Linksys EA3500 / EA4500: Tricks, How-to's, Issues

Here is a step-by-step instruction for Linksys EA4500, making it a triple boot device:

  1. Linksys stock firmware
  2. Stable OpenWRT release
  3. Latest and greatest snapshot, and more snapshots to your heart's desire

Prepare a bootable USB drive on your favorite Linux machine. I did it in Ubuntu 18.04:

Downloads$ wget https://downloads.openwrt.org/snapshots/targets/kirkwood/generic/openwrt-kirkwood-linksys_viper-squashfs-sysupgrade.bin
Downloads$ tar -xf openwrt-kirkwood-linksys_viper-squashfs-sysupgrade.bin && cd sysupgrade-linksys-viper
sysupgrade-linksys-viper$ sudo mke2fs -t ext2 -L ea4500 /dev/sdb1
sysupgrade-linksys-viper$ udisksctl mount --block-device /dev/disk/by-label/ea4500
sysupgrade-linksys-viper$ sudo sh -c "mkdir /media/$USER/ea4500/boot; cp -p kernel /media/$USER/ea4500/boot/; chown root.root /media/$USER/ea4500/boot/kernel"
sysupgrade-linksys-viper$ sudo unsquashfs -f -d /media/$USER/ea4500/ root
sysupgrade-linksys-viper$ udisksctl unmount --block-device /dev/disk/by-label/ea4500

Enable USB Booting
Once OpenWRT is flashed via Linksys Web UI, carefully enable the U-Boot to boot from the USB drive if present. For EA4500, make sure a few U-Boot variables are set as follows:

root@OpenWrt:~# fw_printenv loadaddr
loadaddr=0x02000000
root@OpenWrt:~# fw_printenv console
console=console=ttyS0,115200
root@OpenWrt:~# fw_printenv mtdparts
mtdparts=mtdparts=nand_mtd:512k(uboot)ro,128k@512k(u_env),128k@640k(s_env),26m@2m(kernel),26m@2m(rootfs)fs,26m@28m(alt_kernel),26m@28m(alt_rootfs)fs,74m@54m(syscfg)
root@OpenWrt:~# fw_printenv usb_fs_bootargs_root
usb_fs_bootargs_root=root=/dev/sda1 rw rootfstype=ext2
root@OpenWrt:~# fw_printenv nandboot
nandboot=nand read.e 0x2000000 0x200000 0x300000; setenv bootargs $(console) $(mtdparts) $(fs_bootargs_root) serial_number=$(sn) uuid=$(uuid) hw_version=$(hw) device_mac=$(mac) factory_date=$(date) wps_pin=$(wps); bootm 0x2000000;
root@OpenWrt:~# fw_printenv altnandboot
altnandboot=nand read.e 0x2000000 0x1c00000 0x300000; setenv bootargs $(console) $(mtdparts) $(alt_fs_bootargs_root) serial_number=$(sn) uuid=$(uuid) hw_version=$(hw) device_mac=$(mac) factory_date=$(date) wps_pin=$(wps); bootm 0x2000000;

Then, add or change the following U-Boot variables:

root@OpenWrt:~# cat << EOF > /tmp/env.vars
nandboot         run openwrt_usb_boot; $(fw_printenv -n nandboot)
altnandboot      run openwrt_usb_boot; $(fw_printenv -n altnandboot)
openwrt_usb_boot usb start; mw \${loadaddr} 0 8; ext2load usb 0:1 \${loadaddr} /boot/kernel; setenv bootargs \${console} \${mtdparts} \${usb_fs_bootargs_root} rootdelay=10; bootm \${loadaddr}; usb stop
bootcmd          run nandboot
EOF
root@OpenWrt:~# fw_setenv -s /tmp/env.vars

Switch Boot Partitions

  • Plugging in a bootable USB boots from the USB drive. Otherwise...
  • fw_setenv boot_part 1 runs nandboot, boots the 1st partition
  • fw_setenv boot_part 2 runs altnandboot, boots the 2nd

Notes

  1. The bootcmd is actually a non-factor for EA4500 because the auto recovery scheme sets it to run nandboot and altnandboot on the fly, depending a few variables . One of them is a count of failed boots and this
root@OpenWrt:~# fw_printenv boot_part
boot_part=1
  1. If a USB hub is used, the bootable drive has to be plugged in as the first device.