1 # Copyright
(C
) 1992-2016 Free Software Foundation
, Inc.
3 # This file is part of DejaGnu.
5 # DejaGnu is free software
; you can redistribute it and
/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation
; either version
3 of the License
, or
8 #
(at your option
) any later version.
10 # DejaGnu is distributed in the hope that it will be useful
, but
11 # WITHOUT
ANY WARRANTY
; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License
for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with DejaGnu
; if not
, write to the Free Software Foundation
,
17 # Inc.
, 51 Franklin Street
- Fifth Floor
, Boston
, MA
02110-1301, USA.
19 # This file was originally written by Rob Savoye
<rob@welcomehome.org
>
20 # and modified by Bob Manson
<manson@cygnus.com
>.
23 # Try to boot the machine into the requested OS.
25 proc $
{board
}_init
{ dest
} {
26 # This is not the right way to determine the required OS...
28 set shell_prompt
[board_info $dest shell_prompt
]
31 set desired_kernel
[board_info $dest
"kernel,$target_os"]
33 if { $desired_kernel eq
"" } {
34 vxworks_final_init $dest
35 # Nothing to see here
, nothing to
do.
Move along.
39 remote_raw_open $dest raw
40 remote_send $dest
"\n"
41 remote_expect $dest
5 {
45 -re
"Press any key to stop auto-boot" {
46 remote_send $dest
"\n"
51 set boot_mon_prompt
"VxWorks Boot"
53 -re
{[0-9][\r\n]+ *[0-9][\r\n]} {
54 remote_send $dest
"\n"
68 remote_send $dest
"\n\n"
69 remote_expect $dest
3 {
71 -re
".+" { exp_continue }
73 remote_send $dest
"p\n"
74 remote_expect $dest
20 {
75 -re
{file
name[ \t]+: ([^
\r\n]+)[ \r\n]+} {
76 set curr_file $expect_out
(1,string
)
79 -re $boot_mon_prompt
{ }
81 if {![info exists curr_file
]} {
86 if { $curr_file ne $desired_kernel
} {
87 verbose
"$curr_file != '$desired_kernel'"
89 remote_send $dest
"c\n"
90 remote_expect $dest
20 {
91 -re
{file
name[ \t]+:.
*$
} {
92 remote_send $dest
"$desired_kernel\n"
95 -re
{[a
-z
() \t]+:.
*$
} {
96 remote_send $dest
"\n"
99 -re $boot_mon_prompt
{}
102 remote_send $dest
"@\n"
103 remote_expect $dest
30 {
104 -re
"(^|\[\r\n\])$shell_prompt" {}
109 vxworks_final_init $dest
113 proc vxworks_final_init
{ dest
} {
114 if {[board_info $dest
exists preload_obj
]} {
115 if { [target_compile
[board_info $dest preload_obj
] foo.out object
[board_info $dest preload_obj_flags
]] eq
"" } {
116 vxworks_ld $dest foo.out
118 remote_file build
delete foo.out
122 #
Execute the command
PROGRAM on VxWorks.
125 proc vxworks_exec
{ dest
program pargs inp outp
} {
128 set shell_id
[vxworks_open $dest
]
129 if { $shell_id
< 0 } {
130 return [list
-1 "open failure"]
134 set inp
[remote_download $dest $inp
]
140 set shell_prompt
[board_info $dest shell_prompt
]
141 remote_send $dest
"$program $pargs$suffix\n"
142 # FIXME
: The value
300 below should probably be a parameter passed in.
143 remote_expect $dest
300 {
144 -re
{\
[VxWorks Boot\
]:} {
145 remote_send $dest
"@\n"
149 -re
"(.*)value = (-*$decimal) = $hex\[^\r\n\]*\[\r\n\]+$shell_prompt" {
150 set result
[list $expect_out
(2,string
) $expect_out
(1,string
)]
152 -re
"undefined symbol: .*$shell_prompt" {
153 set result
[list
1 "unknown command"]
155 -re
"syntax error.*$shell_prompt" {
156 set result
[list
-1 "syntax error in command"]
159 set result
[list
-1 "unable to execute command"]
162 if { $suffix ne
"" } {
163 remote_file $dest
delete $inp
168 proc vxworks_download
{ dest localfile remotefile
} {
169 if {[board_info $dest
exists vxworks_homedir
]} {
170 set rfile
"[board_info $dest vxworks_homedir]/$remotefile"
171 remote_download build $localfile $rfile
174 return [remote_raw_download $dest $localfile $remotefile
]
177 proc vxworks_file
{ dest op
args } {
178 set file
[lindex $
args 0]
179 if {[board_info $dest
exists vxworks_homedir
]} {
180 set dir "[board_info $dest vxworks_homedir]"
183 set file
"$dir/[file tail $file]"
184 return [file
exists $file
]
188 set x
"$dir/[file tail $x]"
189 if { [file
exists $x
] && [file isfile $x
] } {
190 file
delete -force
-- $x
197 return [eval remote_raw_file
\"$dest
\" \"$op
\" $
args]
200 proc vxworks_send
{ dest string
} {
201 #
Convert LFs to CRs
, 'cause that is what VxWorks wants to see.
202 regsub -all "\n" $string "\r" string
203 verbose "Sending '$string
' to $dest" 2
204 return [remote_raw_send $dest $string]
207 proc vxworks_open { dest args } {
208 if {[board_info $dest exists fileid]} {
209 return [board_info $dest fileid]
212 set shell_prompt [board_info $dest shell_prompt]
214 set shell_id [remote_raw_open $dest]
216 if { $shell_id eq "" || $shell_id < 0 } {
220 if {[board_info $dest exists logname]} {
221 set logname [board_info $dest logname]
222 if {[board_info $dest exists password]} {
223 remote_send $dest "iam \"$logname\",\"[board_info $dest passwd]\"\r"
225 remote_send $dest "iam \"$logname\"\r"
228 remote_expect $dest 30 {
229 "iam*value = 0 = 0x0*$shell_prompt" {
230 verbose "Set default user." 2
233 perror "Couldn't
set default user.
"
240 if {[board_info $dest
exists ftp_directory
]} {
241 set dir [board_info $dest ftp_directory
]
243 if {[board_info $dest
exists vxworks_homedir
]} {
244 set dir [board_info $dest vxworks_homedir
]
247 set status [remote_exec $dest
"cd" "\"$dir\""]
248 if {[lindex $
status 0]} {
249 perror
"Error in cd to $dir--[lindex $status 1]"
256 #
Load a file into vxworks
260 #
1 - failed
(eg
: link failed so testcase should fail
)
261 #
-1 - unresolved
(eg
: timeout
), may be fixed by rebooting
263 proc vxworks_ld
{ dest prog
} {
271 set shell_id
[remote_open $dest
]
273 if { $shell_id
< 0 } {
277 set prog
[remote_download $dest $prog
]
279 set shell_prompt
[board_info $dest shell_prompt
]
281 # We always want to exit the
program via the code at the end.
282 #
If the
load fails we want `expect_out
' stored in the log and this
283 # saves duplicating that code.
285 for { set x 0 } { $x < 3 } { incr x } {
286 remote_send $dest "\n"
287 remote_expect $dest 30 {
288 -re ".*$shell_prompt $" { set x 20 }
289 -re {\[VxWorks Boot\]:} {
290 remote_send $dest "@\n"
294 timeout { return -1 }
300 set result -7 ;# -7 is a local value meaning "not done"
302 while { $result == -7 && $tries < $maxtries } {
303 verbose "Loading $prog into vxworks."
304 remote_send $dest "ld < $prog\n"
306 remote_expect $dest 300 {
307 -re "USER.*command not understood" {
308 perror "Need to set the user and password."
311 -re "Stale NFS file handle.*$shell_prompt $" {
314 -re "undefined symbol:.*$shell_prompt $" {
315 # This is an error in the testcase, don't
call perror.
316 warning
"Undefined symbol, $prog not loaded."
319 -re
"memPartAlloc: block too.*$shell_prompt $" {
320 perror
"Not enough memory to load $prog."
323 -re
"can't open input.*$shell_prompt $" {
324 perror
"Can't access $prog."
327 -re
"value = (-*$decimal) = $hex.*$shell_prompt $" {
328 verbose
"Loaded $prog into vxworks."
329 set board_info
([board_info $dest
name],vx_module
) $expect_out
(1,string
)
332 -re
"(.*)$shell_prompt $" {
333 warning
"Load failed: $expect_out(1,string)"
336 warning
"Timed out trying load $prog."
342 if { $result
&& [info exists expect_out
(buffer
)] } {
343 send_log $expect_out
(buffer
)
346 remote_file $dest
delete $prog
351 # Start a thread
(process
) executing
355 #
1 - failed
(eg
: testcase aborted
)
356 #
-1 - unresolved
, may be fixed by rebooting
358 proc vxworks_run
{ dest function pargs inp outp
} {
361 set shell_prompt
[board_info $dest shell_prompt
]
364 # There isn
't a command to wait for a thread to finish, so we have to keep
365 # polling. Instead, we expect the status wrapper to return an exit
368 set status [remote_exec $dest "sp" "$function $pargs" $inp $outp]
370 set tid [lindex $status 0]
372 # Bad task id, reboot and try again.
373 if { $tid == -1 || $tid == 0 } {
378 # FIXME: The value 300 below should be a parameter.
379 remote_expect $dest 300 {
380 -re "task $hex - aborted.*$shell_prompt $" {
381 # FIXME: It's not clear we
'll ever get here.
382 verbose "$function aborted"
385 -re {[\r\n]syntax error[\r\n]} {
386 verbose "weirdness after task started"
389 -re "(.*)\\*\\*\\* EXIT code ($decimal)\[\r\n\]" {
390 set output $expect_out(1,string)
391 set exit_code $expect_out(2,string)
392 if { ($exit_code + 0) != 0 } {
398 -re "Operation Fault.*fault type:" {
402 # This is here to try to cope with apparently flaky h/w.
403 # This is potentially an error in the testcase, but we don't
404 # really know
, do we?
407 set output
"Bus Error"
411 # Infinite loop? probably.
412 remote_exec $dest
"td" $tid
417 return [list $result $output
]
421 # Unload the last executable that we loaded
, so we can free up its memory.
423 proc vxworks_unld
{ dest
} {
426 if {[board_info $dest
exists vx_module
]} {
427 # Vxworks5.0 does not have the unld command.
428 if { [board_info $dest os
] ne
"vxworks5.0" } {
429 remote_exec $dest
"unld" "[board_info $dest vx_module]"
431 unset board_info
([board_info $dest
name],vx_module
)
436 # We loop around rebooting the box until either the
load and run
437 #
"work" or we give up.
439 proc vxworks_load
{dest prog
args} {
443 if { [llength $
args] > 0 } {
444 set pargs
"[lindex $args 0]"
449 if { [llength $
args] > 1 } {
450 set inp
"[lindex $args 1]"
455 if { [llength $
args] > 2 } {
456 set outp
"[lindex $args 2]"
461 for { set x
0 } { $x
< 3 } { incr x
} {
462 set status [vxworks_ld $dest $prog
]
463 if { $
status >= 0 } {
467 set out
[vxworks_run $dest __wrap_main $pargs $inp $outp
]
468 set status [lindex $out
0]
469 set output
[lindex $out
1]
470 #
Get rid of the carriage returns
, because they confuse
471 # callers that try to
parse the result.
472 regsub
-all
"\r" $output "" output
473 if { $
status != 0 } {
482 if { $result ne
"" } {
484 return [list $result $output
]
488 return [list
"fail" ""]
491 set_board_info protocol
"vxworks"
492 #
-lm under vxworks isn
't needed.
493 set_board_info mathlib ""
494 set_board_info shell_prompt "->"
495 set_board_info needs_status_wrapper 1
496 # FTP doesn't work in passive
mode to this board.
497 set_board_info ftp_no_passive
1
498 # Wait
15 seconds after powercycling.
499 set_board_info reboot_delay
15
501 # We don
't have sys/unistd.h.
502 set_board_info wrap_compile_flags "-DNO_UNISTD_H"
504 set_board_info gdb_prompt "\[(\]vxgdb\[)\]"
506 set_board_info is_vxworks 1
507 set_board_info gdb,nosignals 1