difos/target/linux/generic/files/drivers/mtd/mtdsplit
INAGAKI Hiroshi ddf7d63e94 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>
2025-07-20 16:12:56 +02:00
..
Kconfig generic: add mstc-boot mtdsplit parser 2025-07-20 16:12:56 +02:00
Makefile generic: add mstc-boot mtdsplit parser 2025-07-20 16:12:56 +02:00
mtdsplit.c treewide: replace nbd@openwrt.org with nbd@nbd.name 2016-06-07 08:58:42 +02:00
mtdsplit.h treewide: replace nbd@openwrt.org with nbd@nbd.name 2016-06-07 08:58:42 +02:00
mtdsplit_bcm63xx.c kernel: mtdsplit: add support for BCM63XX CFE firmware 2021-02-22 18:09:03 +01:00
mtdsplit_bcm_wfi.c kernel: mtd: bcm-wfi: add cferam name support 2023-06-14 23:21:34 +02:00
mtdsplit_brnimage.c kernel: update mtdsplit for linux 4.9 2017-02-03 12:35:44 +01:00
mtdsplit_cfe_bootfs.c kernel: create bootfs partition when parsing on BCM4908 2021-03-24 18:22:37 +01:00
mtdsplit_elf.c kernel: mtdsplit: support ELF loader splitting 2020-09-09 20:41:50 +03:00
mtdsplit_eva.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_fit.c kernel: mtdsplit: fix fit rootfs_data split 2024-07-07 20:58:56 +08:00
mtdsplit_h3c_vfs.c kernel: mtdsplit: add support for H3C VFS filesystem 2022-07-28 14:08:56 +02:00
mtdsplit_jimage.c treewide: strip trailing whitespace 2025-05-20 00:47:37 +02:00
mtdsplit_lzma.c generic: mtdsplit: include appropriate header for kernel 6.12 2025-04-30 16:26:46 +02:00
mtdsplit_minor.c kernel: mtdsplit_minor: accept bootimage filename 2024-10-30 11:15:34 +01:00
mtdsplit_mstc_boot.c generic: add mstc-boot mtdsplit parser 2025-07-20 16:12:56 +02:00
mtdsplit_seama.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_seil.c kernel: add seil-fw mtdsplit driver for IIJ SEIL devices 2023-10-31 14:02:01 +01:00
mtdsplit_squashfs.c kernel: rename mtdpart_get_master to mtd_get_master 2020-11-13 13:16:51 +01:00
mtdsplit_tplink.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_trx.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_uimage.c kernel: mtdsplit_uimage: return 0 if not fatal 2025-06-19 20:51:18 +02:00
mtdsplit_wrgg.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00