ATF(arm 可信固件,BL1,BL2)命令行循环支持 ymodem 协议。在 windows 下,我使用的是 TeraTerm,可以使用它的菜单手动发送文件到设备,使用 ymodem 协议,在输入命令ymodem <address>
并看到C
字符后:
NOTICE: Booting Trusted Firmware
NOTICE: BL1: v1.4(release):58e7395
NOTICE: BL1: Built : 17:39:25, Jan 2 2018
# ymodem 0x45103000
NOTICE: ## Ready for binary (ymodem) download to 0x451030000 at 115200 bps...
C
Tera Term 还支持宏来自动化该过程,效果很好。现在我想在Linux下使用screen
++expect
来做sz
同样的事情......但到目前为止我还没有成功。
我目前正在使用以下代码进行测试:
85 spawn screen /dev/ttyUSB0 115200
86 set screen $spawn_id
93 send "ymodem 0x45103000\r"
94 set timeout 3
95 expect {
96 timeout {
97 puts "timeout..."
98 exit 1
99 }
100 "115200 bps...\r\nC"
101 }
102 #stty -echo raw
103 spawn sz --ymodem $bl2_burn_path
104 interact -u $screen
105 expect "Bytes" # can expect see this?
106 stty echo -raw
107
108 send "\r\r\r"
109 send "exit\r"
似乎sz
重复发送文件,但远程端没有反馈:
expect: does "ymodem 0x45103000\r\n\u001b)0\u001b[?1049h\u001b[4l\u001b[?1h\u001b=\u001b[0m\u001b(B\u001b[1;24r\u001b[H\u001b[J\u001b[H\u001b[Jymodem 0x45103000\r\nNOTICE: ## Ready for binary (ymodem) download to 0x45103000 at 115200 bps...\r\nC" (spawn_id exp7) match glob pattern "115200 bps...\r\nC"? yes
expect: set expect_out(0,string) "115200 bps...\r\nC"
expect: set expect_out(spawn_id) "exp7"
expect: set expect_out(buffer) "ymodem 0x45103000\r\n\u001b)0\u001b[?1049h\u001b[4l\u001b[?1h\u001b=\u001b[0m\u001b(B\u001b[1;24r\u001b[H\u001b[J\u001b[H\u001b[Jymodem 0x45103000\r\nNOTICE: ## Ready for binary (ymodem) download to 0x45103000 at 115200 bps...\r\nC"
spawn sz --ymodem /home/bruin/work/f5/bsp/bl2-burn.bin
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {31117}
spawn id exp7 sent <C>
spawn id exp8 sent <\u0001\u0000\u00ffbl2-burn.bin\u000045352 13335245531 100700 0 1 45352\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001c\u0013\u00a4>
spawn id exp8 sent <\u0001\u0000\u00ffbl2-burn.bin\u000045352 13335245531 100700 0 1 45352\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0001c\u0013\u00a4>
上面的脚本缺少什么?
我还有一个关于如何确定文件传输是否完成的问题。通常(在我观察到的 Windows 上),一旦文件传输完成,ATF 将打印传输数据的大小,例如45123 Bytes
. 现在怎么expect
看这个消息?我的理解是,这两个衍生进程(screen
和sz
)直接对话,绕过expect
,不是吗?