在调试过程中,调试人员需要对flash进行烧写文件系统和内核。采用redboot或U-boot作为引导程序,需要调试人员在串口终端里输入一系列下载、烧写、配置命令。这里介绍一种简单的方法,巧妙利用SecrueCRT的执行脚本功能,简化烧写过程。
脚本采用的是VBSCRIPT语言,在网上能搜出大量的资料,这里不一一叙述。这里只是将我使用的脚本贴出来,思路是相通的,大家只要依葫芦画瓢即可。我采用的是ReadBoot引导程序。
# $language = "VBScript" # $interface = "1.0" Sub Main Dim rc '下载至RAM crt.screen.send " load -rv -h 192.168.1.155 -p 69 -b 0x20410000 rootfs.arm.ext2.gz" & Chr(13) crt.screen.WaitForString "RedBoot> ",40 '下载至flash crt.screen.send " fis create -b 0x20410000 -l 0x680000 -f 0x10020000 -e 0x20410000 rootfs" & Chr(13) rc=crt.screen.WaitForString("?",10) If (showError = 1 And rc <> 1) Then ' error occured pmt = "Error occured when exec:" & vbCrLf & cmd & vbCrLf & "Continue?" sel = msgbox(pmt, vbOKCancel, "Information" ) If sel = vbCancel Then Exit Sub End If ' rc = vbCancel End If ' ShowError = 1 And rc <> 1 crt.screen.send "y" & vbCrLf crt.screen.WaitForString "RedBoot> ",60 crt.screen.send "fco" & vbCrLf crt.screen.send vbCrLf crt.screen.WaitForString ">> ",10 crt.screen.send "fis load -b 0x20410000 rootfs" & vbCrLf crt.screen.send "fis load -b 0x21000000 zimage" & vbCrLf crt.screen.send "exec" & vbCrLf crt.screen.WaitForString ">>",5 crt.screen.send vbCrLf crt.screen.WaitForString ":",10 crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.send vbCrLf crt.screen.WaitForString "?",5 crt.screen.send "y" & vbCrLf End Sub
不过,值得注意的是,在实际使用secureCRT过程中,经常发现复制粘贴时会漏掉头一个字符,导致命令出错。所以,这里有个关键点是将要输入的命令前多输入几个空格,避免漏掉头一个字符。
这样,是不是简单多了!