OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [boards/] [or32-linux-sim.exp] - Blame information for rev 453

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 453 jeremybenn
#!/bin/bash
2
 
3
# Copyright (C) 2010 Embecosm Limited
4
 
5
# Contributor Jeremy Bennett 
6
# Contributor Joern Rennecke 
7
 
8
# This file is a board description for testing OpenRISC with uClibc and
9
# Or1ksim running Linux.
10
 
11
# This program is free software; you can redistribute it and/or modify it
12
# under the terms of the GNU General Public License as published by the Free
13
# Software Foundation; either version 3 of the License, or (at your option)
14
# any later version.
15
 
16
# This program is distributed in the hope that it will be useful, but WITHOUT
17
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
19
# more details.
20
 
21
# You should have received a copy of the GNU General Public License along
22
# with this program.  If not, see .
23
 
24
# This is a list of toolchains that are supported on this board.
25
set_board_info target_install {or32-linux}
26
 
27
# No multilib options needed by default.
28
process_multilib_options ""
29
 
30
# Load the generic configuration for this board. This will define a basic set
31
# of routines needed by the tool to communicate with the board.
32
load_generic_config "unix"
33
 
34
# Set up remote target info
35
set_board_info hostname "192.168.0.3"
36
set_board_info username root
37
 
38
# Use the installed compilers to ensure we get search paths that will find
39
# uClibc.
40
send_user "set_board_info compiler /opt/or32-new/bin/or32-linux-gcc\n"
41
global GCC_UNDER_TEST
42
set GCC_UNDER_TEST "/opt/or32-new/bin/or32-linux-gcc"
43
set_board_info compiler /opt/or32-new/bin/or32-linux-gcc
44
set_board_info c++compiler /opt/or32-new/bin/or32-linux-g++
45
 
46
set_board_info connect telnet
47
set_board_info shell_prompt    "~ # "
48
set_board_info telnet_username "root"
49
set_board_info telnet_password ""
50
 
51
set_board_info file_transfer ftp
52
set_board_info ftp_username  root
53
set_board_info ftp_password  ""
54
 
55
# Custom proc to close a telnet session
56
proc telnet_close {boardname} {
57
    set spawn_id [board_info $boardname fileid]
58
    verbose "Closing $boardname:$spawn_id"
59
 
60
    if { $spawn_id >= 0 } {
61
        catch {close -i $spawn_id}
62
        catch wait
63
        set spawn_id -1
64
 
65
        set board_info($boardname,fileid) $spawn_id
66
    }
67
}
68
 
69
 
70
# Custom proc to exec programs using telnet
71
proc telnet_exec {boardname cmd args} {
72
    global timeout
73
    global verbose
74
    set output "(no output)"
75
 
76
    verbose "Executing $boardname:$cmd $args"
77
 
78
    if { [llength $args] > 0 } {
79
        set pargs [lindex $args 0];
80
    } else {
81
        set pargs ""
82
    }
83
 
84
    if [board_info $boardname exists shell_prompt] {
85
        set shell_prompt [board_info $boardname shell_prompt]
86
    }
87
    if ![info exists shell_prompt] { # if no prompt, then set it to
88
        something generic
89
        set shell_prompt ".*> "
90
    }
91
 
92
    #Start a new telnet session if one dosen't already exist
93
    if ![board_info $boardname exists fileid] {
94
        if {[telnet_open $boardname] == -1} {
95
            return [list -1
96
                    "telnet to $boardname failed for $cmd, couldn't begin
97
telnet session"]
98
        }
99
    }
100
 
101
    set spawn_id [board_info $boardname fileid]
102
    set timeout 30
103
 
104
    #Hit enter to make sure you get a shell prompt
105
    send -- "\r"
106
 
107
    expect {
108
        -re "$shell_prompt.*$" {
109
            verbose "Got a prompt"
110
        }
111
        default {
112
            telnet_close $boardname
113
            if {[telnet_open $boardname] != -1} {
114
                verbose "started new telnet session, spawn_id is [board_info
115
$boardname fileid]"
116
                send -- "\r"
117
                exp_continue
118
            } else {
119
                return [list -1 "telnet to $boardname failed for $cmd, couldn't get
120
a shell prompt"]
121
            }
122
            send -- "\r"
123
            exp_continue
124
        }
125
    }
126
    set timeout 10
127
    send "$cmd $pargs\r"
128
 
129
    expect {
130
        -re "$shell_prompt.*$" {
131
        }
132
        timeout {
133
            if [info exists expect_out(buffer)] {
134
                set execute_output_string $expect_out(buffer)
135
            }
136
            telnet_close $boardname
137
            return "fail timeout"
138
        }
139
    }
140
    #Remove unesesary strings from the output string
141
    #
142
    #If the file path contains any "+" signs, it will mess things up when $cmd
143
    #is used as a regsub pattern (2 lines down), so we replace all "+"s with "."
144
    regsub -all "\\+" $cmd "." cmd
145
    regsub -all $cmd "$expect_out(buffer)" {} output
146
    regsub $shell_prompt $output {} output
147
    regsub -all "\[\r\n\]" $output {} output
148
 
149
    #Check the return status
150
    set timeout 30
151
    send -- "echo \$?\r"
152
    expect -re "$shell_prompt.*$"
153
 
154
    #Regsub the output to get the status number
155
    regsub -all {echo \$\?} $expect_out(buffer) {} status
156
    regsub $shell_prompt $status {} status
157
    regsub -all "\[\r\n \]" $status {} status
158
 
159
    #This probably isn't neccessary..
160
    if {[regexp {[0123456789]+} $status] != 1} {
161
        warning "status not a number, it is <$status>, setting it to 1"
162
        set status 1
163
    }
164
 
165
    if {$status == 0} {
166
        return [list "0" "$output"]
167
    } else {
168
        return [list "1" "$output"]
169
    }
170
}
171
 
172
# Options for the simulator
173
# set cfg_file [lookfor_file ${srcdir} libgloss/or32/sim.cfg]
174
# set_board_info sim,options "-a \"-f ${cfg_file}\""
175
 
176
# We only support uClibc on this target.  We assume that all multilib options
177
# have been specified before we get here.
178
# set_board_info compiler  "[find_gcc]"
179
 
180
# No linker script needed.
181
set_board_info ldscript ""
182
 
183
# This simulator isn't slow.
184
set_board_info slow_simulator 0
185
 
186
# Can't pass arguments to programs on this target..
187
set_board_info noargs  1
188
 
189
# Used by a few gcc.c-torture testcases to delimit how large the stack can
190
# be.
191
set_board_info gcc,stack_size 65536
192
 
193
# GDB options
194
 
195
# We can't do input in GDB (yet! HA!). It *will* do output, hurrah.
196
set_board_info gdb,noinferiorio 1
197
# Or pass arguments.
198
set_board_info gdb,noargs  1
199
set_board_info noargs 1
200
# And there's no support for signals.
201
set_board_info gdb,nosignals  1

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.