WGR614L Firmware Image Creation

Some of you have already noticed that WGR614L firmware uses a .chk extension. Let us go through the steps that is needed to create a firmware image in .chk format.

Most of the broadcom hardware uses a TRX style fimware. Netgear's WGR614L linux based open source router's .chk is also based on the same TRX format - but does add the following interesting improvements

First, the kernel is compressed using LZMA which achieves a better compression than the usual gzip or bzip2 compression. This improvement does need an addition to the CFE bootloader to support uncompression of LZMA encoded kernel

Second, this formats adds a header to trx format, that has the checksum, length, and a compatible board identifier. These checksum and length information makes the job ensuring image integrity much easier and since these checksums are stored in the flash and also checked at each system boot, boot-loader can also identify if the flashed image gets corrupted.

So to pack a image in the .chk format you will need the following files at hand Thee files are generated when you compile the downloaded linux opensource codes for WGR614L

  1. Download the source code the Netgear WGR614L
  2. Linux Kernel - vmlunx -usually compiled at the top directory of the linux kernel source.
  3. compatible.txt containing the boardid of the netgear boards this fimeware is targeted for.
  4. Root File System image - target.squashfs - usually a LZMA Squashfs file system.
  5. Make sure you have added the bcm5354/tools directory into the PATH

$ export PATH=$PATH:$(SRCDIR)/bcm5354/tools

And you will need to follow these steps

1. Trim vmlinux by removing unneccessary sections in the object code

$ mipsel-linux-strip vmlinux

2. Convert to Binary format from the ELF format

$ mipsel-linux-objcopy -O binary -g vmlinux vmlinux.bin

3. Compress using lzma

$ ../../tools/lzma e vmlinux.bin vmlinux.lzma

4. Create the trx image

$ trx -o linux.trx vmlinux.lzma target.squashfs

5. Append the ".chk" header.

$ touch emptyfile; packet -k linux.trx -f emptyfile -b compatible.txt -ok kernel_image \

-oall kernel_rootfs_image -or rootfs_image -i emptyfile; rm -f emtyfile

And this will generate a new file "kernel_rootfs_image.chk" which can be uploaded to WGR614L using its Web UI or if you got the serial console you can also use the tftpd upgrade from the CFE firmware.

The format of a chk header is given below.

Type/Variable

Size (bytes)

Unsigned long magic

4

Unsigned header_len;

4

unsigned char reserved[8];

8

unsigned long kernel_chksum;

4

unsigned long rootfs_chksum;

4

unsigned long kernel_len;

4

unsigned long rootfs_len;

4

unsigned long image_chksum;

4

unsigned long header_chksum;

4

BOARD ID < 64 digits

variable length (max 64 bytes)

twindragon6
twindragon6's picture
What flavor of Linux was this

What flavor of Linux was this compiled in? some of the - switches don't work in other versions.

Stefan
Stefan's picture
I have followed the procedure

I have followed the procedure by using WGR614v8-V1.1.24_14.0.43WW_src.tar.bz2.zip from Netgear website and hnd-tools-3.2.3.tgz

I take the target.squashfs, compatible.txt, vmlinux.lzma from the compiled source. Then I input some .bin to the trx and packet programs as suggested and it creates a kernel_rootfs_image.chk. After that I upload this .chk from the web interface of WGR614v8 to the router. It says the firmware is not a World-Wide one and also says wrong version, i.e. V0.1.0_255.1.0. After I upload it the router just reboots and the factory firmware is still there as if I uploaded nothing.

Serial console also shows nothing interesting during upload.

Writing 3526656 bytes to /dev/mtd/1.
......................................................done.
Restarting system.

What am I missing or doing wrong?