How does a firmware upgrade work?

linuxleand

New Around Here
Hi!

I am trying to understand how a firmware upgrade process work in these AC routers and how it involves the NVRAM. Here's how I think it works:
  1. Stock firmware shipped with the router consists of a few parts:
    1. Bootloader.
    2. Linux kernel image.
    3. Device drivers.
    4. rootfs (all files in the filesystem).
    5. Router settings.
    6. Maybe more stuff?
  2. The vendor is the first one to flash the firmware to the NVRAM chip for the first time. Different things go to different partitions in the NVRAM.
  3. Router settings are stored in a specific partition from the same NVRAM chip (the only area the nvram command works with).
  4. When the router boots up, the filesystem in the NVRAM is mounted in RAM (ramdisk).
  5. A firmware upgrade process would rewrite the whole NVRAM chip, including bootloader, kernel image, and rootfs partitions.
Am I correct in my line of thinking?

Thanks a lot!
 

ColinTaylor

Part of the Furniture
No. A firmware upgrade for AC models would normally only update the partition in nvram that contains the operating system (which includes rootfs). Things are slightly different for HND models.

What router model are you talking about? What is the reason for the question?
 

linuxleand

New Around Here
Thanks for your answer. The reason for the question is purely research/curiosity. I'd to demystify this process in my mind.

I am considering buying one to run a few tests. AC86U looks nice. :)

So, is the rootfs the source for what will be mounted in /tmp by default?

Thanks
 

ColinTaylor

Part of the Furniture
I am considering buying one to run a few tests. AC86U looks nice. :)
The RT-AC86U is an HND model. I don't have that model but I believe it uses ubifs for some of it's filesystems, so that makes things a bit more complicated.

So, is the rootfs the source for what will be mounted in /tmp by default?
I guess you could say that as that is what boots the rest of the operating system. Although I'm not sure what you're alluding to regarding /tmp. It's probably not a good idea to draw too many comparisons with the router's firmware and a standard Linux OS.
 

linuxleand

New Around Here
t's probably not a good idea to draw too many comparisons with the router's firmware and a standard Linux OS
That's key. Thank you.

Do you know any literature on this topic? I still have a few questions but I don't want to annoy you or other users here.
 

ColinTaylor

Part of the Furniture
Sorry I don't know of any literature for the very low level stuff. Probably the DD-WRT and OpenWRT site are best for a general overview of that sort of thing. But it largely depends on what firmware you're going to be using and what you're trying to do. The RT-AC86U isn't supported by DD-WRT or OpenWRT (AFAIK) so you're limited to stock Asus firmware or Asuswrt-Merlin which have their own proprietary way of doing things.
 

RMerlin

Asuswrt-Merlin dev
The NAND flash is partitioned, just like a disk. The firmware image contains data for some of these partitions, so when flashing, only these select partitions (typically one for the kernel and one for the root filesystem) are being overwritten.

The bootloader itself isn't directly written to, and the nvram partition is also untouched.

For reference, here's the partition table for an RT-AC66U_B1:

Code:
[email protected]:/tmp/home/root# cat /proc/mtd 
dev:    size   erasesize  name
mtd0: 00080000 00020000 "boot"
mtd1: 00180000 00020000 "nvram"
mtd2: 03e00000 00020000 "linux"
mtd3: 03c62270 00020000 "rootfs"
mtd4: 03ec0000 00020000 "brcmnand"
mtd5: 00140000 00020000 "asus"

The trx will only overwrite the linux and rootfs partitions.

brcmnand is unused space, which Asus mounts as a JFFS2 partition.

Newer platforms may contain additional partitions within the image.
 

ColinTaylor

Part of the Furniture
That's really useful, @RMerlin. Thank you too.

What about the factory reset? Will it write to rootfs partition too?

Thanks!
A factory reset only affects (i.e. erases) the "user settings" part of nvram. It doesn't change anything else.
 

LilyRoss

New Around Here
based on the title.
A firmware update will upgrade your device with advanced operational instructions without needing any upgradation in the hardware. By updating the firmware, you will be able to explore new features that are added to the device and also have an enhanced user experience while interacting with the device
 

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top