How to Install OpenWrt on Linksys WHW01 [GUIDE]

I was unable to flash OpenWrt using the installation instructions.

run flashimg

Returns the error:

NAND write: device 1 offset 0x0, size 0xa80100
Attempt to write to non page aligned data
NAND write to offset 0 failed -22
 0 bytes written: ERROR

This is because the file size of the OpenWrt image (and $filesize in u-boot env) is not aligned to the page size:

$ wc -c openwrt-ipq40xx-generic-linksys_whw01-squashfs-factory.bin
11010304 openwrt-ipq40xx-generic-linksys_whw01-squashfs-factory.bin

The NAND page size is 2KiB:

NAND:  spi_nand: spi_nand_flash_probe SF NAND ID 0:ef:ab:21
SF: Detected W25M02GV with page size 2 KiB, total 256 MiB

To be page aligned, you need to write 0xa80800 bytes (5377 pages) instead of 0xa80100 (5376.125). The flash area is actually 0x5000000 much larger than the image you write, so there is no adverse effect.

The actual write command(s) should therefore be:

nand write $loadaddr $prikern 0xa80800
nand write $loadaddr $altkern 0xa80800

Once you correct the $filesize to write, flashing proceeds as expected.