This is an old revision of the document!
U-Boot
Okay, we can attempt a TFTP download if and only if $serverip is alive on WAN. Here is example, executed at serial console:
ADM8668 # set if_tftp 'ping $(serverip)' ADM8668 # set do_tftp 'run tftp_boot' ADM8668 # set bootcmd 'run if_tftp do_tftp; run flash_flash' ADM8668 # save Saving Environment to Flash... Un-Protected 1 sectors Erasing Flash... done Erased 1 sectors Writing to Flash... done Protected 1 sectors
Then upon a normal boot:
Hit any key to stop autoboot: 0 TX error status2 = 0x04000008 Using adm8668_net device ping failed; host 10.42.43.1 is not alive ## Booting image at b0040000 ...
If I bring up my TFTP server (I set mine to 10.42.43.1 as you see, since my cable company allows internal IPs to be visible locally, WTF!)
Hit any key to stop autoboot: 0 TX error status2 = 0x04000008 Using adm8668_net device host 10.42.43.1 is alive TX error status2 = 0x04000008 Using adm8668_net device TFTP from server 10.42.43.1; our IP address is 10.42.43.10 Filename 'vmlinuz-8668'. Load address: 0x600000 Loading: T T ######################etc...
Now this will only execute an image from RAM. More helpful would be to replace do_tftp with command such as 'run update_kernel' to actually flash it.
But there is a big problem. Say I kept default IP, which I think was 192.168.0.1, and there is a device on the WAN port that answers to this. You will receive the following:
TX error status2 = 0x04000008 Using adm8668_net device host 192.168.0.1 is alive TX error status2 = 0x04000008 Using adm8668_net device TFTP from server 192.168.0.1; our IP address is 192.168.0.2 Filename 'vmlinuz-8668'. Load address: 0x600000 Loading: T T T T T T T T T T Retry count exceeded; starting again TX error status2 = 0x04000008 Using adm8668_net device TFTP from server 192.168.0.1; our IP address is 192.168.0.2 Filename 'vmlinuz-8668'. Load address: 0x600000 Loading: T T T T T T T T T T Retry count exceeded; starting again
Indefinitely So this is a dumb idea. But looking at U-boot sources, we can set netretry to either no or once let's try that:
ADM8668 # set netretry no ADM8668 # run bootcmd TX error status2 = 0x04000008 Using adm8668_net device host 10.42.43.1 is alive TX error status2 = 0x04000008 Using adm8668_net device TFTP from server 10.42.43.1; our IP address is 10.42.43.10 Filename 'vmlinuz-8668'. Load address: 0x600000 Loading: T T T T T T T T T T Retry count exceeded; starting again ## Booting image at 80600000 ... Bad Header Checksum #####Boot failed! ##### ##### Trying to boot from b0600000 ... ## Booting image at b0600000 ... Bad Magic Number ## Booting image at b0040000 ...
Well, seems like it'll get out of the tftp loop, but it still tried to boot from 0x600000. This is because that command wasn't part of a magic 'run' command which only continues upon success. This wouldn't be good if I used update_kernel because it would go ahead and erase your flash. Also, we still have to wait the extremely long timeouts before it boots from flash! But some more craftiness with variables, we can just attempt TFTP to RAM, if success, erase flash and do a memory copy from RAM to flash…hmm?
ADM8668 # set netretry no ADM8668 # set if_pingable 'ping $(serverip)' ADM8668 # set if_tftp_success 'tftpboot 600000 $(bootfile)' ADM8668 # set do_upgrade 'erase $(kernel_addr) +2fffff; cp 600000 $(kernel_addr) 2fffff' ADM8668 # set bootcmd 'run if_pingable if_tftp_success do_upgrade; bootm $(kernel_addr)' ADM8668 # saveenv
Seems the memory copy command cp deals correctly with flash. yay! one thing goes right. ;)
But we still have these problems:
- If host is alive, but doesn't serve TFTP images, takes about a minute to timeout and boot from flash.
- If host is alive, and serves TFTP image, but first try has 10 timeouts (happens a lot for me), then it doesn't retry.