odroidm1: clear SPI u-boot env on every (re)flash (fixes NVMe boot from SPI) - #10351
Conversation
…boot
write_uboot_platform_mtd flashed SPL (mtd0) and u-boot (mtd2) to SPI but only
erased the env partition (mtd1) when it detected Hardkernel's petitboot. Any
other saved env - e.g. from an older Armbian u-boot - survives the reflash, and
u-boot loads it in preference to its own built-in environment, shadowing the
boot order.
On an M1 with a stale SPI env this shows up as:
Loading Environment from SPIFlash... OK
## Error: "mtd_boot" not defined
(never scans NVMe -> USB -> BOOTP/DHCP -> no boot)
'mtd_boot' is not present anywhere in the current u-boot; it comes from the
stale saved env's bootcmd, whose boot_targets predates nvme. Reflashing SPL +
u-boot (2026.01 -> 2026.07) changed nothing because the env was never touched.
Always erase mtd1 when writing u-boot to SPI so the fresh u-boot regenerates
its default env - which carries the correct boot order (mmc/nvme/scsi/usb/...)
and lets "boot from SPI, root on NVMe" work.
Signed-off-by: Igor Pecovnik <igor@armbian.com>
📝 WalkthroughWalkthroughThe Odroid M1 U-Boot flashing configuration now always erases the SPI environment partition after writing the SPL and U-Boot images. The previous Petitboot detection and conditional erase logic was removed. ChangesOdroid M1 U-Boot flashing
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Hardware-confirmed on the Odroid M1: at the u-boot prompt, |
Problem
"Boot from SPI, root on NVMe" on the Odroid M1 doesn't boot. Serial shows u-boot loads from SPI fine, then:
It never scans NVMe, and reflashing a newer u-boot (2026.01 → 2026.07) changes nothing.
Root cause — stale SPI env shadows the new u-boot
write_uboot_platform_mtdwrites SPL (mtd0) and u-boot (mtd2) but only erases the env partition (mtd1) if it detects petitboot:Any other saved env — an older Armbian u-boot, or a factory env that doesn't match the petitboot string — survives, and u-boot loads it (
Loading Environment from SPIFlash... OK) in preference to its built-in default. That stale env'sbootcmdrunsmtd_boot(which doesn't exist in the current u-boot — grep of the whole 2026.07 tree finds nothing) and itsboot_targetspredates nvme. So NVMe is never scanned. Because the reflash never touches mtd1, both 2026.01 and 2026.07 fail identically.The board's built-in
BOOT_TARGETS(and the board's boot-order override) already include nvme — they're just being overridden by the saved env.Fix
Always
flash_erase /dev/mtd1when (re)flashing u-boot to SPI, so the fresh u-boot regenerates its default env with the correct boot order. A fresh install should reset the env to match the bootloader.Confirming on hardware (no rebuild needed)
At the M1 u-boot prompt this reproduces the fix immediately:
Scope
This is the board-hook side. The configng installer (PR #973) correctly calls
write_uboot_platform_mtd; nothing to change there.Summary by CodeRabbit