host_util: add helper script for U-Boot flashing over serial
This script helps with flashing U-Boot image over serial line (kermit
protocol, 'loadb' command) which can be useful on devices with only
serial interface available. Script requires C-Kermit and includes some
basic checks (start it without any argument to see short usage help).
Tested on C-Kermit 9.0.302
Example run:
$ host_util/u-boot-serial-flash bin/mr3020.bin - - - - -
[INFO]: File to send: 'bin/mr3020.bin'
[INFO]: Serial device: '/dev/ttyUSB0'
[INFO]: Baudrate: '115200'
[INFO]: CLI prompt: 'u-boot> '
[INFO]: Wait string: 'Hit any key to stop booting'
[INFO]: File size: '125952'
[INFO]: Backup size: '131072' (rounded up to 64K block)
[INFO]: Erase size: '0x020000' (hex)
>>>>>> Do you want to continue (type 'y' to continue)? y
[INFO]: Power on device now...
[INFO]: Backuping data in RAM...
[INFO]: Sending command: 'cp.b 0x9f000000 0x80800000 0x020000'
[INFO]: Sending command: 'loadb 0x80800000'
[INFO]: Sending selected file to RAM at 0x80800000 (this may take a while)...
>>>>>> File sent successfully, do you want to write it to FLASH (type 'y' to continue)? y
[INFO]: Erasing FLASH, copying data from RAM to FLASH...
[INFO]: Sending command: 'erase 0x9f000000 +0x020000 && cp.b 0x80800000 0x9f000000 0x020000'
[ OK ]: Done!
>>>>>> Reset board now or switch to U-Boot CLI (type 'y' for reset)? y
[INFO]: Resetting the board...
[INFO]: Sending command: 'reset'
[ OK ]: U-Boot flashed successfully!
>>>>>> Exit now or switch to U-Boot CLI (type 'y' to exit)? y