openwrt/target/linux/generic/files/drivers/mtd/mtdsplit
Linus Walleij 5ac8f14ccb kernel: mtdsplit: create executable prolog splitter
The problem is the following: we have three fixed partitions
in a RedBoot partition for kernel, initrd and rootfs. On the
surface this looks good.

But we have little flash and want to use it efficiently. We want
to use the OpenWrt "firmware" partition scheme where the kernel,
initramfs and sqashfs+jffs2 rootfs is appended, leaving maximum
space for a writeable rootfs.

To do this we will override the existing RedBoot partition table
with one that merges the three separate partitions into one
"firmware" partition.

RedBoot is still booting the system. It still needs to read the
first two parts "as if" these were the kernel and initrd. This
works fine, because the kernel still comes first.

We already have hacks in place to merge the two kernel and initrd
into one binary image and execute it. This is done by prepending
a "prolog" to the kernel that does the necessary copying in
memory and then jumps to execute the kernel.

Since this "prolog" copying routine is just 92 bytes but has 512
bytes allocated, we can trivially create a firmware format that
can be used for splitting the image into kernel and rootfs
using a tagging scheme that can be done directly by scripting
so we don't need any special binary programs.

This splitter implements that idea.

This will be used on the Gemini platform and was tested on the
Raidsonic IB-4220-B.

Link: https://github.com/openwrt/openwrt/pull/21820
Signed-off-by: Linus Walleij <linusw@kernel.org>
2026-02-03 13:33:12 +01:00
..
Kconfig kernel: mtdsplit: create executable prolog splitter 2026-02-03 13:33:12 +01:00
Makefile kernel: mtdsplit: create executable prolog splitter 2026-02-03 13:33:12 +01:00
mtdsplit.c kernel: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01:00
mtdsplit.h kernel: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01: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: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01:00
mtdsplit_eva.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_fit.c kernel: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01:00
mtdsplit_h3c_vfs.c kernel: mtdsplit_h3c_vfs: Fix build 2025-11-21 21:35:32 +01:00
mtdsplit_jimage.c kernel: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01: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: use -ENOENT instead of -ENODEV 2025-11-20 23:42:12 +01:00
mtdsplit_mstc_boot.c kernel: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01:00
mtdsplit_owrt_prolog.c kernel: mtdsplit: create executable prolog splitter 2026-02-03 13:33:12 +01:00
mtdsplit_seama.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00
mtdsplit_seil.c kernel: generic: mtdsplit_seil: use -ENOENT instead of -ENODEV 2025-11-20 23:42:11 +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: mtdsplit: rework and make use of -ENOENT error 2025-11-18 13:07:59 +01:00
mtdsplit_uimage.c kernel: mtdsplit_uimage: use -ENOENT instead of -ENODEV 2025-11-20 23:42:11 +01:00
mtdsplit_wrgg.c kernel: Add missing includes mtdsplit_*.c 2019-07-07 17:37:26 +02:00