[OpenWRT] How to compile OpenWRT with u-boot writable

By default, openwrt won’t allow you to write to u-boot partition for safety reason – it might be dangerous if you write non-compatible data to your u-boot. It will definitely brick your router. However if you want to use “advanced” u-boot with web¬†failsafe and NetConsole as described here, and you don’t have a programmer/don’t want to open the case solder down the flash and solder it back. You may compile your own OpenWRT with u-boot writable. But, do remember, it’s always dangerous to write to u-boot partition if you don’t do it properly.

This article is assuming you have working OpenWRT compiling environment. If you don’t have one, build it following this article.

OK, the only file you need to change is target/linux/ar71xx/files/drivers/mtd/tplinkpart.c (for trunk).

Look for the following:

parts[0].name = "u-boot";
parts[0].offset = 0;
parts[0].size = offset;
parts[0].mask_flags = MTD_WRITEABLE;

parts[1].name = "kernel";
parts[1].offset = offset;
parts[1].size = rootfs_offset - offset;

parts[2].name = "rootfs";
parts[2].offset = rootfs_offset;
parts[2].size = art_offset - rootfs_offset;

parts[3].name = "art";
parts[3].offset = art_offset;
parts[3].size = TPLINK_ART_LEN;
parts[3].mask_flags = MTD_WRITEABLE;

parts[4].name = "firmware";
parts[4].offset = offset;
parts[4].size = art_offset - offset;

comment out or delete this line

parts[0].mask_flags = MTD_WRITEABLE;

Re-compile, and you are all set.

Again, it’s always dangerous writing u-boot partition.

 

Update On 10/12/2014

If you have ever built any firmware using the same source. You need to run

make clean

before build the new one with u-boot write enable.

« »

Leave a Reply

Your email address will not be published. Required fields are marked *