Skip to content
Merged
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
105 changes: 53 additions & 52 deletions config/boards/orangepi5.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,70 @@ 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.07"
declare -g BOOTPATCHDIR="v2025.07"
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"
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
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 # 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=notrunc status=none
}
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"

function write_uboot_platform_mtd() {
flashcp -v -p "$1/u-boot-rockchip-spi.bin" /dev/mtd0
}
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
}


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

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
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_package() {
if [[ $BRANCH == "vendor" ]]; then
return
fi

if [[ -f "${uboottempdir}/.config.sata" ]]; then
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
fi
}

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 +92,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 +105,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 +120,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 +130,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 +149,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
}
33 changes: 22 additions & 11 deletions config/sources/families/include/rockchip64_common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -305,42 +305,53 @@ write_uboot_platform() {
fi
}

# @TODO: this is not ready for BOOT_SCENARIO=binman yet
write_uboot_platform_mtd() {
FILES=$(find "$1" -maxdepth 1 -type f -name "rkspi_loader*.img")
FILES=$(find "$1" -maxdepth 1 -type f \( -name "rkspi_loader*.img" -o -name "u-boot-rockchip-spi*.bin" \))
if [ -z "$FILES" ]; then
echo "No SPI image found."
exit 1
fi

MENU_ITEMS=()
i=1
FILE_ARRAY=()

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

# If there is only one image, we can skip the dialog
if [[ $i -eq 2 ]]; then
dd if=$1/${MENU_ITEMS[1]} of=$2 conv=notrunc status=none > /dev/null 2>&1
if [[ ! -t 1 || $i -eq 2 ]]; then
first_file="${FILE_ARRAY[0]}"
if [[ "$first_file" == *rkspi_loader*.img ]]; then
dd if="$first_file" of="$2" conv=notrunc status=none > /dev/null 2>&1
else
flashcp -v -p "$first_file" /dev/mtd0
fi
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)
--title "armbian-install" \
--backtitle "$backtitle" \
--radiolist "Choose SPI image:" 0 56 4 \
"${MENU_ITEMS[@]}" \
3>&1 1>&2 2>&3)
Comment on lines 321 to +345
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Restore valid dialog state flags

dialog --radiolist requires each entry to end in on or off. Handing it "" makes dialog/whiptail abort with “Expected state to be on/off”, so we drop straight into the “No SPI image chosen.” path and SPI flashing becomes impossible in an interactive session. Please reinstate explicit states (e.g. default the first item to on, the rest to off) before returning.

-		MENU_ITEMS+=("$i" "$filename" "")
+		state="off"
+		[[ $i -eq 1 ]] && state="on"
+		MENU_ITEMS+=("$i" "$filename" "$state")
📝 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
filename=$(basename "$file")
MENU_ITEMS+=("$i" "$filename" "")
FILE_ARRAY+=("$file")
((i++))
done <<< "$FILES"
# If there is only one image, we can skip the dialog
if [[ $i -eq 2 ]]; then
dd if=$1/${MENU_ITEMS[1]} of=$2 conv=notrunc status=none > /dev/null 2>&1
if [[ ! -t 1 || $i -eq 2 ]]; then
first_file="${FILE_ARRAY[0]}"
if [[ "$first_file" == *rkspi_loader*.img ]]; then
dd if="$first_file" of="$2" conv=notrunc status=none > /dev/null 2>&1
else
flashcp -v -p "$first_file" /dev/mtd0
fi
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)
--title "armbian-install" \
--backtitle "$backtitle" \
--radiolist "Choose SPI image:" 0 56 4 \
"${MENU_ITEMS[@]}" \
3>&1 1>&2 2>&3)
filename=$(basename "$file")
state="off"
[[ $i -eq 1 ]] && state="on"
MENU_ITEMS+=("$i" "$filename" "$state")
FILE_ARRAY+=("$file")
((i++))


if [ $? -eq 0 ]; then
dd if=$1/${MENU_ITEMS[($CHOICE*3)-2]} of=$2 conv=notrunc status=none > /dev/null 2>&1
idx=$((CHOICE-1))
chosen_file="${FILE_ARRAY[$idx]}"
if [[ "$chosen_file" == *rkspi_loader*.img ]]; then
dd if="$chosen_file" of="$2" conv=notrunc status=none > /dev/null 2>&1
else
flashcp -v -p "$chosen_file" /dev/mtd0
fi
else
echo "No SPI image chosen."
exit 1
Expand Down
Loading
Loading