Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 91 additions & 45 deletions config/boards/orangepi5.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,25 @@ BOOT_SPI_RKSPI_LOADER="yes"
IMAGE_PARTITION_TABLE="gpt"
declare -g UEFI_EDK2_BOARD_ID="orangepi-5" # This _only_ used for uefi-edk2-rk3588 extension

declare -g BLUETOOTH_HCIATTACH_PARAMS="-s 115200 /dev/ttyS9 bcm43xx 1500000" # For the bluetooth-hciattach extension
enable_extension "bluetooth-hciattach" # Enable the bluetooth-hciattach extension

# Mainline U-Boot for current kernel
function post_family_config_branch_current__orangepi5_use_mainline_uboot() {
function post_family_config__orangepi5_use_mainline_uboot() {
if [[ $BRANCH == "vendor" ]]; then
return
fi

display_alert "$BOARD" "Mainline U-Boot overrides for $BOARD - $BRANCH" "info"

declare -g BOOTCONFIG="orangepi-5-rk3588s_defconfig" # override the default for the board/family
declare -g BOOTDELAY=1 # Wait for UART interrupt to enter UMS/RockUSB mode etc
declare -g BOOTSOURCE="https://github.com/u-boot/u-boot.git" # We ❤️ mainline U-Boot
declare -g BOOTBRANCH="tag:v2025.01"
declare -g BOOTPATCHDIR="v2025.01"
declare -g BOOTBRANCH="tag:v2025.04"
declare -g BOOTPATCHDIR="v2025.04"
declare -g BOOTDIR="u-boot-${BOARD}" # do not share u-boot directory
declare -g UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin"
declare -g UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB} $BOOTCONFIG_SATA;;u-boot-rockchip-spi-sata.bin
BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB} $BOOTCONFIG;;u-boot-rockchip.bin u-boot-rockchip-spi.bin"
unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd # disable stuff from rockchip64_common; we're using binman here which does all the work already

# Just use the binman-provided u-boot-rockchip.bin, which is ready-to-go
Expand All @@ -35,17 +43,88 @@ function post_family_config_branch_current__orangepi5_use_mainline_uboot() {
}

function write_uboot_platform_mtd() {
flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0
FILES=$(find "$1" -maxdepth 1 -type f -name "u-boot-rockchip-spi*.bin")
if [ -z "$FILES" ]; then
echo "No SPI image found."
exit 1
fi

MENU_ITEMS=()
i=1

# Read the files into an array
while IFS= read -r file; do
filename=$(basename "$file")
MENU_ITEMS+=("$i" "$filename" "")
((i++))
done <<< "$FILES"

# If there is only one image or the terminal is not interactive, we can skip the dialog
if [[ ! -t 1 || $i -eq 2 ]]; then
flashcp -v -p "$1/${MENU_ITEMS[1]}" /dev/mtd0
return
fi

[[ -f /etc/armbian-release ]] && source /etc/armbian-release
backtitle="Armbian for $BOARD_NAME install script, https://www.armbian.com"

CHOICE=$(dialog --no-collapse \
--title "armbian-install" \
--backtitle $backtitle \
--radiolist "Choose SPI image:" 0 56 4 \
"${MENU_ITEMS[@]}" \
3>&1 1>&2 2>&3)

if [ $? -eq 0 ]; then
idx=$((CHOICE*3-2))
flashcp -v -p "$1/${MENU_ITEMS[$idx]}" /dev/mtd0
else
echo "No SPI image chosen."
exit 1
fi
}
}

function pre_config_uboot_target__orangepi5_patch_uboot_bootconfig_hack_for_sata() {
if [[ $BRANCH == "vendor" ]]; then
return
fi

display_alert "u-boot for ${BOARD}" "u-boot: hack bootconfig for sata spi image" "info"

declare -g BLUETOOTH_HCIATTACH_PARAMS="-s 115200 /dev/ttyS9 bcm43xx 1500000" # For the bluetooth-hciattach extension
enable_extension "bluetooth-hciattach" # Enable the bluetooth-hciattach extension
if [[ $target_make == *"orangepi-5-sata-rk3588s_defconfig"* ]]; then
BOOTCONFIG="orangepi-5-sata-rk3588s_defconfig"
target_make=${target_make/orangepi-5-sata-rk3588s_defconfig/}
else
BOOTCONFIG="orangepi-5-rk3588s_defconfig"
target_make=${target_make/orangepi-5-rk3588s_defconfig/}
fi
}
Comment on lines +88 to +102
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify SATA defconfig file existence and path handling.

The SATA configuration handling logic looks reasonable, but based on the past review comment, there may be an issue with the orangepi-5-sata-rk3588s_defconfig file not existing in the expected location.


🏁 Script executed:

#!/bin/bash
# Description: Check for SATA defconfig files in U-Boot source and package locations
echo "Searching for SATA defconfig files..."
fd -t f "orangepi-5-sata.*defconfig" .

echo "Checking if SATA defconfig exists in common U-Boot defconfig locations..."
fd -t f "*sata*defconfig" . | head -20

echo "Looking for Orange Pi 5 related defconfigs..."
fd -t f "*orangepi*5*defconfig" .

Length of output: 1056


🏁 Script executed:

#!/bin/bash
# Re-run fd with glob patterns to locate defconfig files

echo "Searching for the specific SATA defconfig for Orange Pi 5..."
fd -t f --glob "orangepi-5-sata*defconfig" .

echo "Searching for any defconfig files containing 'sata'..."
fd -t f --glob "*sata*defconfig" .

echo "Searching for all Orange Pi 5 defconfig files..."
fd -t f --glob "*orangepi*5*defconfig" .

Length of output: 489


Missing SATA defconfig: add or correct path

Our search didn’t find any orangepi-5-sata-rk3588s_defconfig (or any *sata*defconfig / *orangepi*5*defconfig) in the repo, so the patch logic will fail at runtime:

  • File: config/boards/orangepi5.conf (lines 88-102)
    References orangepi-5-sata-rk3588s_defconfig but no such file exists.

Please ensure the SATA defconfig is present (e.g. add orangepi-5-sata-rk3588s_defconfig to your U-Boot defconfigs directory) or update the script to use the correct defconfig name/path.

🤖 Prompt for AI Agents
In config/boards/orangepi5.conf around lines 88 to 102, the script references
the defconfig file "orangepi-5-sata-rk3588s_defconfig" which does not exist in
the repository, causing runtime failures. To fix this, either add the missing
"orangepi-5-sata-rk3588s_defconfig" file to the U-Boot defconfigs directory or
update the script to reference the correct existing SATA defconfig file name or
path that matches the repository contents.



function post_config_uboot_target__orangepi5_keep_sata_bootconfig() {
if [[ $BRANCH == "vendor" ]]; then
return
fi

display_alert "u-boot for ${BOARD}" "u-boot: hack bootconfig for sata spi image" "info"

if [[ $BOOTCONFIG == "orangepi-5-sata-rk3588s_defconfig" ]]; then
cp .config ${uboottempdir}/.config.sata
fi
}

function pre_package_uboot_image__orangepi5_copy_sataconfig_to_pacage() {
if [[ $BRANCH == "vendor" ]]; then
return
fi

run_host_command_logged cp ${uboottempdir}/.config.sata "$uboottempdir/usr/lib/u-boot/orangepi-5-sata-rk3588s_defconfig"
run_host_command_logged rm ${uboottempdir}/.config.sata
}
Comment on lines +117 to +124
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Potential issue with SATA config file handling.

The function assumes .config.sata exists when copying it to the package, but there's no check to ensure the file was actually created. This could cause the build to fail if the SATA configuration step didn't execute properly.

Add a check before copying the SATA config:

 function pre_package_uboot_image__orangepi5_copy_sataconfig_to_pacage() {
 	if [[ $BRANCH == "vendor" ]]; then
 		return
 	fi
 
+	# Only copy SATA config if it exists
+	if [[ ! -f "${uboottempdir}/.config.sata" ]]; then
+		display_alert "u-boot for ${BOARD}" "No SATA config found, skipping copy" "info"
+		return
+	fi
+
 	run_host_command_logged cp ${uboottempdir}/.config.sata "$uboottempdir/usr/lib/u-boot/orangepi-5-sata-rk3588s_defconfig"
 	run_host_command_logged rm ${uboottempdir}/.config.sata
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
function pre_package_uboot_image__orangepi5_copy_sataconfig_to_pacage() {
if [[ $BRANCH == "vendor" ]]; then
return
fi
run_host_command_logged cp ${uboottempdir}/.config.sata "$uboottempdir/usr/lib/u-boot/orangepi-5-sata-rk3588s_defconfig"
run_host_command_logged rm ${uboottempdir}/.config.sata
}
function pre_package_uboot_image__orangepi5_copy_sataconfig_to_pacage() {
if [[ $BRANCH == "vendor" ]]; then
return
fi
# Only copy SATA config if it exists
if [[ ! -f "${uboottempdir}/.config.sata" ]]; then
display_alert "u-boot for ${BOARD}" "No SATA config found, skipping copy" "info"
return
fi
run_host_command_logged cp ${uboottempdir}/.config.sata "$uboottempdir/usr/lib/u-boot/orangepi-5-sata-rk3588s_defconfig"
run_host_command_logged rm ${uboottempdir}/.config.sata
}
🤖 Prompt for AI Agents
In config/boards/orangepi5.conf around lines 117 to 124, the function
pre_package_uboot_image__orangepi5_copy_sataconfig_to_pacage assumes the file
.config.sata exists without verifying its presence, which may cause build
failures. Add a conditional check to verify that ${uboottempdir}/.config.sata
exists before attempting to copy it. If the file does not exist, skip the copy
and removal steps to prevent errors during the build process.


function post_family_tweaks_bsp__orangepi5_copy_usb2_service() {
if [[ $BRANCH == "edge" ]]; then
if [[ $BRANCH == "edge" || $BRANCH == "current" ]]; then
return
fi

Expand All @@ -58,7 +137,7 @@ function post_family_tweaks_bsp__orangepi5_copy_usb2_service() {
}

function post_family_tweaks__orangepi5_enable_usb2_service() {
if [[ $BRANCH == "edge" ]]; then
if [[ $BRANCH == "edge" || $BRANCH == "current" ]]; then
return
fi

Expand All @@ -71,7 +150,7 @@ function post_family_tweaks__orangepi5_enable_usb2_service() {
}

function post_family_tweaks__orangepi5_naming_audios() {
if [[ $BRANCH == "edge" ]]; then
if [[ $BRANCH == "edge" || $BRANCH == "current" ]]; then
return
fi

Expand All @@ -86,7 +165,7 @@ function post_family_tweaks__orangepi5_naming_audios() {
}

function post_family_config__orangepi5_uboot_add_sata_target() {
if [[ $BRANCH == "edge" ]]; then
if [[ $BRANCH == "edge" || $BRANCH == "current" ]]; then
return
fi

Expand All @@ -96,31 +175,8 @@ function post_family_config__orangepi5_uboot_add_sata_target() {
BL31=$RKBIN_DIR/$BL31_BLOB $BOOTCONFIG_SATA spl/u-boot-spl.bin u-boot.dtb u-boot.itb;; rkspi_loader_sata.img"
}

function post_family_config_branch_edge__uboot_config() {
display_alert "$BOARD" "u-boot ${BOOTBRANCH_BOARD} edge overrides" "info"
UBOOT_TARGET_MAP="BL31=${RKBIN_DIR}/${BL31_BLOB} ROCKCHIP_TPL=${RKBIN_DIR}/${DDR_BLOB};;u-boot-rockchip.bin u-boot-rockchip-spi.bin u-boot.itb idbloader.img idbloader-spi.img"
unset uboot_custom_postprocess write_uboot_platform write_uboot_platform_mtd # disable stuff from rockchip64_common; we're using binman here which does all the work already

# Just use the binman-provided u-boot-rockchip.bin, which is ready-to-go
function write_uboot_platform() {
dd if=${1}/u-boot-rockchip.bin of=${2} bs=32k seek=1 conv=fsync
}

# Smarter/faster/better to-spi writer using flashcp (hopefully with --partition), using the binman-provided 'u-boot-rockchip-spi.bin'
function write_uboot_platform_mtd() {
declare -a extra_opts_flashcp=("--verbose")
if flashcp -h | grep -q -e '--partition'; then
echo "Confirmed flashcp supports --partition -- read and write only changed blocks." >&2
extra_opts_flashcp+=("--partition")
else
echo "flashcp does not support --partition, will write full SPI flash blocks." >&2
fi
flashcp "${extra_opts_flashcp[@]}" "${1}/u-boot-rockchip-spi.bin" /dev/mtd0
}
}

function post_uboot_custom_postprocess__create_sata_spi_image() {
if [[ $BRANCH == "edge" ]]; then
if [[ $BRANCH == "edge" || $BRANCH == "current" ]]; then
return
fi

Expand All @@ -138,13 +194,3 @@ function post_uboot_custom_postprocess__create_sata_spi_image() {
dd if=idbloader.img of=rkspi_loader_sata.img seek=64 conv=notrunc
dd if=u-boot.itb of=rkspi_loader_sata.img seek=16384 conv=notrunc
}

function post_family_config_branch_edge__orangepi5_use_mainline_uboot() {
if [[ $BRANCH == "edge" ]]; then
BOOTCONFIG="orangepi-5-rk3588s_defconfig"
BOOTSOURCE="https://github.com/u-boot/u-boot.git"
BOOTBRANCH="commit:2f0282922b2c458eea7f85c500a948a587437b63"
BOOTDIR="u-boot-${BOARD}"
BOOTPATCHDIR="v2024.01/board_${BOARD}"
fi
}
7 changes: 4 additions & 3 deletions config/sources/families/include/rockchip64_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,8 @@ write_uboot_platform_mtd() {
((i++))
done <<< "$FILES"

# If there is only one image, we can skip the dialog
if [[ $i -eq 2 ]]; then
# If there is only one image or the terminal is not interactive, we can skip the dialog
if [[ ! -t 1 || $i -eq 2 ]]; then
dd if=$1/${MENU_ITEMS[1]} of=$2 conv=notrunc status=none > /dev/null 2>&1
return
fi
Expand All @@ -332,7 +332,8 @@ write_uboot_platform_mtd() {
3>&1 1>&2 2>&3)

if [ $? -eq 0 ]; then
dd if=$1/${MENU_ITEMS[($CHOICE*3)-2]} of=$2 conv=notrunc status=none > /dev/null 2>&1
idx=$((CHOICE*3-2))
dd if=$1/${MENU_ITEMS[$idx]} of=$2 conv=notrunc status=none > /dev/null 2>&1
else
echo "No SPI image chosen."
exit 1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Muhammed Efe Cetin <[email protected]>
Date: Sat, 26 Apr 2025 15:45:44 +0300
Subject: add sata dts and defconfig for OPi5

---
arch/arm/dts/rk3588s-orangepi-5-sata-u-boot.dtsi | 16 ++
configs/orangepi-5-sata-rk3588s_defconfig | 93 ++++++++++
dts/upstream/src/arm64/rockchip/rk3588s-orangepi-5-sata.dts | 33 ++++
3 files changed, 142 insertions(+)

diff --git a/arch/arm/dts/rk3588s-orangepi-5-sata-u-boot.dtsi b/arch/arm/dts/rk3588s-orangepi-5-sata-u-boot.dtsi
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/arch/arm/dts/rk3588s-orangepi-5-sata-u-boot.dtsi
@@ -0,0 +1,16 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3588s-u-boot.dtsi"
+#include "rk3588s-orangepi-5-u-boot.dtsi"
+
+/ {
+ chosen {
+ u-boot,spl-boot-order = "same-as-spl", &sdmmc;
+ };
+};
+
+&binman {
+ simple-bin-spi {
+ filename = "u-boot-rockchip-spi-sata.bin";
+ };
+};
\ No newline at end of file
diff --git a/configs/orangepi-5-sata-rk3588s_defconfig b/configs/orangepi-5-sata-rk3588s_defconfig
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/configs/orangepi-5-sata-rk3588s_defconfig
@@ -0,0 +1,93 @@
+CONFIG_ARM=y
+CONFIG_SKIP_LOWLEVEL_INIT=y
+CONFIG_COUNTER_FREQUENCY=24000000
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_SF_DEFAULT_SPEED=24000000
+CONFIG_SF_DEFAULT_MODE=0x2000
+CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3588s-orangepi-5-sata"
+CONFIG_ROCKCHIP_RK3588=y
+CONFIG_ROCKCHIP_SPI_IMAGE=y
+CONFIG_SPL_SERIAL=y
+CONFIG_TARGET_EVB_RK3588=y
+CONFIG_SYS_LOAD_ADDR=0xc00800
+CONFIG_SF_DEFAULT_BUS=5
+CONFIG_DEBUG_UART_BASE=0xFEB50000
+CONFIG_DEBUG_UART_CLOCK=24000000
+CONFIG_SPL_SPI_FLASH_SUPPORT=y
+CONFIG_SPL_SPI=y
+CONFIG_PCI=y
+CONFIG_DEBUG_UART=y
+CONFIG_AHCI=y
+CONFIG_FIT=y
+CONFIG_FIT_VERBOSE=y
+CONFIG_SPL_FIT_SIGNATURE=y
+CONFIG_SPL_LOAD_FIT=y
+CONFIG_LEGACY_IMAGE_FORMAT=y
+CONFIG_DEFAULT_FDT_FILE="rockchip/rk3588s-orangepi-5-sata.dtb"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_SPL_MAX_SIZE=0x40000
+CONFIG_SPL_PAD_TO=0x7f8000
+# CONFIG_SPL_RAW_IMAGE_SUPPORT is not set
+CONFIG_SPL_SPI_LOAD=y
+CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000
+CONFIG_SPL_ATF=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_GPT=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_MMC=y
+CONFIG_CMD_PCI=y
+CONFIG_CMD_USB=y
+# CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
+# CONFIG_SPL_DOS_PARTITION is not set
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_OF_LIVE=y
+CONFIG_OF_SPL_REMOVE_PROPS="clock-names interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
+CONFIG_SPL_DM_SEQ_ALIAS=y
+CONFIG_SPL_REGMAP=y
+CONFIG_SPL_SYSCON=y
+CONFIG_AHCI_PCI=y
+CONFIG_DWC_AHCI=y
+CONFIG_SPL_CLK=y
+CONFIG_ROCKCHIP_GPIO=y
+CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_MISC=y
+CONFIG_SUPPORT_EMMC_RPMB=y
+CONFIG_MMC_DW=y
+CONFIG_MMC_DW_ROCKCHIP=y
+CONFIG_SPI_FLASH_SFDP_SUPPORT=y
+CONFIG_SPI_FLASH_XMC=y
+CONFIG_PHY_MOTORCOMM=y
+CONFIG_DWC_ETH_QOS=y
+CONFIG_DWC_ETH_QOS_ROCKCHIP=y
+CONFIG_NVME_PCI=y
+CONFIG_PCIE_DW_ROCKCHIP=y
+CONFIG_PHY_ROCKCHIP_INNO_USB2=y
+CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y
+CONFIG_PHY_ROCKCHIP_USBDP=y
+CONFIG_SPL_PINCTRL=y
+CONFIG_PWM_ROCKCHIP=y
+CONFIG_SPL_RAM=y
+CONFIG_SCSI=y
+CONFIG_BAUDRATE=1500000
+CONFIG_DEBUG_UART_SHIFT=2
+CONFIG_SYS_NS16550_MEM32=y
+CONFIG_ROCKCHIP_SFC=y
+CONFIG_SYSRESET=y
+CONFIG_USB=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
+CONFIG_USB_DWC3=y
+CONFIG_USB_DWC3_GENERIC=y
+CONFIG_ERRNO_STR=y
+CONFIG_AHCI=y
+CONFIG_CMD_SCSI=y
+CONFIG_DM_SCSI=y
+CONFIG_DWC_AHCI=y
+CONFIG_LIBATA=y
+CONFIG_SCSI_AHCI=y
+CONFIG_SCSI=y
diff --git a/dts/upstream/src/arm64/rockchip/rk3588s-orangepi-5-sata.dts b/dts/upstream/src/arm64/rockchip/rk3588s-orangepi-5-sata.dts
new file mode 100644
index 000000000000..111111111111
--- /dev/null
+++ b/dts/upstream/src/arm64/rockchip/rk3588s-orangepi-5-sata.dts
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+/dts-v1/;
+
+#include "rk3588s-orangepi-5.dtsi"
+#include <dt-bindings/pinctrl/rockchip.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+ model = "Xunlong Orange Pi 5 (Sata)";
+ compatible = "xunlong,orangepi-5", "rockchip,rk3588s";
+};
+
+&sata0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&sata_reset>;
+ status = "okay";
+
+ phys = <&combphy0_ps PHY_TYPE_SATA>;
+ phy-names = "sata-phy";
+};
+
+&sfc {
+ status = "okay";
+};
+
+&pinctrl {
+ sata {
+ sata_reset: sata-reset {
+ rockchip,pins = <3 RK_PD1 RK_FUNC_GPIO &pcfg_pull_up>;
+ };
+ };
+};
--
Armbian