How to flash firmware more thoroughly?

I like to erase & clear as much as I can when I'm flashing my machine.

Currently I know of 2 ways to to flash OpenWRT:

1- Sysupgrade (Probably what Web GUI uses)
sysupgrade -n /tmp/sysupgrade.bin

2- MTD Method

mtd erase rootfs_data
mtd -e firmware write /tmp/sysupgrade.bin firmware

I have around 9 mtd blocks, firmware is just one of them. When we update are we writing on all of these blocks?

MTD tool can only erase rootfs_data and reflash the firmware block.

Are those blocks other than firmware never updated even with 'sysupgrade'?
What's the difference between those 2 methods?
Can we do it even more thoroughly?



Leave the rest of the partitions well alone, unless you want a brick! Some of them contain the bootloader, some of them contain stuff required by the bootloader, some of them contain stuff required to get WiFi working and so on -- if you were to e.g. erase the one with the WiFi-stuff, you'd break your WiFi!

Besides which, the whole concept of writing "more thoroughly" to the flash is ill-conceived. Flash can be written to only a limited number of times and you want to write as little as possible, not as much as possible. Neither SPI NOR or NAND have any sort of wear-levelling, they're not like SSDs.

Please don't dictate about how to use my devices. I know about the wear problem and it's not a concern for me (I can flash mine a thousand times before it wears out).

And breaking WiFi-or such secondary functionalities are nothing to be afraid of. You simply backup all your mtd blocks and restore them as needed.

As for bricking the device, I would like to learn specifically which mtd blocks are higher risk and how to replace other blocks than them.

Lastly, thank you for pointing that out which is understandable but I think every tweaker is aware of the risk of bricking, sometimes learning cost you but we still keep on learning.

Btw, here's the mtd blocks on my machine:

I'm also interested in learning which of those blocks have closed source-proprietary software.

Edit: So which of these blocks do we have in a sysupgrade image?

Also, is there a block which is only responsible for WiFi? As I'm not using WiFi, I'd like to experiment on surgically removing it.

How about none.

Understand that some of these MTD blocks are actually subpartitions of another MTD block. kernel and rootfs are the 2 subpartitions of firmware. rootfs_data is the area after the firmware partition that holds changes made to the file system when you modify files using SSH. The config files go here as well.

u-boot is the bootloader program. You modify this and you have a brick as, without it working, you can't start the firmware running. This is never touched unless you are replacing it with a known working bootloader program.

u-boot-env has the data needed by u-boot in order to run. It is only data and not any programs. Playing with this could brick your router as the bootloader may not work if the required data here is incorrect.

factory usually holds data like the router MAC address and the Wifi calibration data. These aren't programs but data used to set the MAC or to calibrate the Wifi chip so it works.

The other MTD blocks may be subpartitions of factory or they could be separate blocks. You can usually figure this out from /proc/mtd.

No. That is done in the firmware. There may be a block with calibration data in it but that is used by the firmware to get working Wifi.

You aren't going to find hidden code in the MTD partitions as that isn't what they are for. Other than u-boot and firmware they are all data areas.

To see what is in these blocks save them and then do a binwalk on them or use a Hex Editor to see what the data is.


This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.