From 2d73b5830a60c1e44b2f2140a029e76c38da7c40 Mon Sep 17 00:00:00 2001 From: Muhammed Efe Cetin Date: Sat, 26 Apr 2025 13:44:50 +0300 Subject: [PATCH] rockchip64: add multiple SPI images support to armbian-install --- .../families/include/rockchip64_common.inc | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/config/sources/families/include/rockchip64_common.inc b/config/sources/families/include/rockchip64_common.inc index ff10d70070..ce0e09ce44 100644 --- a/config/sources/families/include/rockchip64_common.inc +++ b/config/sources/families/include/rockchip64_common.inc @@ -299,10 +299,42 @@ write_uboot_platform() { # @TODO: this is not ready for BOOT_SCENARIO=binman yet write_uboot_platform_mtd() { - if [[ -f $1/rkspi_loader.img ]]; then - dd if=$1/rkspi_loader.img of=$2 conv=notrunc status=none > /dev/null 2>&1 + FILES=$(find "$1" -maxdepth 1 -type f -name "rkspi_loader*.img") + 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, 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 + 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 + dd if=$1/${MENU_ITEMS[($CHOICE*3)-2]} of=$2 conv=notrunc status=none > /dev/null 2>&1 else - echo "SPI u-boot image not found!" + echo "No SPI image chosen." exit 1 fi }