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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [boards/] [or32-linux-sim.exp] - Diff between revs 453 and 473

Show entire file | Details | Blame | View Log

Rev 453 Rev 473
Line 19... Line 19...
# more details.
# more details.
 
 
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see .
# with this program.  If not, see .
 
 
# This is a list of toolchains that are supported on this board.
# -----------------------------------------------------------------------------
set_board_info target_install {or32-linux}
# For telnet targets we need to define some functions.
 
 
# No multilib options needed by default.
 
process_multilib_options ""
 
 
 
# Load the generic configuration for this board. This will define a basic set
 
# of routines needed by the tool to communicate with the board.
 
load_generic_config "unix"
 
 
 
# Set up remote target info
 
set_board_info hostname "192.168.0.3"
 
set_board_info username root
 
 
 
# Use the installed compilers to ensure we get search paths that will find
 
# uClibc.
 
send_user "set_board_info compiler /opt/or32-new/bin/or32-linux-gcc\n"
 
global GCC_UNDER_TEST
 
set GCC_UNDER_TEST "/opt/or32-new/bin/or32-linux-gcc"
 
set_board_info compiler /opt/or32-new/bin/or32-linux-gcc
 
set_board_info c++compiler /opt/or32-new/bin/or32-linux-g++
 
 
 
set_board_info connect telnet
 
set_board_info shell_prompt    "~ # "
 
set_board_info telnet_username "root"
 
set_board_info telnet_password ""
 
 
 
set_board_info file_transfer ftp
 
set_board_info ftp_username  root
 
set_board_info ftp_password  ""
 
 
 
 
# -----------------------------------------------------------------------------
# Custom proc to close a telnet session
# Custom proc to close a telnet session
 
 
 
# @param[in] boardname  The board being closed.
 
# -----------------------------------------------------------------------------
proc telnet_close {boardname} {
proc telnet_close {boardname} {
 
 
 
    # Make the telnet process associated with this board the current process
    set spawn_id [board_info $boardname fileid]
    set spawn_id [board_info $boardname fileid]
    verbose "Closing $boardname:$spawn_id"
    verbose "Closing $boardname:$spawn_id"
 
 
 
    # If we have a process, close it.
    if { $spawn_id >= 0 } {
    if { $spawn_id >= 0 } {
        catch {close -i $spawn_id}
        catch close
        catch wait
        catch wait
        set spawn_id -1
        set spawn_id -1
 
 
        set board_info($boardname,fileid) $spawn_id
        set_board_info $boardname,fileid $spawn_id
    }
    }
}
}
 
 
 
 
 
# -----------------------------------------------------------------------------
# Custom proc to exec programs using telnet
# Custom proc to exec programs using telnet
 
 
 
# We seem to only pass in the first of the arguments supplied to the command.
 
 
 
# We seem to set the timeout to 30, no matter what. Not sure that is right
 
# here.
 
 
 
# @param[in] boardname  The board we are telnetting to
 
# @param[in] cmd        The command to run
 
# @param[in] args       Arguments to the command
 
 
 
# @return  A list of the return code (-1 on failure) and any error message.
 
# -----------------------------------------------------------------------------
proc telnet_exec {boardname cmd args} {
proc telnet_exec {boardname cmd args} {
    global timeout
    global timeout
    global verbose
    global verbose
    set output "(no output)"
    set output "(no output)"
 
 
    verbose "Executing $boardname:$cmd $args"
    verbose "Executing $boardname:$cmd $args"
 
 
 
    # Get the first argument, if any.
    if { [llength $args] > 0 } {
    if { [llength $args] > 0 } {
        set pargs [lindex $args 0];
        set pargs [lindex $args 0];
    } else {
    } else {
        set pargs ""
        set pargs ""
    }
    }
 
 
 
    # Set the shell prompt
    if [board_info $boardname exists shell_prompt] {
    if [board_info $boardname exists shell_prompt] {
        set shell_prompt [board_info $boardname shell_prompt]
        set shell_prompt [board_info $boardname shell_prompt]
    }
    }
    if ![info exists shell_prompt] { # if no prompt, then set it to
    if ![info exists shell_prompt] { # if no prompt, then set it to
        something generic
        something generic
        set shell_prompt ".*> "
        set shell_prompt ".*> "
    }
    }
 
 
    #Start a new telnet session if one dosen't already exist
    # Start a new telnet session if one doesn't already exist. If sucessful
 
    # the fileid field associated with $boardname will be set to the spawn_id
 
    # of the new telnet process.
    if ![board_info $boardname exists fileid] {
    if ![board_info $boardname exists fileid] {
        if {[telnet_open $boardname] == -1} {
        if {[telnet_open $boardname] == -1} {
            return [list -1
            return [list -1
                    "telnet to $boardname failed for $cmd, couldn't begin
                    "telnet to $boardname failed for $cmd, couldn't begin
telnet session"]
telnet session"]
        }
        }
    }
    }
 
 
 
    # Make the telnet session the current process.
    set spawn_id [board_info $boardname fileid]
    set spawn_id [board_info $boardname fileid]
 
    set old_timeout $timeout
    set timeout 30
    set timeout 30
 
 
    #Hit enter to make sure you get a shell prompt
    #Hit enter to make sure you get a shell prompt
    send -- "\r"
    send -- "\r"
 
 
    expect {
    expect {
 
        # A prompt indicates the current session is alive
        -re "$shell_prompt.*$" {
        -re "$shell_prompt.*$" {
            verbose "Got a prompt"
            verbose "Got a prompt"
        }
        }
        default {
        default {
 
            # No response try closing the connection and reopening.
            telnet_close $boardname
            telnet_close $boardname
            if {[telnet_open $boardname] != -1} {
            if {[telnet_open $boardname] != -1} {
                verbose "started new telnet session, spawn_id is [board_info
                verbose "started new telnet session, spawn_id is [board_info
$boardname fileid]"
$boardname fileid]"
                send -- "\r"
                send -- "\r"
                exp_continue
                exp_continue
            } else {
            } else {
 
                set timeout $old_timeout
                return [list -1 "telnet to $boardname failed for $cmd, couldn't get
                return [list -1 "telnet to $boardname failed for $cmd, couldn't get
a shell prompt"]
a shell prompt"]
            }
            }
            send -- "\r"
            # I don't think we can get here. Comment out the old code and
            exp_continue
            # trigger an error
 
            # send -- "\r"
 
            # exp_continue
 
            set timeout $old_timeout
 
            error "Problem reconnecting to telnet."
        }
        }
    }
    }
 
 
 
    # Shorter timeout for commands. Not sure why we only use the first of the
 
    # arguments.
    set timeout 10
    set timeout 10
    send "$cmd $pargs\r"
    send "$cmd $pargs\r"
 
 
    expect {
    expect {
        -re "$shell_prompt.*$" {
        -re "$shell_prompt.*$" {
Line 132... Line 140...
        timeout {
        timeout {
            if [info exists expect_out(buffer)] {
            if [info exists expect_out(buffer)] {
                set execute_output_string $expect_out(buffer)
                set execute_output_string $expect_out(buffer)
            }
            }
            telnet_close $boardname
            telnet_close $boardname
            return "fail timeout"
            set timeout $old_timeout
 
            return [list -1 "telnet to $boardname for $cmd $pargs failed (timeout)"
        }
        }
    }
    }
    #Remove unesesary strings from the output string
 
    #
    #Remove unnecessary strings from the output string
 
 
    #If the file path contains any "+" signs, it will mess things up when $cmd
    #If the file path contains any "+" signs, it will mess things up when $cmd
    #is used as a regsub pattern (2 lines down), so we replace all "+"s with "."
    #is used as a regsub pattern (2 lines down), so we replace all "+"s with "."
    regsub -all "\\+" $cmd "." cmd
    regsub -all "\\+" $cmd "." cmd
    regsub -all $cmd "$expect_out(buffer)" {} output
    regsub -all $cmd "$expect_out(buffer)" {} output
    regsub $shell_prompt $output {} output
    regsub $shell_prompt $output {} output
Line 160... Line 170...
    if {[regexp {[0123456789]+} $status] != 1} {
    if {[regexp {[0123456789]+} $status] != 1} {
        warning "status not a number, it is <$status>, setting it to 1"
        warning "status not a number, it is <$status>, setting it to 1"
        set status 1
        set status 1
    }
    }
 
 
 
    set timeout $old_timeout
    if {$status == 0} {
    if {$status == 0} {
        return [list "0" "$output"]
        return [list "0" "$output"]
    } else {
    } else {
        return [list "1" "$output"]
        return [list "1" "$output"]
    }
    }
}
}
 
 
 
# This is a list of toolchains that are supported on this board.
 
set_board_info target_install {or32-linux}
 
 
 
# No multilib options needed by default.
 
process_multilib_options ""
 
 
 
# Load the generic configuration for this board. This will define a basic set
 
# of routines needed by the tool to communicate with the board.
 
load_generic_config "unix"
 
 
 
# Set up remote target info
 
set_board_info hostname "192.168.0.3"
 
set_board_info username root
 
 
 
# Use the installed compilers to ensure we get search paths that will find
 
# uClibc.
 
send_user "set_board_info compiler /opt/or32-new/bin/or32-linux-gcc\n"
 
global GCC_UNDER_TEST
 
set GCC_UNDER_TEST "/opt/or32-new/bin/or32-linux-gcc"
 
global GXX_UNDER_TEST
 
set GXX_UNDER_TEST "/opt/or32-new/bin/or32-linux-g++"
 
set_board_info compiler /opt/or32-new/bin/or32-linux-gcc
 
set_board_info c++compiler /opt/or32-new/bin/or32-linux-g++
 
set target_alias "or32-linux"
 
 
 
set_board_info connect telnet
 
set_board_info shell_prompt    "~ # "
 
set_board_info telnet_username "root"
 
set_board_info telnet_password ""
 
 
 
set_board_info file_transfer ftp
 
set_board_info ftp_username  root
 
set_board_info ftp_password  ""
 
 
# Options for the simulator
# Options for the simulator
# set cfg_file [lookfor_file ${srcdir} libgloss/or32/sim.cfg]
# set cfg_file [lookfor_file ${srcdir} libgloss/or32/sim.cfg]
# set_board_info sim,options "-a \"-f ${cfg_file}\""
# set_board_info sim,options "-a \"-f ${cfg_file}\""
 
 
# We only support uClibc on this target.  We assume that all multilib options
# We only support uClibc on this target.  We assume that all multilib options
# have been specified before we get here.
# have been specified before we get here.
# set_board_info compiler  "[find_gcc]"
# set_board_info compiler  "[find_gcc]"
 
 
 
# We need to define the right flags if pthreads is to work.
 
set_board_info cflags    "-D_XOPEN_SOURCE=600"
 
set_board_info cxxflags  "-D_XOPEN_SOURCE=600"
 
 
# No linker script needed.
# No linker script needed.
set_board_info ldscript ""
set_board_info ldscript ""
 
 
# This simulator isn't slow.
# This simulator isn't slow.
set_board_info slow_simulator 0
set_board_info slow_simulator 0

powered by: WebSVN 2.1.0

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