]> git.ipfire.org Git - thirdparty/openwrt.git/commit
generic: add mstc-boot mtdsplit parser
authorINAGAKI Hiroshi <musashino.open@gmail.com>
Mon, 28 Apr 2025 09:44:29 +0000 (18:44 +0900)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 20 Jul 2025 14:12:56 +0000 (16:12 +0200)
commitddf7d63e946a65d510c4ec0338aea49dc45a976c
tree219cc959312fce42d2b122069985bf41908dfdb6
parentc08c2d6eb39dd5e040d6a50fdb46471b268fad1a
generic: add mstc-boot mtdsplit parser

Add new mtdsplit parser "mstc-boot" for the devices manufactured by MSTC
(Mitra Star Technology Corp.). This is necessary to handle dual-boot on
those devices.
This parser splits kernel+rootfs or only rootfs(or UBI) based on the
image in the firmware partition or pre-defined partitions in dts, and
"bootnum" value in the "persist" (or "working") partition.

Note: "bootnum" is used for switching active firmware partitions on the
      devices manufactured by MSTC and '1' or '2' are used on most
      devices. But some devices use '0' or '1'. (example: I-O DATA
      WN-DEAX1800GR)

Sequence:

1. obtain "bootnum" value
2. child nodes exsist (regardless of bootnum)
   -> fixed partitions
      (active parts  : without bootnum (ex.: "kernel", "rootfs")
       inactive parts: with bootnum (ex.: "kernel2", "rootfs2"))
3. current partition is active (dt bootnum == mtd bootnum)
   -> image-based partitions

Device Tree:

- common

  - mstc,bootnum  : "bootnum" value for the mtd partition (0/1/2)
  - mstc,persist  : phandle of "persist" partition containing "bootnum"
                    value

- fixed partitions

  - #address-cells: indicate cell count of address of child nodes (1)
  - #size-cells   : indicate cell count of size of child nodes (1)
  - (child nodes) : define the child partitions
    - reg         : define the offset and size
    - label-base  : define the base name of the partition
      - (example) : base:"kernel"->"kernel"(active)/"kernel2"(inactive)

  example:

  partition@3c0000 {
   compatible = "mstc,boot";
   reg = <0x3c0000 0x3240000>;
   label = "firmware1";
   mstc,bootnum = <1>;
   mstc,persist = <&mtd_persist>;
   #address-cells = <1>;
   #size-cells = <1>;

   partition@0 {
   reg = <0x0 0x800000>;
   label-base = "kernel";
   };

   partition@800000 {
   reg = <0x800000 0x2a40000>;
   label-base = "ubi";
  };
  };

- image-based partitions

  (no additional properties)

  example:

  partition@5a0000 {
   compatible = "mstc,boot";
   label = "firmware1";
   reg = <0x5a0000 0x3200000>;
   mstc,bootnum = <1>;
   mstc,persist = <&mtd_persist>;
  };

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
Link: https://github.com/openwrt/openwrt/pull/18976
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/generic/config-6.12
target/linux/generic/config-6.6
target/linux/generic/files/drivers/mtd/mtdsplit/Kconfig
target/linux/generic/files/drivers/mtd/mtdsplit/Makefile
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_mstc_boot.c [new file with mode: 0644]