Custom Firmware Build Warning

When building custom firmware, DO NOT use the WD merge tool (included with source code) to create a firmware bin file. Doing so will result in a bricked NAS, caused by a corrupted uRamdisk file on the /dev/mmcblk0p3 (wdnas_initramfs) NAND flash partition.

Initramfs Boot (Good):

[    1.475849] Trying to unpack rootfs image as initramfs...
[    1.594126] Freeing initrd memory: 3772K (ffff880037892000 - ffff880037c41000)

Initramfs Boot (Bad):

[    1.470692] Trying to unpack rootfs image as initramfs...
[    1.587849] rootfs image is not initramfs (junk in compressed archive); looks like an initrd
[    1.602261] Freeing initrd memory: 3772K (ffff880037892000 - ffff880037c41000)

The Linux kernel can’t boot properly without a valid initial ram filesystem, which ultimately leads to Kernel panic, resulting in a bricked NAS.

[ 4.797935] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.

The hex pattern of the corrupted files is always the same, where the firmware bin file has 6 bytes (ff ff ff) at the end, and the uRamdisk (initramfs) file has 4 bytes (ff ff) at the end. Also, the uRamdisk file is not corrupted prior to being packaged by the WD merge tool, it only occurs after being uploaded to the NAS. Extensive analysis and testing traced the problem back to the WD merge tool, which was verified by replacing the corrupted /dev/mmcblk0p3/uRamdisk file with a known good one.

Firmware (Bad):

e3 f1 78 3c 1e 8f c7 e3 f1 78 3c 1e 8f e7 bf e5 1f e8 89 3b c0 00 e8 08 00 ff ff ff

uRamdisk (Bad):

7b 7b bb b5 a5 d5 d6 5e 52 52 a2 fa ec b7 a0 bf ff 01 7c 65 e4 f6 00 aa 7a 00 ff ff

Until a better installation method can be devised, the individual firmware files (uImage, uRamdisk, image.cfs, GRUB, etc) must be manually copied to the correct NAND flash partitions.

Fortunately, if anyone learns about this problem the hard way, recovery is possible.