Skip to content
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

Enable rootfs ab redundancy support #1428

Merged
merged 2 commits into from
Dec 6, 2023

Conversation

dwalkes
Copy link
Member

@dwalkes dwalkes commented Dec 2, 2023

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 #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 #1389

Copy link
Member

@madisongh madisongh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dwalkes , overall this looks good. See in-line for some specific questions and changes.

conf/machine/include/tegra-common.inc Outdated Show resolved Hide resolved
@@ -20,6 +20,8 @@ NVDISPLAY_INIT ?= "${NVDISPLAY_INIT_DEFAULT}"
NVDISPLAY_INIT_DEPS = ""
NVDISPLAY_INIT_DEPS:tegra194 = "nvdisp-init:do_deploy"

SRC_URI += "${@'file://L4TConfiguration-RootfsRedundancyLevelABEnable.dtso' if d.getVar('USE_REDUNDANT_FLASH_LAYOUT') else ''}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The suffix for the DTS fragment should be .dtsi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Fixed.

conf/machine/include/tegra-common.inc Outdated Show resolved Hide resolved
conf/machine/include/tegra-common.inc Outdated Show resolved Hide resolved
@dwalkes dwalkes marked this pull request as draft December 4, 2023 23:31
NVIDIA provides redundant flash layouts with A/B support
for most platforms. This commit adds a parameter
USE_REDUNDANT_FLASH_LAYOUT which uses them instead of the
default non-redundant.

* Add a variable USE_REDUNDANT_FLASH_LAYOUT to control whether
to use the default flash layout or the redundant flash layout
for both internal and external layouts.  The weak override var
USE_REDUNDANT_FLASH_LAYOUT_DEFAULT can be set at the distro
layer to override the default (off) state if desired.
* Build a PARTITION_LAYOUT_TEMPLATE_REDUNDANT variable
which appends the rootfs_ab string to the partition layout file
for all cases other than when PARTITION_LAYOUT_TEMPLATE_DEFAULT_SUPPORTS_REDUNDANT
is set, where PARTITION_LAYOUT_TEMPLATE_DEFAULT_SUPPORTS_REDUNDANT
is set for nano platforms using flash_t234_qspi.xml which already
contains redundant partitions.
* Build a PARTITION_LAYOUT_EXTERNAL_REDUNDANT variable which
appends the rootfs_ab string to the PARTITION_LAYOUT_EXTERNAL file
for all platforms with the exception of orin nano platforms which
 use "flash_l4t_external.xml" by default.
* Add a ROOTFSPART_SIZE_DEFAULT var which sets the default rootfs
partition size for the MACHINE when not using dual redundancy.
* Add a ROOTFSPART_SIZE_REDUNDANT var which divides the
ROOTFSPART_SIZE_DEFAULT by two when USE_REDUNDANT_FLASH_LAYOUT
is specified.

After this commit:
* Custom MACHINE types which need to support multiple flash
layouts for redundancy can name their layouts to match the
NVIDIA syntax, ending with _rootfs_ab, define
PARTITION_LAYOUT_EXTERNAL_DEFAULT as well as
PARTITION_LAYOUT_TEMPLATE_DEAFULT and the
USE_REDUNDANT_FLASH_LAYOUT will function as expected for
these platforms as well to select the appropriate xml files.
* Custom MACHINEs which don't need to support multiple flash
layouts can just define PARTITION_LAYOUT_EXTERNAL and/or
PARTITION_LAYOUT_TEMPLATE as done previously to override
the default assignments for these variables in tegra-common.inc
* Custom MACHINEs which need to specify a custom partition size
can either specify ROOTFSPART_SIZE_DEFAULT to let the size be
set based on USE_REDUNDANT_FLASH_LAYOUT, or set ROOTFSPART_SIZE
to force to a specific size regardless of USE_REDUNDANT_FLASH_LAYOUT

See also https://github.com/OE4T/meta-tegra/wiki/Rendundant-Rootfs-A-B-Partition-Support

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
When USE_REDUNDANT_FLASH_LAYOUT is specified, add the
.dtbo file to the build which enables RootfsA/B suport
in UEFI based on discussion at [1].

This content of the variable is set based on the corresponding
logic found in nvidia's flash.sh.  The usage for this variable
can be found at [2].

1: OE4T#1182 (comment)
2: https://github.com/NVIDIA/edk2-nvidia/blob/71fc2f6de48f3e9f01214b4e9464dd03620b876b/Silicon/NVIDIA/Application/L4TLauncher/L4TRootfsValidation.c#L464-L466

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
dwalkes added a commit to Trellis-Logic/tegra-demo-distro that referenced this pull request Dec 5, 2023
* Update meta-tegra repo to latest supporting [1].
* Set distro configuration to default to A/B redundant
rootfs.

1: OE4T/meta-tegra#1428

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
@dwalkes
Copy link
Member Author

dwalkes commented Dec 5, 2023

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 OE4T/tegra-demo-distro#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 added a commit to Trellis-Logic/tegra-demo-distro that referenced this pull request Dec 5, 2023
* Update meta-tegra repo to latest supporting [1].
* Set distro configuration to default to A/B redundant
rootfs.

1: OE4T/meta-tegra#1428

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
@dwalkes
Copy link
Member Author

dwalkes commented Dec 6, 2023

Tested with jetson-xavier-nx-devkit-emmc

  • non-redundant, emmc
  • rendundant, emmc
  • non-redundant, nvme
  • redundant, nvme

Tested with jetson-orin-nano-devkit

  • non-redundant
  • redundant

Tested with jetson-orin-nano-devkit-nvme

  • redundant

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.

@dwalkes dwalkes marked this pull request as ready for review December 6, 2023 03:11
@madisongh
Copy link
Member

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 madisongh merged commit d421bf5 into OE4T:master Dec 6, 2023
1 check passed
dwalkes added a commit to Trellis-Logic/tegra-demo-distro that referenced this pull request Dec 6, 2023
* Update meta-tegra repo to latest supporting [1].
* Set distro configuration to default to A/B redundant
rootfs.

1: OE4T/meta-tegra#1428

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
madisongh pushed a commit to OE4T/tegra-demo-distro that referenced this pull request Dec 6, 2023
* Update meta-tegra repo to latest supporting [1].
* Set distro configuration to default to A/B redundant
rootfs.

1: OE4T/meta-tegra#1428

Signed-off-by: Dan Walkes <danwalkes@trellis-logic.com>
@madisongh
Copy link
Member

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

@arrow53
Copy link

arrow53 commented Feb 21, 2024

@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
Copy link
Member Author

dwalkes commented Feb 22, 2024

@arrow53 I think OE4T/tegra-demo-distro#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
Copy link
Member

madisongh commented Feb 22, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support enabling rootfs A/B redundancy
3 participants