21 |
|
|
22 |
# Reset the prompt to what GDB needs. |
# Reset the prompt to what GDB needs. |
23 |
proc ${board}_init { dest } { |
proc ${board}_init { dest } { |
24 |
global doing_ddb_init; |
global doing_ddb_init |
25 |
|
|
26 |
if ![info exists doing_ddb_init] { |
if ![info exists doing_ddb_init] { |
27 |
set doing_ddb_init 1; |
set doing_ddb_init 1 |
28 |
|
|
29 |
remote_close $dest; |
remote_close $dest |
30 |
for { set x 0; } { $x < 3 } { incr x; } { |
for { set x 0; } { $x < 3 } { incr x; } { |
31 |
set shell_id [remote_open $dest]; |
set shell_id [remote_open $dest] |
32 |
if { $shell_id == "" || $shell_id < 0 } { |
if { $shell_id == "" || $shell_id < 0 } { |
33 |
remote_reboot $dest; |
remote_reboot $dest |
34 |
} else { |
} else { |
35 |
break; |
break |
36 |
} |
} |
37 |
} |
} |
38 |
|
|
39 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
40 |
|
|
41 |
remote_send $dest "\n"; |
remote_send $dest "\n" |
42 |
remote_expect $dest 10 { |
remote_expect $dest 10 { |
43 |
-re ".*PMON> $" { |
-re ".*PMON> $" { |
44 |
remote_send $dest "set prompt \"$shell_prompt\"\n"; |
remote_send $dest "set prompt \"$shell_prompt\"\n" |
45 |
exp_continue; |
exp_continue |
46 |
} |
} |
47 |
-re ".*${shell_prompt}$" { } |
-re ".*${shell_prompt}$" { } |
48 |
} |
} |
49 |
remote_close $dest; |
remote_close $dest |
50 |
unset doing_ddb_init; |
unset doing_ddb_init |
51 |
} else { |
} else { |
52 |
return; |
return |
53 |
} |
} |
54 |
} |
} |
55 |
|
|
56 |
proc ddb_ether_load { dest prog args } { |
proc ddb_ether_load { dest prog args } { |
57 |
for { set x 0; } { $x < 3 } { incr x } { |
for { set x 0; } { $x < 3 } { incr x } { |
58 |
set result [eval remote_spawn \{$dest\} \{$prog\} $args]; |
set result [eval remote_spawn \{$dest\} \{$prog\} $args] |
59 |
if { $result < 0 } { |
if { $result < 0 } { |
60 |
remote_reboot $dest; |
remote_reboot $dest |
61 |
} else { |
} else { |
62 |
set result [remote_wait $dest 300]; |
set result [remote_wait $dest 300] |
63 |
set status [lindex $result 0]; |
set status [lindex $result 0] |
64 |
set output [lindex $result 1]; |
set output [lindex $result 1] |
65 |
if { $status >= 0 } { |
if { $status >= 0 } { |
66 |
if { $status > 0 } { |
if { $status > 0 } { |
67 |
return [list "fail" $output]; |
return [list "fail" $output] |
68 |
} else { |
} else { |
69 |
return [list "pass" $output]; |
return [list "pass" $output] |
70 |
} |
} |
71 |
} |
} |
72 |
} |
} |
73 |
} |
} |
74 |
return [list "fail" ""]; |
return [list "fail" ""] |
75 |
} |
} |
76 |
|
|
77 |
proc ddb_ether_ld { dest prog } { |
proc ddb_ether_ld { dest prog } { |
78 |
if ![board_info $dest exists tftpdir] { |
if ![board_info $dest exists tftpdir] { |
79 |
perror "Must set_board_info tftpdir for [board_info $dest name]"; |
perror "Must set_board_info tftpdir for [board_info $dest name]" |
80 |
return "fail"; |
return "fail" |
81 |
} |
} |
82 |
|
|
83 |
if ![board_info $dest exists fileid] { |
if ![board_info $dest exists fileid] { |
84 |
set spawn_id [remote_open $dest]; |
set spawn_id [remote_open $dest] |
85 |
if { $spawn_id == "" || $spawn_id < 0 } { |
if { $spawn_id == "" || $spawn_id < 0 } { |
86 |
return "retry"; |
return "retry" |
87 |
} |
} |
88 |
remote_binary $dest; |
remote_binary $dest |
89 |
} |
} |
90 |
|
|
91 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
92 |
|
|
93 |
remote_send $dest "\n"; |
remote_send $dest "\n" |
94 |
remote_expect $dest 10 { |
remote_expect $dest 10 { |
95 |
-re ".*${shell_prompt}$" { } |
-re ".*${shell_prompt}$" { } |
96 |
default { |
default { |
97 |
return "retry"; |
return "retry" |
98 |
} |
} |
99 |
} |
} |
100 |
set basename "a.out.[pid]"; |
set basename "a.out.[pid]" |
101 |
set file "[board_info $dest tftpdir]/$basename"; |
set file "[board_info $dest tftpdir]/$basename" |
102 |
set file [remote_download build $prog $file]; |
set file [remote_download build $prog $file] |
103 |
if { $file == "" } { |
if { $file == "" } { |
104 |
perror "download to tftp area failed"; |
perror "download to tftp area failed" |
105 |
return "fail"; |
return "fail" |
106 |
} |
} |
107 |
set state "pass"; |
set state "pass" |
108 |
|
|
109 |
remote_send $dest "boot /$basename\n"; |
remote_send $dest "boot /$basename\n" |
110 |
set tries 0; |
set tries 0 |
111 |
remote_expect $dest 30 { |
remote_expect $dest 30 { |
112 |
-re "Loading.*Entry address is.*${shell_prompt}$" { } |
-re "Loading.*Entry address is.*${shell_prompt}$" { } |
113 |
-re "invalid executable.*${shell_prompt}$" { |
-re "invalid executable.*${shell_prompt}$" { |
114 |
incr tries; |
incr tries |
115 |
if { $tries < 3 } { |
if { $tries < 3 } { |
116 |
sleep 2; |
sleep 2 |
117 |
remote_send $dest "boot /$basename\n"; |
remote_send $dest "boot /$basename\n" |
118 |
exp_continue; |
exp_continue |
119 |
} |
} |
120 |
} |
} |
121 |
-re ".*${shell_prompt}$" { |
-re ".*${shell_prompt}$" { |
122 |
set state "fail"; |
set state "fail" |
123 |
} |
} |
124 |
default { |
default { |
125 |
set state "fail"; |
set state "fail" |
126 |
} |
} |
127 |
} |
} |
128 |
remote_file build delete $file; |
remote_file build delete $file |
129 |
if { $state == "fail" } { |
if { $state == "fail" } { |
130 |
return $state; |
return $state |
131 |
} |
} |
132 |
return "pass"; |
return "pass" |
133 |
} |
} |
134 |
|
|
135 |
proc ddb_ether_spawn { dest prog args } { |
proc ddb_ether_spawn { dest prog args } { |
136 |
set state [ddb_ether_ld $dest $prog]; |
set state [ddb_ether_ld $dest $prog] |
137 |
|
|
138 |
if { $state != "pass" } { |
if { $state != "pass" } { |
139 |
return -1; |
return -1 |
140 |
} |
} |
141 |
remote_send $dest "g\n"; |
remote_send $dest "g\n" |
142 |
remote_expect $dest 5 { |
remote_expect $dest 5 { |
143 |
-re "g\[\r\n\]\[\r\n\]?" { } |
-re "g\[\r\n\]\[\r\n\]?" { } |
144 |
default { } |
default { } |
145 |
} |
} |
146 |
|
|
147 |
return [board_info $dest fileid]; |
return [board_info $dest fileid] |
148 |
} |
} |
149 |
|
|
150 |
proc ddb_ether_wait { dest timeout } { |
proc ddb_ether_wait { dest timeout } { |
151 |
set output ""; |
set output "" |
152 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
153 |
|
|
154 |
remote_expect $dest $timeout { |
remote_expect $dest $timeout { |
155 |
-re "^g\[\r\n\]\[\r\n\]?" { |
-re "^g\[\r\n\]\[\r\n\]?" { |
156 |
if { $output != "" } { |
if { $output != "" } { |
157 |
append output $expect_out(buffer); |
append output $expect_out(buffer) |
158 |
} |
} |
159 |
exp_continue; |
exp_continue |
160 |
} |
} |
161 |
-re "(.*)$shell_prompt" { |
-re "(.*)$shell_prompt" { |
162 |
append output $expect_out(1,string); |
append output $expect_out(1,string) |
163 |
set status [check_for_board_status output]; |
set status [check_for_board_status output] |
164 |
if { $status > 0 } { |
if { $status > 0 } { |
165 |
return [list $status $output]; |
return [list $status $output] |
166 |
} else { |
} else { |
167 |
if [regexp "Exception Cause=" $output] { |
if [regexp "Exception Cause=" $output] { |
168 |
remote_reboot $dest; |
remote_reboot $dest |
169 |
return [list -1 $output]; |
return [list -1 $output] |
170 |
} |
} |
171 |
return [list 0 $output]; |
return [list 0 $output] |
172 |
} |
} |
173 |
} |
} |
174 |
-re "\[\r\n\]+" { |
-re "\[\r\n\]+" { |
175 |
append output $expect_out(buffer); |
append output $expect_out(buffer) |
176 |
if { [string length $output] < 512000 } { |
if { [string length $output] < 512000 } { |
177 |
exp_continue; |
exp_continue |
178 |
} else { |
} else { |
179 |
return [list -1 ""]; |
return [list -1 ""] |
180 |
} |
} |
181 |
} |
} |
182 |
default { |
default { |
183 |
return [list -1 ""]; |
return [list -1 ""] |
184 |
} |
} |
185 |
} |
} |
186 |
} |
} |