Zyxel NSA310 U-Boot variables to boot Linux from a USB stick

Here’s my USB stick layout:

Partition 1 is /boot and must be ext2
Partition 2 is swap
Partition 3 is root

bootcmd=usb start; ext2load usb 0:1 0x800000 /uImage-3.5.7; bootm 0x800000; reset

This was for the rear USB port. You will need to change usb 0:1 to something else for the front port. Not sure if it’s 1:1 or 0:2.

The reset at the end is because sometimes the USB detection fails after a long timeout, and this ensures your system will keep rebooting until it successfully boots.

bootargs=root=/dev/sda3 console=ttyS0,115200 rootdelay=9 panic=4

Adjust /dev/sda3 to whatever your root partition is.

I found that rootdelay at 9 seconds is a safe time window to allow the root partition to mount. If you have a particularly slow USB stick try increasing it. No rootdelay is a bad idea. If 9 seconds isn’t enough rootdelay, it will reboot after another 4 seconds, set by the panic parameter.

To set these from a serial console, the commands are:
setenv bootcmd 'usb start; ext2load usb 0:1 0x800000 /uImage-3.5.7; bootm 0x800000; reset'
setenv bootargs 'root=/dev/sda3 console=ttyS0,115200 rootdelay=9 panic=4'

Then try booting:
boot

If booting works, great! You can type the setenv commands again and then run this command to save them to EEPROM:
saveenv

If for any reason your system environment variables get all screwed up, you can go back to defaults with:
resetenv
reset