34 |
return "untested" |
return "untested" |
35 |
} |
} |
36 |
if [is_remote host] { |
if [is_remote host] { |
37 |
set prog [remote_download host $prog]; |
set prog [remote_download host $prog] |
38 |
if { $prog == "" } { |
if { $prog == "" } { |
39 |
verbose -log "Unable to download $prog to host."; |
verbose -log "Unable to download $prog to host." |
40 |
return "untested"; |
return "untested" |
41 |
} |
} |
42 |
} |
} |
43 |
|
|
44 |
if [board_info $dest exists objcopy] { |
if [board_info $dest exists objcopy] { |
45 |
set OBJCOPY [board_info $dest objcopy]; |
set OBJCOPY [board_info $dest objcopy] |
46 |
set exec_file "${prog}.srec" |
set exec_file "${prog}.srec" |
47 |
set objcopy_args "" |
set objcopy_args "" |
48 |
if [board_info $dest exists use_vma_offset] { |
if [board_info $dest exists use_vma_offset] { |
49 |
set objcopy_args "--adjust-vma=[board_info $dest hex_startaddr]"; |
set objcopy_args "--adjust-vma=[board_info $dest hex_startaddr]" |
50 |
} |
} |
51 |
set status [remote_exec host "$OBJCOPY $objcopy_args -O srec $prog ${prog}.srec"] |
set status [remote_exec host "$OBJCOPY $objcopy_args -O srec $prog ${prog}.srec"] |
52 |
set result [lindex $status 1]; |
set result [lindex $status 1] |
53 |
regsub -all -- "\[\r\n\]*" $result "" result |
regsub -all -- "\[\r\n\]*" $result "" result |
54 |
if { $result != "" || [lindex $status 0] != 0 } { |
if { $result != "" || [lindex $status 0] != 0 } { |
55 |
warning "Got \"$result\" from $OBJCOPY" |
warning "Got \"$result\" from $OBJCOPY" |
56 |
verbose -log "Couldn't convert to srecord for downloading" |
verbose -log "Couldn't convert to srecord for downloading" |
57 |
remote_close $dest; |
remote_close $dest |
58 |
return "untested" |
return "untested" |
59 |
} else { |
} else { |
60 |
verbose "Converted $prog to an srecord." 2 |
verbose "Converted $prog to an srecord." 2 |
63 |
set exec_file $prog |
set exec_file $prog |
64 |
} |
} |
65 |
|
|
66 |
set value 0; |
set value 0 |
67 |
if ![board_info $dest exists fileid] { |
if ![board_info $dest exists fileid] { |
68 |
while { $value < 2 } { |
while { $value < 2 } { |
69 |
set rom68k_shell_id [remote_open $dest] |
set rom68k_shell_id [remote_open $dest] |
72 |
verbose -log "$prog not executed, couldn't connect to target." |
verbose -log "$prog not executed, couldn't connect to target." |
73 |
return "untested" |
return "untested" |
74 |
} |
} |
75 |
incr value; |
incr value |
76 |
} else { |
} else { |
77 |
break; |
break |
78 |
} |
} |
79 |
} |
} |
80 |
# dbug has problems if we go into binary mode, so this allows us to |
# dbug has problems if we go into binary mode, so this allows us to |
81 |
# disable entry into binary mode. |
# disable entry into binary mode. |
82 |
if ![board_info $dest exists no_binary_mode] { |
if ![board_info $dest exists no_binary_mode] { |
83 |
remote_binary $dest; |
remote_binary $dest |
84 |
} |
} |
85 |
} |
} |
86 |
|
|
88 |
# can load it |
# can load it |
89 |
if [is_remote host] { |
if [is_remote host] { |
90 |
global objdir |
global objdir |
91 |
set exec_file [remote_upload host ${exec_file} "${objdir}/a.out"]; |
set exec_file [remote_upload host ${exec_file} "${objdir}/a.out"] |
92 |
} |
} |
93 |
|
|
94 |
set got_p 0; |
set got_p 0 |
95 |
for { set tries 0; } { (! $got_p) && $tries < 5 } { incr tries } { |
for { set tries 0; } { (! $got_p) && $tries < 5 } { incr tries } { |
96 |
remote_send $dest "\r\n\r\n" |
remote_send $dest "\r\n\r\n" |
97 |
remote_expect $dest 5 { |
remote_expect $dest 5 { |
98 |
-re "${shell_prompt}$" { |
-re "${shell_prompt}$" { |
99 |
verbose "Got prompt." |
verbose "Got prompt." |
100 |
set result 0 |
set result 0 |
101 |
set got_p 1; |
set got_p 1 |
102 |
} |
} |
103 |
timeout { |
timeout { |
104 |
warning "Never got prompt." |
warning "Never got prompt." |
107 |
if { ! $got_p } { |
if { ! $got_p } { |
108 |
if $tries<=4 then { |
if $tries<=4 then { |
109 |
if { $tries == 3 } then { |
if { $tries == 3 } then { |
110 |
remote_reboot $dest; |
remote_reboot $dest |
111 |
} else { |
} else { |
112 |
remote_send $dest "\r\n" |
remote_send $dest "\r\n" |
113 |
} |
} |
119 |
# scrogged -- the remote_expect above will fail in a lot of |
# scrogged -- the remote_expect above will fail in a lot of |
120 |
# non-clean ways. |
# non-clean ways. |
121 |
if { ! $got_p } { |
if { ! $got_p } { |
122 |
remote_close $dest; |
remote_close $dest |
123 |
remote_reboot $dest; |
remote_reboot $dest |
124 |
return "unresolved"; |
return "unresolved" |
125 |
} else { |
} else { |
126 |
# Flush out any remaining cruft. |
# Flush out any remaining cruft. |
127 |
remote_expect $dest 2 { |
remote_expect $dest 2 { |
133 |
|
|
134 |
if [board_info $dest exists download_command] { |
if [board_info $dest exists download_command] { |
135 |
# Load the program. |
# Load the program. |
136 |
remote_send $dest "\r\n"; |
remote_send $dest "\r\n" |
137 |
# dbug has problems sending download command immediately after a |
# dbug has problems sending download command immediately after a |
138 |
# newline, so we wait for the prompt to come back first. |
# newline, so we wait for the prompt to come back first. |
139 |
remote_expect $dest 5 { |
remote_expect $dest 5 { |
150 |
[board_info $dest download_response] { } |
[board_info $dest download_response] { } |
151 |
timeout { |
timeout { |
152 |
perror "Download command never responded." |
perror "Download command never responded." |
153 |
return "unresolved"; |
return "unresolved" |
154 |
} |
} |
155 |
} |
} |
156 |
} |
} |
157 |
} |
} |
158 |
|
|
159 |
verbose "Writing records to target..." |
verbose "Writing records to target..." |
160 |
set status [remote_transmit $dest $exec_file]; |
set status [remote_transmit $dest $exec_file] |
161 |
if { $exec_file != $prog } { |
if { $exec_file != $prog } { |
162 |
remote_file build delete $exec_file |
remote_file build delete $exec_file |
163 |
} |
} |
164 |
if { $status != 0 } { |
if { $status != 0 } { |
165 |
remote_close $dest; |
remote_close $dest |
166 |
verbose -log "Transmission of $exec_file to the target failed." 3 |
verbose -log "Transmission of $exec_file to the target failed." 3 |
167 |
return "unresolved" |
return "unresolved" |
168 |
} |
} |
169 |
verbose "Wrote records to target...waiting for prompt." |
verbose "Wrote records to target...waiting for prompt." |
170 |
remote_send $dest "\n" |
remote_send $dest "\n" |
171 |
set got_p 0; |
set got_p 0 |
172 |
remote_expect $dest 50 { |
remote_expect $dest 50 { |
173 |
-re "$shell_prompt$" { |
-re "$shell_prompt$" { |
174 |
verbose "Got prompt." |
verbose "Got prompt." |
175 |
set got_p 1; |
set got_p 1 |
176 |
} |
} |
177 |
timeout { } |
timeout { } |
178 |
} |
} |
183 |
-re ".+" { exp_continue } |
-re ".+" { exp_continue } |
184 |
default { } |
default { } |
185 |
} |
} |
186 |
return "pass"; |
return "pass" |
187 |
} else { |
} else { |
188 |
remote_close $dest; |
remote_close $dest |
189 |
remote_reboot $dest; |
remote_reboot $dest |
190 |
return "unresolved"; |
return "unresolved" |
191 |
} |
} |
192 |
|
|
193 |
} |
} |
194 |
|
|
195 |
|
|
196 |
proc base68k_spawn { dest prog args } { |
proc base68k_spawn { dest prog args } { |
197 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
198 |
|
|
199 |
set result [remote_ld $dest $prog]; |
set result [remote_ld $dest $prog] |
200 |
if { $result != "pass" } { |
if { $result != "pass" } { |
201 |
return [list $result ""]; |
return [list $result ""] |
202 |
} |
} |
203 |
|
|
204 |
if [board_info $dest exists startaddr] { |
if [board_info $dest exists startaddr] { |
205 |
set go_command "[board_info $dest go_command] [board_info $dest startaddr]"; |
set go_command "[board_info $dest go_command] [board_info $dest startaddr]" |
206 |
} else { |
} else { |
207 |
set go_command "[board_info $dest go_command]"; |
set go_command "[board_info $dest go_command]" |
208 |
} |
} |
209 |
|
|
210 |
verbose "Sending $go_command, waiting for results."; |
verbose "Sending $go_command, waiting for results." |
211 |
remote_send $dest "${go_command}\n"; |
remote_send $dest "${go_command}\n" |
212 |
return { "pass" "" }; |
return { "pass" "" } |
213 |
} |
} |
214 |
|
|
215 |
proc base68k_wait { dest timeout } { |
proc base68k_wait { dest timeout } { |
216 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
217 |
set noappend 0; |
set noappend 0 |
218 |
set result -1; |
set result -1 |
219 |
|
|
220 |
set output ""; |
set output "" |
221 |
|
|
222 |
remote_expect $dest $timeout { |
remote_expect $dest $timeout { |
223 |
-re [board_info $dest go_response] { |
-re [board_info $dest go_response] { |
224 |
append output $expect_out(buffer); |
append output $expect_out(buffer) |
225 |
set noappend 1; |
set noappend 1 |
226 |
set result 0; |
set result 0 |
227 |
exp_continue -continue_timer; |
exp_continue -continue_timer |
228 |
} |
} |
229 |
-re "$shell_prompt$" { |
-re "$shell_prompt$" { |
230 |
verbose "Got prompt."; |
verbose "Got prompt." |
231 |
set result 0; |
set result 0 |
232 |
} |
} |
233 |
-re "\[\r\n\]+" { |
-re "\[\r\n\]+" { |
234 |
if { ! $noappend } { |
if { ! $noappend } { |
235 |
append output $expect_out(buffer); |
append output $expect_out(buffer) |
236 |
if { [string length $output] < 512000 } { |
if { [string length $output] < 512000 } { |
237 |
exp_continue -continue_timer; |
exp_continue -continue_timer |
238 |
} else { |
} else { |
239 |
set result -1; |
set result -1 |
240 |
} |
} |
241 |
} |
} |
242 |
} |
} |
243 |
timeout { |
timeout { |
244 |
warning "Nothing ever came back."; |
warning "Nothing ever came back." |
245 |
set result -1; |
set result -1 |
246 |
} |
} |
247 |
} |
} |
248 |
|
|
249 |
if [board_info $dest exists output_end] { |
if [board_info $dest exists output_end] { |
250 |
regsub "[board_info $dest output_end]" "$output" "\n" output; |
regsub "[board_info $dest output_end]" "$output" "\n" output |
251 |
} |
} |
252 |
|
|
253 |
# There has got to be a better way. (We need to do this in order to remove |
# There has got to be a better way. (We need to do this in order to remove |
254 |
# the echoed "go command". |
# the echoed "go command". |
255 |
if [board_info $dest exists startaddr] { |
if [board_info $dest exists startaddr] { |
256 |
set go_command "[board_info $dest go_command] [board_info $dest startaddr]"; |
set go_command "[board_info $dest go_command] [board_info $dest startaddr]" |
257 |
} else { |
} else { |
258 |
set go_command "[board_info $dest go_command]"; |
set go_command "[board_info $dest go_command]" |
259 |
} |
} |
260 |
|
|
261 |
regsub "^.*$go_command\[\r\n\]*" "$output" "" output; |
regsub "^.*$go_command\[\r\n\]*" "$output" "" output |
262 |
regsub "^.*$go_command\[\r\n\]*" "$output" "" output; |
regsub "^.*$go_command\[\r\n\]*" "$output" "" output |
263 |
|
|
264 |
# We always want to check for a status, even if there was a funky weird |
# We always want to check for a status, even if there was a funky weird |
265 |
# failure above. |
# failure above. |
266 |
set status [check_for_board_status output]; |
set status [check_for_board_status output] |
267 |
if { $result == 0 } { |
if { $result == 0 } { |
268 |
set result $status; |
set result $status |
269 |
verbose -log "exit status was $status"; |
verbose -log "exit status was $status" |
270 |
} |
} |
271 |
# A negative value indicates that we should reboot. Otherwise, return |
# A negative value indicates that we should reboot. Otherwise, return |
272 |
# the exit status from the program if we got one (and we should have). |
# the exit status from the program if we got one (and we should have). |
273 |
return [list $result "$output"]; |
return [list $result "$output"] |
274 |
} |
} |
275 |
|
|
276 |
proc base68k_load { dest prog args } { |
proc base68k_load { dest prog args } { |
277 |
global base68k_retry |
global base68k_retry |
278 |
|
|
279 |
set shell_prompt [board_info $dest shell_prompt]; |
set shell_prompt [board_info $dest shell_prompt] |
280 |
|
|
281 |
if { [llength $args] > 0 } { |
if { [llength $args] > 0 } { |
282 |
for { set x 0; } { $x < [llength $args] } { incr x ; } { |
for { set x 0; } { $x < [llength $args] } { incr x ; } { |
283 |
if { [lindex $args $x] != "" } { |
if { [lindex $args $x] != "" } { |
284 |
verbose -log "Cannot pass parameters or input file to this target"; |
verbose -log "Cannot pass parameters or input file to this target" |
285 |
return [list "unsupported" ""]; |
return [list "unsupported" ""] |
286 |
} |
} |
287 |
} |
} |
288 |
} |
} |
289 |
|
|
290 |
set result [remote_spawn $dest $prog]; |
set result [remote_spawn $dest $prog] |
291 |
if { [lindex $result 0] != "pass" } { |
if { [lindex $result 0] != "pass" } { |
292 |
return $result; |
return $result |
293 |
} |
} |
294 |
|
|
295 |
# FIXME: The value 360 below should be a parameter. |
# FIXME: The value 360 below should be a parameter. |
296 |
|
|
297 |
set result [remote_wait $dest 360]; |
set result [remote_wait $dest 360] |
298 |
set output [lindex $result 1]; |
set output [lindex $result 1] |
299 |
set status [lindex $result 0]; |
set status [lindex $result 0] |
300 |
|
|
301 |
verbose "output from board is $output" |
verbose "output from board is $output" |
302 |
|
|
304 |
send_log "\n" |
send_log "\n" |
305 |
|
|
306 |
if { $status > 0 } { |
if { $status > 0 } { |
307 |
return [list "fail" $output]; |
return [list "fail" $output] |
308 |
} elseif { $status == 0 } { |
} elseif { $status == 0 } { |
309 |
return [list "pass" $output]; |
return [list "pass" $output] |
310 |
} else { |
} else { |
311 |
if [info exists base68k_retry] { |
if [info exists base68k_retry] { |
312 |
return [list "fail" $output]; |
return [list "fail" $output] |
313 |
} |
} |
314 |
set base68k_retry 1; |
set base68k_retry 1 |
315 |
remote_reboot $dest; |
remote_reboot $dest |
316 |
set status [eval base68k_load \{$dest\} \{$prog\} $args]; |
set status [eval base68k_load \{$dest\} \{$prog\} $args] |
317 |
unset base68k_retry; |
unset base68k_retry |
318 |
return $status; |
return $status |
319 |
} |
} |
320 |
} |
} |
321 |
|
|
322 |
set_board_info protocol "base68k"; |
set_board_info protocol "base68k" |
323 |
set_board_info send_initial_cr 1 |
set_board_info send_initial_cr 1 |