rootfs_data on UBI-aware devices
Rafał Miłecki
zajec5 at gmail.com
Wed Dec 8 23:58:00 PST 2021
Hi,
I have BCM4908 router with U-Boot that uses UBI. There are basically
two relevant UBI volumes:
1. bootfs (contains U-Boot, kernel & DTBs)
2. rootfs
Broadcom's U-Boot takes "pkgtb" firmware format with "bootfs" and
"rootfs" images. It writes them to UBI volumes.
What's missing in this design is "rootfs_data". Usually "rootfs_data" is:
1. Created by OpenWrt by splitting "rootfs"
or
2. Created in UBI image while building OpenWrt image
Here I already have UBI on flash (managed by bootloader), so I don't
create whole UBI image. Just content for UBI volumes (bootfs FIT &
rootfs ubifs).
Question: how to deal with creating "rootfs_data" (like?) on UBI based device?
I guess I need some user space uci-defaults / init script to handle that.
Creating "rootfs_data" UBI volume with "ubimkvol" should be easy. I
just need init.d or uci-defaults script that will do that before
fstools starts.
The problem I see is wiping "rootfs_data" when needed. That UBI volume
should be linked with currently flashed firmware. So even if someone:
1. Has OpenWrt installed
2. Flashes OpenWrt again using bootloader
The newly flashed OpenWrt won't use the old "rootfs_data".
Any idea how to do that? It requires some identification of currently
flashed image. It can't be any release/build based magic number as
even flashing exactly the same image (as already installed) should
wipe "rootfs_data".
I can't think of any generic solution to that.
On this specific platform I could:
1. Add some placeholder to "bootfs" and replace it with random number
if it's empty.
2. Use U-Boot stored flashing sequence number of currently running firmware.
Both solutions are BCM4908 U-Boot specific.
Other solutions I can think of:
1. Hacking UBI volume header by adding custom field there. Fill with
random number if it's empty.
2. Appending some empty placeholder data to kernel. Fill with random
number if it's empty. Tricky if kernel is hidden in FIT image in UBI
volume.
Any ideas?
--
Rafał
More information about the openwrt-devel
mailing list