OE4T / meta-tegra

BSP layer for NVIDIA Jetson platforms, based on L4T
MIT License
405 stars 222 forks source link

Enable rootfs ab redundancy support #1428

Closed dwalkes closed 10 months ago

dwalkes commented 10 months ago

Add BSP support for enabling A/B redundancy and managing redundant and non-redundant A/B partition layouts, using the Nvidia provided BSP layouts.

See details in the wiki page at https://github.com/OE4T/meta-tegra/wiki/Redundant-Rootfs-A-B-Partition-Support

When combined with https://github.com/OE4T/meta-tegra/pull/1285 , this logic provides a base for supporting A/B slot switching using uefi variables and capsule updates which is independent of a specific update tool used to write parititions.

Control for supporting A/B rootfs partition layout is supported through USE_REDUNDANT_FLASH_LAYOUT which is set to 0 by default in the BSP layer, but set to 1 in tegra-demo-distro.

Custom MACHINEs which already define their own ROOTFSPART_SIZE, PARTITION_LAYOUT_TEMPLATE, and ROOTFSPART_SIZE shouldn't be impacted by this change, although anyone who has done their own overlay implementation for Rootfs A/B may want to remove it in favor of this implementation.

I've initially tested this on jetson-xavier-nx-devkit-emmc and demo-image-base with this sequence:

In local.conf:

IMAGE_INSTALL:append = " tegra-uefi-capsules"

After building/booting, I see slots enabled and slot A selected

root@jetson-xavier-nx-devkit-emmc:~# nvbootctrl dump-slots-info
Current version: 35.4.1
Capsule update status: 0
Current bootloader slot: A
Active bootloader slot: A
num_slots: 2
slot: 0,             status: normal
slot: 1,             status: normal

After performing capsule update:

mkdir -p /opt/nvidia/esp/EFI/UpdateCapsule
cp /opt/nvidia/UpdateCapsule/tegra-bl.cap /opt/nvidia/esp/EFI/UpdateCapsule/TEGRA_BL.Cap
oe4t-set-uefi-OSIndications

and rebooting, I see:

root@jetson-xavier-nx-devkit-emmc:~# nvbootctrl dump-slots-info
Current version: 35.4.1
Capsule update status: 1
Current bootloader slot: B
Active bootloader slot: B
num_slots: 2
slot: 0,             status: normal
slot: 1,             status: normal

And rootfs changed to partition 2:

root@jetson-xavier-nx-devkit-emmc:~# mount | grep mmcblk0p
/dev/mmcblk0p2 on / type ext4 (rw,relatime)

If/when this looks ready to merge I'll test on a few other platforms and try some non-redundant configs.

Closes https://github.com/OE4T/meta-tegra/issues/1389

dwalkes commented 10 months ago

I believe I've addressed all the comments here. I've also re-tested on jetson-xavier-nx-devkit-emmc in the default configuration with USE_REDUNDANT_FLASH_LAYOUT = "0" and the branch of tegra-demo-distro at https://github.com/OE4T/tegra-demo-distro/pull/284 which sets USE_REDUNDANT_FLASH_LAYOUT_DEFAULT = "1".

Tomorrow I'll try with jetson-xavier-nx-devkit-emmc and NVMe boot as well as Orin Nano with/without NVMe.

dwalkes commented 10 months ago

Tested with jetson-xavier-nx-devkit-emmc

Tested with jetson-orin-nano-devkit

Tested with jetson-orin-nano-devkit-nvme

In each of the redundant cases I ran capsule update and verified the slots changed accordingly.

I think this is ready to merge but let me know if you'd like me to try something else.

I'd like to backport this to kirkstone next as well, let me know if you'd like a PR for this.

madisongh commented 10 months ago

Thanks @dwalkes ! Once we've got a passing build on master (with your PR merged there), I'll cherry-pick these to the other branches.

madisongh commented 10 months ago

I've backported these changes to nanbield, mickledore, and kirkstone branches.

arrow53 commented 7 months ago

@dwalkes @madisongh with my orin nano on kirkstone with the tegra-demo-distro I don't see the redundant flash layout as being 1

/yocto/tegra-demo-distro-nvme/build$ bitbake -e demo-image-egl | grep ^USE_REDUNDANT_FLASH_LAYOUT
USE_REDUNDANT_FLASH_LAYOUT="0"
USE_REDUNDANT_FLASH_LAYOUT_DEFAULT="0"

I have these in my local.conf FWIW

IMAGE_INSTALL:append = " tegra-uefi-capsules"

TNSPEC_BOOTDEV = "nvme0n1p1"
dwalkes commented 7 months ago

@arrow53 I think https://github.com/OE4T/tegra-demo-distro/pull/284 was never backported to kirkstone. @madisongh would you prefer not to change tegra-demo-distro branches to avoid swapping partition layouts on stable branches? I should probably just clarify wording in https://github.com/OE4T/meta-tegra/wiki/Redundant-Rootfs-A-B-Partition-Support#setting-up-a-custom-machine in that case.

madisongh commented 7 months ago

@dwalkes Yes, that's right - https://github.com/OE4T/tegra-demo-distro/pull/284 would have been a big surprise to folks already using kirkstone if it had been backported.