所以我有这个 DVR,它被锁定了,所以我需要使用 U-boot 中的 md 命令来转储其内存,但是 u-Boot 每大约 15 秒重新启动一次,所以我需要分块转储内存,这是我的 shell 脚本
#!/usr/bin/expect
# Replace with the actual serial port of your device (e.g., /dev/ttyACM0)
set serial_port "/dev/ttyACM0"
# Replace with the starting memory address
set start_address 0xe1000000
# Replace with the size of each chunk
set chunk_size 0x3E00
# Replace with the target address to stop at
set stop_address 0xE100BA00
# Open a connection to the serial port
spawn cu -l $serial_port -s 115200
# Expect the message to stop autoboot
expect "Hit any key to stop autoboot:"
send "\r"
#after 2000
# Set the initial address
set current_address $start_address
# Dump memory in chunks
while {$current_address < $stop_address} {
# Send the md command to the bootloader for the current chunk
send "md $current_address $chunk_size\r"
# Wait for the bootloader's response
expect "Hit any key to stop autoboot:"
send "\r"
# Send any key to continue (press Enter)
send "\r"
# Update the current address for the next chunk
set current_address [expr {$current_address + $chunk_size}]
}
# Close the connection
send "\x03" ;# Send Ctrl+C to stop autoboot if needed
send "exit\r"
expect eof
因此,在第一次通电时,它确实会从内存中打印第一个块的内容,但在重新启动后,设备启动后会发送“\r”,预计“按任意键停止自动启动:”不起作用,我不知道为什么,任何建议 tnx ?