Skip to content

Conversation

@dust-7
Copy link
Contributor

@dust-7 dust-7 commented Feb 10, 2026

Description

This PR enables generation of u-boot-rockchip-spi-sata.bin. Flashing this to SPI flash enables U-Boot to communicate with an attached SATA m.2 SSD, thereby allowing booting directly from SPI flash to SATA SSD.

The method for creating the secondary spi image is copied from orangepi5.conf.

The only change in the SATA defconfig is the addition of CONFIG_DWC_AHCI=y.

Quickstart for SATA SSD users

  1. Flash image to SD card and boot.
  2. Enable rockchip-rk3566-sata2 overlay and reboot.
  3. From terminal, run nand-sata-install.
  4. Select option Boot from MTD Flash - system on SATA, USB or NVMe.
  5. After system is copied over to SSD, there will be a prompt to choose SPI image. Select u-boot-rockchip-spi-sata.bin.
  6. Poweroff, remove SD card, enjoy!

How Has This Been Tested?

  • Followed steps in quickstart above, works.
  • From U-Boot command line, bootflow scan succcessfully detects boot.scr on SCSI bootdev.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features
    • Orange Pi 3B now supports SATA/AHCI boot (M.2 SSD): device configuration, boot-image selection and packaging updated to automatically handle SATA-enabled and non‑SATA setups, providing correct boot paths and fallback behavior.
  • Compatibility
    • Board device configuration now conditionally enables SATA hardware when present and falls back to the prior PCIe setup when not.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Add SATA boot support for Orange Pi 3B: new BOOTCONFIG_SATA and build hooks in the board config, device-tree/binman changes to gate AHCI/SATA, and a new u-boot defconfig enabling AHCI/SCSI/PCI and related drivers for SATA boot.

Changes

Cohort / File(s) Summary
Board config & hooks
config/boards/orangepi3b.csc
Add BOOTCONFIG_SATA, modify UBOOT_TARGET_MAP to reference SATA/non‑SATA bootconfigs, and add three hooks to select, save (.config.sata), and copy SATA-specific .config into packages.
U-Boot board/device-tree patch
patch/u-boot/v2026.01/board_orangepi3b/0003-rk3566-orangepi-3b-enable-boot-from-sata.patch
Introduce CONFIG_DWC_AHCI‑guarded changes: add binman SPI-backed SATA image entry when AHCI enabled, enable SATA2 regulator/boot-on wiring under AHCI, and provide PCIe fallback when AHCI is absent.
New defconfig
patch/u-boot/v2026.01/defconfig/orangepi-3b-sata-rk3566_defconfig
Add a new rk3566 Orange Pi 3B SATA defconfig enabling RK3566/ROCKCHIP options, SPL/FIT, AHCI/SCSI, PCI, USB, device-tree list entries, and many drivers/boot parameters for SATA booting.

Sequence Diagram(s)

sequenceDiagram
  participant Builder as Build System
  participant Hooks as orangepi3b.csc hooks
  participant UBoot as U-Boot build
  participant DT as Device Tree / binman
  participant Pack as Packaging

  Builder->>Hooks: start pre-config
  Hooks->>Hooks: detect target_make for orangepi-3b-sata
  Hooks-->>Builder: set BOOTCONFIG_SATA and adjust target_make
  Builder->>UBoot: build U-Boot with chosen BOOTCONFIG
  UBoot->>DT: include SATA/binman entries if CONFIG_DWC_AHCI
  UBoot-->>Hooks: post-config (save .config or .config.sata)
  Builder->>Hooks: pre-package
  Hooks->>Pack: copy .config.sata into package (if present)
  Pack-->>Builder: produce final u-boot package
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibbled code beneath the tree,

Pulled SATA threads and set them free,
DT leaves rustled, hooks hopped in place,
Orange Pi wakes with a SATA grace,
I twitch my whiskers — build success, hooray!

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective: enabling SATA boot by generating an alternate SPI U-Boot image for Orange Pi 3B.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

🧹 Recent nitpick comments
config/boards/orangepi3b.csc (1)

30-55: Hook implementation correctly matches orangepi5 pattern.

The three hooks implement the build flow correctly and follow the established pattern across similar boards (orangepi5, nanopi-m6): bare cp saves the config during post_config_uboot_target, then run_host_command_logged handles packaging operations. This pattern distinction is consistent throughout the codebase and does not require changes.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added size/medium PR with more then 50 and less then 250 lines 02 Milestone: First quarter release Needs review Seeking for review Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Feb 10, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@config/boards/orangepi3b.csc`:
- Around line 30-40: In function
pre_config_uboot_target__orangepi3b_patch_uboot_bootconfig_hack_for_sata, fix
the whitespace on the BOOTCONFIG assignment line so it uses tabs only (matching
the rest of the function) instead of the current leading spaces+tab; ensure all
lines that set BOOTCONFIG and modify target_make use consistent tab indentation
to remove the minor whitespace inconsistency.
🧹 Nitpick comments (2)
config/boards/orangepi3b.csc (2)

42-48: Post-config hook saves SATA .config — consider quoting the path.

The cp .config ${uboottempdir}/.config.sata on Line 46 leaves ${uboottempdir} unquoted. If the path ever contains spaces, this would break. Minor defensive coding suggestion.

Suggested fix
-		cp .config ${uboottempdir}/.config.sata
+		cp .config "${uboottempdir}/.config.sata"

50-55: Packaging hook: same quoting concern for ${uboottempdir}.

Both cp and rm commands on Lines 51-53 leave ${uboottempdir} unquoted. For consistency and robustness:

Suggested fix
-	if [[ -f "${uboottempdir}/.config.sata" ]]; then
-		run_host_command_logged cp ${uboottempdir}/.config.sata "$uboottempdir/usr/lib/u-boot/orangepi-3b-sata-rk3566_defconfig"
-		run_host_command_logged rm ${uboottempdir}/.config.sata
+	if [[ -f "${uboottempdir}/.config.sata" ]]; then
+		run_host_command_logged cp "${uboottempdir}/.config.sata" "${uboottempdir}/usr/lib/u-boot/orangepi-3b-sata-rk3566_defconfig"
+		run_host_command_logged rm "${uboottempdir}/.config.sata"
 	fi

This commit enables generation of `u-boot-rockchip-spi-sata.bin`.
Flashing this to SPI flash enables U-Boot to communicate with an
attached SATA m.2 SSD, thereby allowing booting directly from SPI flash
to SATA SSD.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

02 Milestone: First quarter release Hardware Hardware related like kernel, U-Boot, ... Needs review Seeking for review Patches Patches related to kernel, U-Boot, ... size/medium PR with more then 50 and less then 250 lines

Development

Successfully merging this pull request may close these issues.

1 participant