[RFC PATCH 0/4] block: uImage.FIT filesystem image mapper

Daniel Golle
2022-11-17T00:43:02Z

uImage.FIT is the default image format of Das U-Boot bootloader which
is used on the great majority of embedded Linux devices.

Using uImage.FIT to also store the root filesystem besides kernel and
dtb has several obvious advantages which are hard to obtain in any
other way:
* single image accross different storage types (mmcblk, mtdblock, ubiblock)
* dynamically sized partitions for kernel and rootfs
* hash also for rootfs checked by U-Boot before launching kernel
* images may include additional filesystems e.g. for localization or
branding

Add uImage.FIT partition parser, this time implemented as a tiny block
driver which can be built as a module. Being an early RFC, module
unloading by now has only been implemented rudimentary without removing
partitions added by the driver on unload. If the overall approach looks
acceptable, this can of course be improved.

For this to work, the image has to be created with external data and
sub-images aligned to the system's memory page boundaries, ie.
mkimage -E -B 0x1000 -p 0x1000 ...

Booting such images has been supported by Das U-Boot since v2018.01.

A previous version of this partition parser is in production use on some
OpenWrt devices, eg. the BananaPi R64 where using the FIT parser allows
booting the very same image from eMMC, SD Card or SPI-NAND/UBI and also
using it as a firmware-upgrade image at the same time.
The Ubiquiti UniFi 6 LR access point served as a reference board with
SPI-NOR flash and use of the partition parser on top of a mtdblock
device.

As Das U-Boot by now also passes down the selected configuration node
name via device tree this allows the partition parser (or userspace
process via sysfs) to identify the selected image configuration.

Device Tree schema for that has also been merged already[1].

In most cases this partition parser can be used without relying on the
bootloader to pass-down the configuration node name. The default
configuration node is used then in that case.

A check of the chosen/u-boot,version node is used to make sure that
Das U-Boot has been used to boot the system and the user (or the
bootloader) is required to specify the lower block device to be used
by the parser. In case any of the two is missing, this driver won't
start.

This RFC presents an alternative implementation of the previously
posted patch series "partition parser for U-Boot's uImage.FIT"[1].

[1]: https://github.com/devicetree-org/dt-schema/commit/a24d97d43491e55d4def006213213a6c4045b646
[2]: https://patchwork.kernel.org/project/linux-block/list/?series=695709

Daniel Golle (4):
init: move block device helpers from init/do_mounts.c
block: add new flag to add partitions read-only
blkdev: add function to add named read-only partitions
block: add uImage.FIT block partition driver

MAINTAINERS | 6 +
block/bdev.c | 166 ++++++++++++++++++
block/blk.h | 1 +
block/partitions/core.c | 37 ++++
drivers/block/Kconfig | 6 +
drivers/block/Makefile | 2 +
drivers/block/fitblk.c | 364 ++++++++++++++++++++++++++++++++++++++++
include/linux/blkdev.h | 22 +++
init/do_mounts.c | 166 +-----------------
9 files changed, 606 insertions(+), 164 deletions(-)
create mode 100644 drivers/block/fitblk.c

--
2.38.1