Jetson A/B OTA: reboot loop after power interruption before update commit

Hello! We’re investigating cases in which a device can become stuck in a reboot loop after power is interrupted during or shortly after an OTA update finishes, before Mender has commited the update and acknowledged it as successful. The affected devices are deployed remotely, so we are not present when power is interrupted. In these cases, the user may unplug the device while an update is finishing or shortly after it reboots.

Setup

  • NVIDIA Jetson/Tegra platform with bootloader and rootfs A/B redundancy.
  • Mender client 4.0.7, using a rootfs-image Update Module and a custom Tegra/Mender integration.
  • UEFI boot with L4TLauncher; firmware versions observed include 36.4.3 and 36.4.4.
  • Persistent Mender state under /data/mender.

Our observation

Serial output on affected device showed a firmware-level reset and the device never reached Linux:

Switching the bootchain. Resetting the system in 2 seconds.

In UEFI, we saw:

OS chain A status: Unbootable
OS chain B status: Normal
L4T Boot Mode: ExtLinux

Manually changing OS chain A to Normal allowed the device to boot. After recovery, nvbootctrl showed rootfs A and bootloader A active, while bootloader B was Unbootable and the capsule update status was 2.
We did not capture the bootloader and rootfs status tables simultaneously before recovery, so we cannot establish the exact sequence that led to those states. A subsequent OTA succeeded, and the device later booted from B with both bootloader slots reporting Normal.

In a separate power-interruption test, the device rebooted once and then reached Linux. We later observed a pending upgrade with both rootfs slots Normal:

Current rootfs slot: A
Active rootfs slot: A
slot: 0, retry_count: 0, status: normal
slot: 1, retry_count: 1, status: normal

upgrade_available=1
/var/lib/mender/boot_attempted exists

The previous boot’s journal was not persistent, so we could not determine which component requested the extra reboot. This test did not reproduce the persistent firmware-level loop.

Integration behavior we’re investigating

We found that the nv_update_verifier.sh at our pinned commit uses a persistent boot_attempted marker.

If upgrade_available is not 0 and the marker matches the current bootloader slot, the script removes the marker and forces a reboot. If upgrade_available=0, it calls nvbootctrl verify.

We’re wondering how this is intended to behave when a device loses power after booting the update but before Mender commits it. We have not established that the verifier’s forced-reboot branch ran during the persistent loop. In the captured loop, the resets occurred in firmware before Linux started.

We also found that our fw_setenv implementation stores upgrade_available as a file-backed marker. We’re still investigating how the rootfs-image rollback path coordinates that marker with NVIDIA’s slot selection and verification.

Questions

  1. Is this a known failure mode for power loss between the OTA reboot and Mender commit on a Jetson A/B integration?
  2. How should the integration coordinate Mender’s upgrade_available state, Jetson boot retries, and nvbootctrl verify so that an interrupted trial boot does not exhaust the last known-good fallback?
  3. Is the verifier’s forced reboot on a repeated boot into the same slot expected after power loss? What is supposed to select and acknowledge the known-good slot if the update cannot be committed?
  4. What slot/status transitions and logs would you recommend capturing to distinguish an expected rollback from a boot-control integration issue?

We can try to reproduce power interruptions on a test device and collect serial logs and slot states. We’d appreciate guidance on the expected recovery behavior and any existing tests or fixes for this case.

We’d appreciate any comment and would like to know if someone has experienced this before too. Thanks in advance!!

Hi @chrisg,

I think I saw something similar to this, but can’t remember the exact details. It depended on the exact timing of the power fail during the update cycle, yes. Unfortunately I’m traveling at the moment, but hopefully I can rig up everything again next week and try to reproduce.

Since Mender Client 4.x it is also possible to replace the glue code integration with one using the native tooling. I think it should not suffer the same failure mode, but I’m definitely not sure, and its all a bit fresh still. Yet if you are interested, have a peek at meta-mender-community/meta-mender-tegra/meta-mender-tegra-native at tegra-data-trailing-partition · TheYoctoJester/meta-mender-community · GitHub.

Hopefully can get back to reproducing soon, will let you know then.

Greetz,
Josef

Hi @TheYoctoJester , thanks a lot for your answer. I’ll definitely have a look at the links.

Greetings!

Hi @chrisg,

I went through the edk2-nvidia source for r36.4.3/36.4.4 with some AI help, and I think the loop can be explained without a Mender bug.

“Switching the bootchain. Resetting the system in 2 seconds.” comes from L4TLauncher, at the end of ValidateRootfsStatus() in L4TRootfsValidation.c. With bootloader+rootfs redundancy, when the current rootfs slot has no retries left it marks the slot unbootable and, if the other rootfs slot looks bootable, sets BootChainFwNext to it and cold-resets. The rootfs slot is always tied to the bootloader chain. That check only looks at the rootfs retry counts, not at whether the target bootloader chain works.

Your capsule status 2 is documented as “Capsule install successfully but boot new firmware failed”, which fits bootloader B being unbootable. So my guess is: rootfs A ran out of retries, rootfs B still looked fine, L4TLauncher switches to chain B, chain B fails, you’re back on A, and it starts again. BootChainFinishUpdate() clears BootChainFwResetCount each round, so its limit of 3 never stops it. Setting OS chain A to Normal breaks the loop, as you saw.

Not verified: how rootfs A got to zero retries in your case (several reboots before the boot-successful service ran?), and the early-boot fallback from B to A.

If it happens again, it would help to dump these before touching anything: RootfsStatusSlotA/B, BootChainFwCurrent/Next/Previous/Status/ResetCount, plus nvbootctrl dump-slots-info and nvbootctrl -t rootfs dump-slots-info.

Open question for @TheYoctoJester: does the native integration avoid a rootfs failover while the other bootloader chain is known bad?

Note: I used Claude (Anthropic’s AI assistant) for this one: it helped with the diagnosis on the bench, wrote the patch and drafted this post. the results come from real power cuts on real hardware.

Hi @chrisg, hi @janos-naumann,

I finally got the bench rigged up again, and I can reproduce the loop reliably. Thanks a lot to @janos-naumann for the edk2-nvidia analysis, it was spot on and saved me a lot of digging.

Setup

Jetson Orin Nano devkit (p3767-0005, NVMe), L4T 36.4.4, meta-mender-community scarthgap with the classic integration (the update logic is unchanged since 1a20362), RootfsRetryCountMax=1 as set by the layer. Mender client 5.0.3, driven in standalone mode so I can hold the device in the “booted but not committed” window. Power is switched through a relay, so the cuts are real cold power cuts.

Reproduction

  1. Install an update on slot A and reboot.
  2. Cut power while UEFI writes the bootloader capsule (I cut at “Update Progress - 50%”).
  3. Power on. The device comes back on slot A, the capsule is not retried (UEFI clears OsIndications and removes TEGRA_BL.Cap before applying it). The update is still pending: upgrade_available=1, boot_attempted=0, rootfs A has retry_count: 0, rootfs B is Normal (switch-rootfs set it before the capsule). Note that nvbootctrl dump-slots-info still reports bootloader slot B as normal at this point.
  4. Cut power again before the update is committed.
  5. Power on: L4TLauncher boots rootfs A, and 6.5 seconds into Linux nv_update_verifier finds boot_attempted matching the current slot and forces a reboot. The persistent journal says so explicitly:
    Reboot requested from client PID 711 ('systemctl') (unit nv_update_verifier.service)
  6. That reboot is warm, so the rootfs retry counter of A is still 0. L4TLauncher marks A unbootable, sees B with retries left, prints Switching the bootchain. Resetting the system in 2 seconds., BootChainDxe flips the BR-BCT to chain B, chain B is half written and never reaches UEFI, the boot ROM falls back to chain A, and L4TLauncher switches again. Forever. I counted 11 rounds in 5 minutes before I stopped watching.

UEFI then shows exactly what you saw: OS chain A Unbootable, OS chain B Normal. Setting OS chain A to Normal in the setup menu breaks the loop, and afterwards nvbootctrl shows bootloader B as unbootable, again as in your report. One difference: my capsule status reads 1, not 2.

Step 4 does not even need a power cut. A plain reboot while the device sits on slot A with the pending update triggers the same switch, and so would the reboot of a Mender rollback.

Root cause

Three things line up:

  • The layer sets RootfsRetryCountMax to 1, and while an update is pending nothing re-arms the running slot. So the old slot sits at 0 retries, and a single warm reset condemns it.
  • switch-rootfs marks the target rootfs slot Normal before the capsule has proven the target bootloader chain.
  • nv_update_verifier never checks whether it is running on the slot the update targets. After an interrupted capsule it is running on the old, known-good slot, and its forced reboot is exactly the warm reset that condemns it.

On the firmware side, as @janos-naumann found, L4TLauncher only looks at the rootfs retry counts when it fails over and never at the health of the target bootloader chain. On top of that, once A is stored as unbootable in the UEFI variable, every pass rebuilds the retry counters with A at 0, so the loop sustains itself.

A related consequence in daemon mode: because the fake fw_printenv reports the booted slot as mender_boot_part, ArtifactVerifyReboot cannot tell that the switch never happened. Mender would happily commit the new artifact while still running the old rootfs.

Fix

I have a fix attempt for the classic integration on a branch, tested on the bench:

  • switch-rootfs records the target slot in /var/lib/mender/tegra-update-target.
  • nv_update_verifier compares it with the running slot. If an update is pending and we are not on the target, we are on the known-good slot: it marks the target rootfs slot unbootable, runs nvbootctrl verify (re-arming the running slot), and clears upgrade_available so Mender rolls back. No forced reboot in that case.
  • The commit and rollback hooks remove the marker.
  • nv_update_verifier.service becomes Type=oneshot and is ordered before the Mender daemon, so the daemon cannot commit before the verifier has decided.

With that, the same sequence ends with the device running slot A, rootfs B marked unbootable, no loop on a second power cut nor on a warm reboot, and the deployment rolled back. The next update to B rewrites chain B and leaves both chains Normal. The designed fallback (power loss while pending on the new slot) still rolls back cleanly to the old one.

PR: tegra: fix firmware reboot loop after power loss during the bootloader capsule update by TheYoctoJester · Pull Request #538 · mendersoftware/meta-mender-community · GitHub

@janos-naumann’s question about the native integration

From reading the code: no, the native integration does not avoid this either. It also sets RootfsRetryCountMax to 1, also marks the target rootfs Normal before the capsule lands, and nothing checks the bootloader chain before the firmware fails over. It does not have the forced reboot, so it takes a different warm reset to trigger it, but the exposure is the same. I have not run the power cut test against it on the bench yet; it will get the same treatment.

If it happens again in the field

Before touching anything, please grab:

  • from UEFI setup: OS chain A/B status
  • after recovery, from Linux: nvbootctrl dump-slots-info, nvbootctrl -t rootfs dump-slots-info, the RootfsStatusSlotA/B and BootChainFw* efivars, /var/lib/mender/upgrade_available and boot_attempted
  • and make the journal persistent, the previous boot’s journal is what tells you who rebooted.

Greetz,
Josef

Note: as before, I used Claude (Anthropic’s AI assistant) for the bench work and for drafting this post.

Hi @chrisg, hi @janos-naumann,

a short follow-up. I kept hammering the bench with more power cuts and resets, and there is one corner case left that the fix does not cover. I added it to the PR as a known limitation, but you should know about it if you run the fix in the field.

What remains

After an interrupted capsule, the fix marks the target rootfs slot unbootable and rolls back. That mark stays until the next complete update rewrites the half-written bootloader chain. This is on purpose: clearing it earlier would let L4TLauncher fail over into that chain again, which is exactly the loop.

In that window the running slot is the only bootable one. If the device then crashes early in boot (kernel panic or watchdog reset before nv_update_verifier runs), RootfsRetryCountMax=1 makes L4TLauncher condemn the running slot as well. With both slots unbootable it tries the recovery boot, and as the recovery partition is empty on these images, it stops in the UEFI shell:

L4TLauncher: Attempting Recovery Boot
Failed to boot recovery:1 partition

This survives power cycles. Note that it needs two independent events: the interrupted capsule, and then an early crash before the next update. Without the fix, the interrupted capsule alone ends in the loop.

If you end up in the UEFI shell

Set the slot the device was running back to Normal, either in UEFI setup (L4T Configuration, OS chain status) or directly in the shell. For slot B:

setvar RootfsStatusSlotB -guid 781e084c-a330-417c-b678-38e696380cb9 -nv -bs -rt =00000000
reset

Use RootfsStatusSlotA if it was running on A. Leave the other slot unbootable, its bootloader chain is still half-written. The next update rewrites that chain and clears the mark.

What comes next

L4TLauncher already has the hook for this: when both slots are unbootable, it boots the recovery partition. A minimal image there that sets the running slot back to Normal and reboots turns this into one extra reboot. I have a prototype for that, it is not part of the PR yet.

Details are in the PR: tegra: fix firmware reboot loop after power loss during the bootloader capsule update by TheYoctoJester · Pull Request #538 · mendersoftware/meta-mender-community · GitHub

Greetz,
Josef

Hi @janos-naumann, @TheYoctoJester,

thank you both for your help!! I will take a closer look but it looks very promising and hopefully it can help us. Will keep an eye out for any cases where this is repeated.

Best,
Christina