openwrt/target/linux/ramips
Nikolay Martynov 62dbcb8305 ramips: Fix root volume for tplink-er605-v2
This device has two sets of volumes: main ones (`kernel`, `rootfs`, etc) and
'backup' (`kernel.b`, `rootfs.b`, etc). Bootloader tries to determine which set of
volumes to use by looking at contens of `extra-para` and `extra-para.b` volumes.
These volumes contain JSON that looks like this:

```
{
	"dbootFlag": "1",
	"integerFlag": "1",
	"fwFlag": "GOOD",
	"score":1
}
```

It looks like the bootloader looks for `"fwFlag": "GOOD"` (as opposed to `BAD`)
then it compares `score` field - whichever 'good' volume has bigger score wins.
This determines which set of volumes to use to boot.

So for example if `extra-para` is good and has bigger score then `kernel`,
`rootfs`, etc volumes are used. This means bootloader needs to explain to the
kernel which volume to use for the rootfs. After looking at bootloader code with
disassembler I think it contains a bug. Relevant part of code looks something
like this:

```
  if (image_id == 0) {
    rootfs_volume_id = 8;
    rootfs_volume_name = "rootfs";
  }
  else {
    rootfs_volume_id = 0xf;
    rootfs_volume_name = "rootfs.b";
  }
  sprintf(
    &buffer,
    0x800,
    "console=ttyS0,115200 noinitrd ubi.mtd=3,2048 ubi.block=0,%s
    root=/dev/ubiblock0_%d DKMGT_IMAGE_ID=%d DKMGT_IMAGE_TYPE=ubi",
    rootfs_volume_name,
    rootfs_volume_id,
    image_id
    );
```

Where `image_id == 0` if 'normal' (not '*.b' set of volumes is used).
However from device dumps we know that from the factory `rootfs.b` has id 8 and
`rootfs` has id 15.

So from above we can see that ids and names of rootfs volumes do not match. More
over - they are hardcoded in the bootloader.

Both things are problematic for OpwnWRT which completely removes volumes on
update meaning that volume ids may actually change.

So instead of relying on bootloader to provide the kernel with root device this
patch forces kernel to determine root automatically - and it defaults to
`rootfs` volume which is correct for our purposes.

Overall this makes image boot fine from flash after sysupgrade from inirams.
assuming `extra-para*` volumes make bootloader use non-'*.b' set of volumes.

Signed-off-by: Nikolay Martynov <mar.kolya@gmail.com>
2023-01-22 14:37:47 +01:00
..
base-files/etc ramips: remove model name from LED labels 2020-10-02 14:51:57 +02:00
dts ramips: Fix root volume for tplink-er605-v2 2023-01-22 14:37:47 +01:00
files/drivers ramips: ethernet: ralink: add led_source dts-binding 2022-05-01 13:40:13 +09:00
image ramips: mt7621: Add Arcadyan WE420223-99 support 2023-01-15 13:41:02 +01:00
mt76x8 ramips: add support for Keenetic KN-1613 2023-01-06 17:53:10 +01:00
mt7620 ramips: add support for SNR-CPE-W4N-MT router 2022-12-17 22:34:44 +01:00
mt7621 ramips: mt7621: Add Arcadyan WE420223-99 support 2023-01-15 13:41:02 +01:00
patches-5.10 kernel: bump 5.10 to 5.10.163 2023-01-14 22:31:38 +01:00
patches-5.15 kernel: bump 5.15 to 5.15.87 2023-01-13 22:04:22 +01:00
rt288x kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
rt305x kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
rt3883 kernel: disable CONFIG_CPU_LITTLE_ENDIAN in generic config 2022-10-21 13:47:01 +02:00
Makefile ramips: add linux 5.15 support for mt7621 2022-03-27 21:36:40 +02:00
modules.mk ramips: rename mtk-hsdma to hsdma-mt7621 2021-03-04 23:43:02 -10:00