Generic Flashing over the Serial Port

Technical references

Actual procedure

  • first, launch a tftp server running on address 192.168.1.234, serving the openwrt firmware file, renamed to firm.bin

mkdir -p /tmp/tftp/
cp openwrt-...-factory.bin /tmp/tftp/firm.bin

sudo ip addr add 192.168.1.234/24 dev eth0
sudo dnsmasq -d --port=0 --enable-tftp --tftp-root=/tmp/tftp/

  • then, on another console, run a serial terminal program (e.g. screen or minicom) set to 115200 8N1, no flow control

screen /dev/ttyUSB0 115200

  • finally, instruct the bootloader to transfer the firm.bin from the tftp server on your computer and save it to RAM memory (0x81000000); then erase 0x7c0000 bytes (7.75 MiB) from the flash (starting at 0xbf020000); finally copy the image stored in RAM to flash

DO NOT USE THESE VALUES. FIND OUT THE RIGHT ONES! NO, NOT KIDDING.

  • 0x7c0000: size of the firmware (be aware that you may have a different size thus bricking your router)

Commands:

setenv serverip 192.168.1.234
tftpboot 0x81000000 firm.bin
erase 0xbf020000 +0x7c0000
cp.b 0x81000000 0xbf020000 0x7c0000
bootm 0xbf020000

To get a rough idea of the process, check an example serial console log during the whole procedure

Kermit

You can use a client using the Kermit (protocol) to transfer the new image. It may take forever and a half (15-20min) to copy. But it's easier and more secure than running a tftpd server. These instructions assume you're using a Linux system, but they will give you all you need to do the same on a Windows box.

Requirements:

  • terminal program (e.g. minicom) set to 115200 8N1, no flow control
  • file named code.bin containing openwrt firmware.
  • Kermit client (these instructions will involve using C-Kermit under Linux)

DO NOT USE THESE VALUES. FIND OUT THE RIGHT ONES! NO, NOT KIDDING.

erase 0xbf020000 +7c0000 # 7c0000: size of the firmware (be aware that you may have a different size thus bricking your router)
loadb 0x81000000

Fire up C-Kermit and run the following commands (or configure your Kermit client to these parameters):

set line /dev/ttyUSB0 # Just make sure you got the right USB interface
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5
send code.bin # Make sure you include a proper path to the file. That's why I just kept it in /home/$user

After the 15-20min file transfer, the new firmware should be on your router and you can continue in terminal:

DO NOT USE THESE VALUES. FIND OUT THE RIGHT ONES! NO, NOT KIDDING.

cp.b 0x81000000 0xbf020000 0x7c0000
bootm 0xbf020000

Note: This serial transfer method doesn't solve the "chicken or the egg" dilemma (if your Ethernet port is not working on U-Boot) because you cannot use tftpboot to transfer code.bin to u-boot. Fortunately U-Boot supports serial transfer using modem protocol: http://acassis.wordpress.com/2009/10/23/transfering-file-to-u-boot-over-serial/

Back to top

doc/howto/generic.flashing.serial.txt · Last modified: 2013/04/27 16:40 by gui