1
# Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software
4
# This file is part of DejaGnu.
6
# DejaGnu is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
11
# DejaGnu is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with DejaGnu; if not, write to the Free Software Foundation,
18
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
# Initialize the board on initial connection or after rebooting.
22
# Since the board autobauds, we have to be a bit aggressive about
23
# getting a valid prompt.
25
proc ${board}_init { dest } {
28
set prompt [board_info $dest shell_prompt]
31
if ![info exists i960_try_count] {
36
if { [remote_open $dest] != "" } {
37
for { set tries 0 } { $tries < 7 && ! $done } { incr tries } {
38
remote_send $dest "\n"
39
remote_expect $dest 1 {
43
-re ".+" { exp_continue }
51
if { $i960_try_count == 3 } {
52
perror "Couldn't connect to board."
59
if [info exists i960_try_count] {
64
proc i960_ld { dest prog } {
65
if ![file exists $prog] {
66
perror "$prog does not exist."
69
set shell_prompt [board_info $dest shell_prompt]
70
set strip [board_info $dest strip]
71
set rprog [remote_download host $prog a.out]
73
remote_exec host $strip $rprog
75
remote_upload host $rprog a.out
77
set id [remote_open $dest]
82
remote_send $dest "\n"
83
remote_expect $dest 5 {
86
remote_send $dest "do\n"
87
remote_expect $dest 5 {
91
if { [board_info $dest connect] == "telnet" } {
95
set hp [split [board_info $dest netport] ":"]
96
set host [lindex $hp 0]
97
set port [lindex $hp 1]
99
while { $status != 0 } {
100
set status [catch "socket $host $port" id2]
101
if { $status != 0 } {
106
set id2 [exp_open -leaveopen -i $id]
108
if [catch "exec sx -bX a.out <@$id2 >@$id2 2>/dev/null" error] {
109
perror "exec sx failed: $error"
111
if { [board_info $dest connect] == "telnet" } {
118
remote_send $dest "\n"
119
remote_expect $dest 1 {
120
-re "$shell_prompt" {
129
proc i960_spawn { dest prog args } {
130
set shell_prompt [board_info $dest shell_prompt]
132
for { set tries 0 } { $tries < 3 } { incr tries } {
133
set result [remote_ld $dest $prog]
134
if { $result == 0 } {
135
set comm "go [board_info $dest start_addr]"
136
remote_send $dest "$comm\n"
137
remote_expect $dest 10 {
138
-re "$comm\[\r\n\]\[\r\n\]?" { }
141
return [board_info $dest fileid]
149
proc i960_wait { dest timeout } {
151
set shell_prompt [board_info $dest shell_prompt]
153
remote_expect $dest $timeout {
154
-re " fault at \[0-9a-h\]+, subtype \[0-9a-h\]+" {
158
-re "(.*)(\[\r\n\]|^)Program Exit: (\[0-9\]+)\[\r\n\]" {
159
append output $expect_out(1,string)
160
set status $expect_out(3,string)
163
-re "(.*)$shell_prompt" {
164
append output $expect_out(1,string)
165
set bstatus [check_for_board_status output]
166
if { $bstatus >= 0 } {
171
# Sometimes the board goes wacky in the head, and we have
173
append output $expect_out(buffer)
174
if { [string length $output] < 512000 } {
184
return [list $status $output]
187
proc i960_load { dest prog args } {
188
for { set x 0 } { $x < 3 } { incr x } {
189
set id [eval remote_spawn \{$dest\} \{$prog\} $args]
191
return [list "fail" ""]
193
set result [remote_wait $dest 120]
194
set status [lindex $result 0]
195
set output [lindex $result 1]
197
if { $status == 0 } {
198
return [list "pass" $output]
202
if { [board_info $dest exists unreliable] && ![info exists i960_retry] } {
205
set result [eval i960_load \{$dest\} \{$prog\} $args]
212
return [list "fail" $output]
218
set_board_info shell_prompt "=>"
219
set_board_info send_initial_cr 1
220
# We take care of getting a prompt in ${board}_init.
221
set_board_info dont_wait_for_prompt 1