-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support dual firmware (aka A/B) devices where rootfs_data are discreete partitions #9
base: master
Are you sure you want to change the base?
Conversation
Move get_var_from_file() to common library. Signed-off-by: Rodrigo Balerdi <[email protected]>
The kernel parameter 'fstools_overlay_name' can now be used to specify the overlay backing storage by name. The name is resolved by the regular stack of fstools drivers. Signed-off-by: Rodrigo Balerdi <[email protected]>
The kernel parameter 'fstools_overlay_fstype' can now be used to specify the preferred overlay fileystem type. The supported values are 'ext4', 'f2fs' and 'auto'. Type 'auto' is the default and represents the usual behavior of selecting the filesystem type based on available space. Signed-off-by: Rodrigo Balerdi <[email protected]>
hi @hauke, sorry to bother you. openwrt does not support dual-firmware in devices with discreet |
tangential note: i must admit that (in addition to these changes) i'd also like seeing a u-boot env var that takes precedence over in time i've heard many people wanting ext4 in the overlay in the forums, and i see no reason why we shouldn't accommodate them. a simple uboot var could be set to solve the issue for those who care. i could also do that change if desired. there is precedence on customizing sysupgrade with optional uboot vars, such as providing a limit for how big you want the overlay fs when it is a volume inside a UBI partition. |
@dangowrt so there's no interest in supporting dual firmware? |
I think there could be interest in supporting existing vendor bootloaders which offer A/B dual-boot feature (which is what this PR is about, ie. supporting the existing A/B on NBG7815, right?). |
no, i don't have that device, this is about spectrum sax1v1k. the relevant partitions of this device are:
this device is has secure boot enabled and a locked down bootloader. the bootloader cannot be interrupted. initial access is gained by hacking the firmware userland. then uboot vars are programmed that will patch uboot in memory before loading an unsigned kernel. the situation was very precarious because a borked system would have become an unrecoverable brick. i coded a solution for this, allowing breaking the boot process if you have serial access, an also externally triggering a recovery (initramfs) OS at any time without serial access. on top of that, i also wanted to add the possibility of completely rolling back a sysupgrade externally without serial access, but i'm not going to do that if both systems share rootfs_data. i think it just doesn't make sense to do that. the two rootfs_data partitions are there, but i can't use them because openwrt is missing this capability. the partitions cannot be merged or renamed, as in my experience most qualcomm systems from the last decade with secure boot enable sign the GPT, so any change results in a brick. (not that i'd want to merge anything: i think 512 MB rootfs_data is more than enough, and IMHO the best and safest way to leverage an 8GB emmc like this one in openwrt is to use a big partition (eg: the existing user_data with 4.7 GiB) as extra storage that survives sysupgrades.) actual status of official devices
i respectfully disagree. this might have been the case in 128 MB devices, but there is no use in having 3.5 GB or 7.5 GB rootfs_data partitions these days. more importantly, this is not how actual official openwrt devices are implemented. many of these devices have separate rootfs_data partitions for A and B (placing rootfs_data after rootfs via loop) in both nand and emmc storages. example: whw03v2512 MB NAND device where rootfs_data could be 450 MB but is only 120 MB. here are the partitions:
(btw i proposed solutions to this, but they are not relevant here.) example: whw03v1a 4 GB emmc GPT device where rootfs_data could be 3.5 GB but is less than 100 MB. this also has separate rootfs_data for A and B (as loop devices after rootfs). for this device i provided a solution: optional steps to repartition the device to use 2 x 512 MB rootfs_data (i don't see the point in using more) and the rest of the emmc goes to an extra partition that survives sysupgrades, which you can use if you happen to need it. there are many more examples in the list linked above. my dual boot experienceafter using proper dual boot devices (with dual rootfs_data) i'm really not going back. situations in which a misconfiguration would have required ripping off the device from its network and access it failsafe in isolation happened many times. this is inconvenient enough, but sometimes the devices where remote, which would have meant somebody knowledgeable would have needed to commute. thanks to proper dual boot, these situations just required a special power up sequence to roll back changes, and the rest was handled via VPN. reasons for this change
conclusion: better support for GPTso in summary, openwrt partition handling was designed for nand flash, where the device port author could freely name freely defined partitions, so names could be hard-coded in code as they are. in GPT devices names preexist, and they are either very cumbersome to change (repartition during install) to downright impossible (signed GPTs). in light of this, a way to configure names is needed to better support GPT systems. configuration via the kernel command line is for sure needed. it might be desirable to have other avenues for that, idk, but this is a start. |
could you maybe review this or suggest someone who should? |
hi @robimarko, what would be the best way to have a discussion about this? maybe someone in the core project is interested, but i don't know how to find that out |
hi @hauke @dangowrt @robimarko
Many devices support dual firmwares (
kermel
/kernel_1
,rootfs
/rootfs_1
). However openwrt only supports dual firmwares on devices for which the overlay is stoted in the trailing part of the active rootfs partition. Devices with discreet overlay partitions (rootfs_data
/rootfs_data_1
) are not supported.This change allows the bootloader to choose which
rootfs_data
partition to use, just like it could always choose whichrootfs
: via a kernel command line parameter.For example, uboot can now specify
fstools_overlay_name=rootfs_data
orfstools_overlay_name=rootfs_data_1
. This works for block devices, UBI and MTD, as the system delegates partition name resolution to the usual fstools driver stack.For completeness, an
fstools_overlay_fstype=ext4
/f2fs
/auto
parameter is also included. This selects which filesystem to use when it is time to format the overlay anew.thank you!
this change has been tested to work properly in spectrum sax1v1k.