From 1f9c554fb06b4a145cd9448f2ba1353ee81e9887 Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Sat, 13 Sep 2025 20:13:20 +0300 Subject: [PATCH] rockchip64: support binman images in write_uboot_platform_mtd --- config/boards/orangepi5.conf | 49 +------------------ .../families/include/rockchip64_common.inc | 32 +++++++----- 2 files changed, 22 insertions(+), 59 deletions(-) diff --git a/config/boards/orangepi5.conf b/config/boards/orangepi5.conf index 28f38c4e0..0d1e996ba 100644 --- a/config/boards/orangepi5.conf +++ b/config/boards/orangepi5.conf @@ -35,54 +35,7 @@ function post_family_config__orangepi5_use_mainline_uboot() { 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} $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 - function write_uboot_platform() { - dd "if=$1/u-boot-rockchip.bin" "of=$2" bs=32k seek=1 conv=notrunc status=none - } - - function write_uboot_platform_mtd() { - 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 - } + unset uboot_custom_postprocess # disable stuff from rockchip64_common; we're using binman here which does all the work already } function pre_config_uboot_target__orangepi5_patch_uboot_bootconfig_hack_for_sata() { diff --git a/config/sources/families/include/rockchip64_common.inc b/config/sources/families/include/rockchip64_common.inc index d39ec5599..508ac1fa8 100644 --- a/config/sources/families/include/rockchip64_common.inc +++ b/config/sources/families/include/rockchip64_common.inc @@ -305,9 +305,8 @@ 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 @@ -315,17 +314,23 @@ write_uboot_platform_mtd() { 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 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 + 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 @@ -333,15 +338,20 @@ write_uboot_platform_mtd() { 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) if [ $? -eq 0 ]; then - idx=$((CHOICE*3-2)) - dd if=$1/${MENU_ITEMS[$idx]} 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