文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>u-boot环境的擦除,默认设置,批写..

u-boot环境的擦除,默认设置,批写..

时间:2010-10-08  来源:jiangjqian

1. 环境的擦除:
nor erase 0x160000 0x20000
CONFIG_ENV_OFFSET => 0x160000
CONFIG_ENV_SIZE => 0x20000
2. 默认设置

u-boot-2009.08/include/configs/vpe_apollo.h 里面设置
3. 批写入可以利用TCL和expect来完成,见后面
参考:
-------------------------------------------------------------------------------------------------------------
tcl: http://www.cotse.com/dlf/man/tcl/index.htm
expect: http://www.cotse.com/dlf/man/expect/index.html
advance expect guide: http://tldp.org/LDP/LGNET/issue48/fisher.html
-------------------------------------------------------------------------------------------------------------
调试中遇到的问题:
-------------------------------------------------------------------------------------------------------------
qianjiang@qianjiang-laptop:~/tmp$ sudo ./test_expect -s /dev/ttyS0
DEBUG: serialport = /dev/ttyS0 ; imagefile = env.txt
>>> Executing u-boot commands from env.txt
bad option "-mode": should be one of -blocking, -buffering, -buffersize, -encoding, -eofchar, or -translation
    while executing
"fconfigure $serial -blocking 0 -mode 115200,n,8,1 -translation {auto cr} -buffering none"
    (file "./test_expect" line 85)
-------------------------------------------------------------------------------------------------------------
>> 可能和我电脑的/dev/ttyS0不能配置bitrate等有关???

4. nfs启动设置如下:
# for eth boot
setenv ethport 'eth0'

setenv addrootpath 'setenv rootpath /home/qianjiang/nfsroot/rootfs'
setenv addnfs 'setenv bootargs ${bootargs} root=/dev/nfs rw nfsroot=${serverip}:${rootpath},tcp'
setenv addapppath 'setenv apppath /home/qianjiang/nfsroot/appfs'
setenv addappfs 'setenv bootargs ${bootargs} APPFS=${serverip}:${apppath}'

# common envs
setenv setargs 'setenv bootargs noinitrd ip=${ipaddr}:${serverip}::::${ethport} console=ttyS1,115200n8 ${mtdparts}'

# bootchoice
# 3: tftp kernel and nfs root
setenv bootchoice 3

# define boot
setenv bootcmd 'echo "Boot mode is :"; run bootmode${bootchoice}'

# define bootmode
setenv bootmode3 'run setargs; run addrootpath; run addnfs; run addapppath; run addappfs; tftpboot; go 0x8000'


setenv uboot_cmdline 1
saveenv


============================================== 自动写入环境的脚本 ==================================================
#!/usr/bin/expect
###############################################################################
#
# Filename : set_uboot_env
# Purpose  : Set the u-boot environment in a board, by uploading a file
#            of u-boot commands. It sends them slowly & reliably, unlike
#            minicom's send function
#
# Usage:     set_uboot_env [-y -s <serialport>] file
#
# Rev   Date    Author          Comments
# ----- ------- --------------- -----------------------------------------------
# 001   101010  jiang.j.qian     Original
#
###############################################################################
set send_slow {2 0.01}
set timeout -1
set prompt    "Apollo #"
set serialport "/dev/ttyS0"
set argv0       [file tail $argv0]

set imagefile "env.txt"

# Process the input arguments if they exist
while {[llength $argv] > 0 } {
    set flag [lindex $argv 0]
    switch -glob -- $flag {
        # Options that are followed by an argument
        -s {
            set opt($flag) [lindex $argv 1]
            set argv [lrange $argv 2 end]
        }
        # Options that are either on or off
        -[y] {
            set opt($flag) 1
            set argv [lrange $argv 1 end]
        }
        -h {
            send_error "Usage: $argv0 \[-y -s <serialport>\] \[file\]\nDefault serialport port is /dev/ttyS0\n"
            exit 0
        }
        -* {
            send_error "Unrecognised option $flag (see -h for help)\n"
            exit 1
        }
        default {
            set imagefile $flag
            set argv [lrange $argv 1 end]
        }
    }
}

# Overwrite default serial port (/dev/ttyS0) if -s option specified
if {[info exists opt(-s)]} {
    set serialport $opt(-s)
}

send_user "DEBUG: serialport = $serialport ; imagefile = $imagefile\n"

# Check if the image file exists
if {![file exists $imagefile]} {
    send_user "Image file  $imagefile does not exist\n"
    exit 1
}

# Check if the serialport exists
if {![file exists $serialport]} {
    send_user "serialport: $serialport not exist\n"
    exit 1
}

send_user ">>> Executing u-boot commands from $imagefile\n"

# Check the serial port isn't already in use
if {[file exists "/var/lock/LCK..[file tail $serialport]"]} {
    send_user "Serial port $serialport is locked (have you left minicom running?)\n"
    exit 1
}

# Setup the serial
if {[catch {set serial [open $serialport {RDWR NOCTTY}]} err]} {
    send_error "Couldn't open serial port $serialport (add yourself to the uucp & lock groups!)\n"
    exit 1
}
fconfigure $serial -blocking 0 -mode 115200,n,8,1 -translation {auto cr} -buffering none
spawn -noecho -open $serial

# Get to u-boot prompt
send_user "\n>>> Please press reset button to start u-boot\n"
expect    "U-Boot"
expect {

    -regexp $prompt {
    # We've gone straight to the prompt - job done!
    }

    "Hit any key to stop autoboot" {
    # We need to send a keypress to get to the prompt
    send -s   "\r"
    expect -regexp $prompt
    }
}
send_user "\n"

# Do a printenv (so in case of disaster, user can cut&paste old environment)
send_user "\n>>> Old environment (in case of disaster) is...\n"
send -s "printenv\r"
expect -regexp $prompt
send_user "\n"

# Check user is happy
if {![info exists opt(-y)]} {
       send_user "\n>>> Are you REALLY REALLY sure you want to reset the environment? (y/n) "
       expect_user {
    y    {}
    n    {exit}
    }
}

# Send each line in the file(s) slowly, waiting for the prompt
foreach filename $imagefile {
    set chan [open $filename r]
    while {[gets $chan line] >= 0} {
            # Skip comment & blank lines
            if {[regexp "^\[^#\].*\[^ \]+.*\$" $line]} {
                send -s "$line\r"
                expect -regexp $prompt
            }
    }
    close $chan
}
 

相关阅读 更多 +
排行榜 更多 +
坦克冒险大师安卓版

坦克冒险大师安卓版

策略塔防 下载
自动防御

自动防御

策略塔防 下载
枪战大乱斗2

枪战大乱斗2

飞行射击 下载