nanopi-m5: mainline U-Boot v2026.04 + UFS (vendor-SPL hybrid)#9788
Conversation
Hybrid scenario pairing the SoC vendor SPL idblock with mainline U-Boot proper, for boards where mainline SPL cannot yet boot from UFS (RK3576). VENDOR_SPL_PATH is auto-derived per BOOT_SOC and a default write_uboot_platform_ufs is provided at family level.
Y. Charkov's UFS v5 series (Kwiboo/u-boot ufs-v5, not yet upstream), a Linux mainline DT cherry-pick, and a controller hard-reset workaround. Moved up from board_radxa-rock-4d/ since the SPL gap is SoC-wide.
Switches from the u-boot-radxa-rk35xx legacy fork to mainline v2026.04 with BOOT_SCENARIO=vendor-spl-blobs. Adds SD/SPI/UFS install helpers, rewrites BOOT_TARGETS to 'mmc0 scsi nvme pxe dhcp', and expands KERNEL_TARGET to current,edge,vendor.
Replaces checked-in DTS copies with branch-specific patches against upstream. Enables RTL8822CS Wi-Fi, Bluetooth, GMAC RGMII delays, ADC back button, UART3/UART8. 6.18 also enables &ufshc + regulators.
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds UFS boot/install support for NanoPi M5: new vendor-spl-blobs path, board config and platform writers, installer UFS option, U‑Boot SPL/UFS boot and reset patches, UFS/UART/SDIO kernel DTS additions, and removal of duplicate DTS files. ChangesNanoPi M5 UFS boot and peripherals
Sequence Diagram(s)sequenceDiagram
participant User
participant Installer as armbian-install
participant Root as create_armbian
participant BSP as write_uboot_platform_ufs
participant SPL as U-Boot SPL
participant UFS as UFS Controller
User->>Installer: Select "Boot from UFS"
Installer->>Installer: Detect LUN0/LUN1/LUN2
Installer->>Root: Partition and install rootfs
Root-->>Installer: Complete
Installer->>BSP: Write idbloader + u-boot to boot LUNs
BSP->>UFS: Program LUN1 and LUN0
Note over SPL,UFS: System boot
SPL->>UFS: Enumerate via SPL UFS loader
UFS-->>SPL: Return U-Boot image
SPL-->>SPL: Load and execute U-Boot proper
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Discussion: dedicated UFS image extensionNow that Three points worth weighing:
Not changed in this PR — proposal only. Deferring the call to @igorpecovnik. |
|
@SuperKali the PR description includes too much AI slop. Can you reduce it to the actual important info and not the discussion why things were chosen as a path |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
config/boards/nanopi-m5.conf (1)
57-63: 💤 Low valueConsider extracting BOOT_TARGETS to a board variable.
The
sedapproach to patchrockchip-common.hworks but is fragile—if upstream changes the format of#define BOOT_TARGETS, the regex may silently fail. Consider whether a board-levelUBOOT_BOOT_TARGETSvariable could be wired into the u-boot build instead of runtime patching.That said, this pattern appears elsewhere in the codebase and the
regular_git diffoutput provides visibility into whether the patch applied.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@config/boards/nanopi-m5.conf` around lines 57 - 63, The current pre_config_uboot_target__nanopi_m5_patch_rockchip_common_boot_order function mutates include/configs/rockchip-common.h with a fragile sed that may break if upstream changes the `#define` format; replace this runtime patching by exposing a board-level variable (e.g., UBOOT_BOOT_TARGETS) set to the rockchip_uboot_targets array and wire that into the u-boot build configuration instead of using sed on include/configs/rockchip-common.h—update references in the build logic that consume BOOT_TARGETS to prefer UBOOT_BOOT_TARGETS and remove the sed/regex patch from pre_config_uboot_target__nanopi_m5_patch_rockchip_common_boot_order so diffs are unnecessary and robust.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/bsp/common/usr/bin/armbian-install`:
- Line 1145: The mount call hardcodes ext4 and will fail for btrfs/f2fs; change
the mount in the post-install fixup to use the filesystem type selected by the
format_disk logic (use the variable that holds the chosen fs type instead of the
literal "ext4"), e.g. replace the "-t ext4" in the mount invocation that
references DISK_ROOT_PART and _ufs_fix_mp with the variable that format_disk
sets (and add a safe default/fallback to ext4 if that variable is empty).
---
Nitpick comments:
In `@config/boards/nanopi-m5.conf`:
- Around line 57-63: The current
pre_config_uboot_target__nanopi_m5_patch_rockchip_common_boot_order function
mutates include/configs/rockchip-common.h with a fragile sed that may break if
upstream changes the `#define` format; replace this runtime patching by exposing a
board-level variable (e.g., UBOOT_BOOT_TARGETS) set to the
rockchip_uboot_targets array and wire that into the u-boot build configuration
instead of using sed on include/configs/rockchip-common.h—update references in
the build logic that consume BOOT_TARGETS to prefer UBOOT_BOOT_TARGETS and
remove the sed/regex patch from
pre_config_uboot_target__nanopi_m5_patch_rockchip_common_boot_order so diffs are
unnecessary and robust.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 68008165-db5b-46b8-8a48-b17cfbbcc0a7
📒 Files selected for processing (19)
config/boards/nanopi-m5.confconfig/sources/families/include/rockchip64_common.inclib/functions/compilation/uboot.shpackages/bsp/common/usr/bin/armbian-installpatch/kernel/archive/rockchip64-6.18/board-nanopi-m5-add-wifi-bt-ufs-and-misc.patchpatch/kernel/archive/rockchip64-6.18/dt/rk3576-nanopi-m5.dtspatch/kernel/archive/rockchip64-7.0/board-nanopi-m5-add-wifi-bt-and-misc.patchpatch/kernel/archive/rockchip64-7.0/dt/rk3576-nanopi-m5.dtspatch/kernel/archive/rockchip64-7.1/board-nanopi-m5-add-wifi-bt-and-misc.patchpatch/kernel/archive/rockchip64-7.1/dt/rk3576-nanopi-m5.dtspatch/u-boot/legacy/u-boot-radxa-rk35xx/add-board-nanopi-m5.patchpatch/u-boot/v2026.04/board_nanopi-m5/0001-arm64-dts-rockchip-enable-UFS-controller-NanoPi-M5.patchpatch/u-boot/v2026.04/board_nanopi-m5/0002-rockchip-rk3576-nanopi-m5-Enable-UFS-support.patchpatch/u-boot/v2026.04/general-reset-rockchip-make-device-resets-available-in-SPL.patchpatch/u-boot/v2026.04/general-rockchip-spl-Add-support-for-booting-from-UFS.patchpatch/u-boot/v2026.04/general-spl-Make-UFS-available-for-SPL-builds.patchpatch/u-boot/v2026.04/general-ufs-rockchip-Add-device-reset-support.patchpatch/u-boot/v2026.04/rk3576-arm64-dts-Explicitly-request-UFS-reset-pin.patchpatch/u-boot/v2026.04/rk3576-ufs-rockchip-Hard-reset-controller-on-init.patch
💤 Files with no reviewable changes (4)
- patch/u-boot/legacy/u-boot-radxa-rk35xx/add-board-nanopi-m5.patch
- patch/kernel/archive/rockchip64-6.18/dt/rk3576-nanopi-m5.dts
- patch/kernel/archive/rockchip64-7.0/dt/rk3576-nanopi-m5.dts
- patch/kernel/archive/rockchip64-7.1/dt/rk3576-nanopi-m5.dts
JEDEC LUN-id detection from sysfs, new case 9 (install to UFS) via write_uboot_platform_ufs, and UFS_EXCLUDE filter in check_partitions() so non-UFS install paths never offer UFS partitions as destinations.
da075a5 to
9f182b9
Compare
igorpecovnik
left a comment
There was a problem hiding this comment.
If it's tested and works, lets merge. No apparent problems at sigt.
I would only have comment on armbian-install part ... that whole thing has to be written from scratch in order that code becomes read-able. Currently is a big mess. Not a subject of this PR.
|
✅ This PR has been reviewed and approved — all set for merge! |
Summary
Migrate NanoPi M5 (RK3576) from the
u-boot-radxa-rk35xxlegacy fork to mainline U-Boot v2026.04 with UFS support, via a newvendor-spl-blobsBOOT_SCENARIO. Promotecurrent(kernel 6.18) to active target. Add UFS install path toarmbian-install.Family —
rockchip64vendor-spl-blobsBOOT_SCENARIO inconfig/sources/families/include/rockchip64_common.inc. DefaultVENDOR_SPL_PATHperBOOT_SOC(RK3576 →rk3576_spl_v1.08.bin).write_uboot_platform_ufsat family level (4 KiB LBA, idbloader on Boot LUN A @ 32 KiB,u-boot.itbon General LUN @ 8 MiB).lib/functions/compilation/uboot.sh: forwardwrite_uboot_platform_ufsinto the BSPplatform_install.shheredoc.U-Boot v2026.04
Top-level patches:
general-spl-Make-UFS-available-for-SPL-builds.patch(Y. Charkov v5 1/4)general-reset-rockchip-make-device-resets-available-in-SPL.patch(v5 2/4)general-ufs-rockchip-Add-device-reset-support.patch(v5 3/4)general-rockchip-spl-Add-support-for-booting-from-UFS.patch(v5 4/4 +bootph-pre-ramhunk)rk3576-arm64-dts-Explicitly-request-UFS-reset-pin.patch(Linux mainline79a3286e6182cherry-pick)rk3576-ufs-rockchip-Hard-reset-controller-on-init.patchBoard:
board_nanopi-m5/0001-arm64-dts-rockchip-enable-UFS-controller-NanoPi-M5.patch,0002-rockchip-rk3576-nanopi-m5-Enable-UFS-support.patch.Board —
nanopi-m5.confBOOT_SCENARIO="vendor-spl-blobs",BOOTSOURCE/BOOTBRANCH/BOOTPATCHDIR→v2026.04.KERNEL_TARGET="current,edge,vendor"(wasedge,vendor),KERNEL_TEST_TARGET="vendor,current".write_uboot_platform,write_uboot_platform_mtd,write_uboot_platform_ufshelpers.BOOT_TARGETSrewritten tommc0 scsi nvme pxe dhcpviapre_config_uboot_target.Kernel DT patches
current)board-nanopi-m5-add-wifi-bt-ufs-and-misc.patchedge)board-nanopi-m5-add-wifi-bt-and-misc.patchboard-nanopi-m5-add-wifi-bt-and-misc.patchAdds: RTL8822CS Wi-Fi (SDIO), Bluetooth (UART5 + flow control), GMAC RGMII delays, ADC back button, UART3/UART8. 6.18 also enables
&ufshc+ UFS regulators.armbian-install
write_uboot_platform_ufs.UFS_EXCLUDEfilter on bothlsblkpipelines incheck_partitions()so non-UFS install paths never offer UFS partitions as destinations.Removed
patch/u-boot/legacy/u-boot-radxa-rk35xx/add-board-nanopi-m5.patchpatch/kernel/archive/rockchip64-{6.18,7.0,7.1}/dt/rk3576-nanopi-m5.dts(replaced by patches)packages/blobs/nanopi-m5/rk3576_spl_v1.08.bin(now inarmbian/rkbinmaster, rkbin#44)Hardware validation
vendorcurrent(6.18)edge(7.0)Caveats
UFS and NVMe cannot host two coexisting Armbian installations on M5: with the bootloader on SPI, U-Boot proper iterates
BOOT_TARGETSmmc0 scsi nvme pxe dhcpandscsi(UFS) always wins overnvme. Use NVMe as data only, or wipe the General LUN's first 8 MiB (dd if=/dev/zero of=<general-lun> bs=4096 count=2048) to fall through.Summary by CodeRabbit
New Features
Improvements