Add Rockchip u-boot "binman" BOOT_SCENARIO (#7505)

* rockchip64: add `BOOT_SCENARIO=binman` for mainline u-boot

- drop special handling for 3308's `legacy` branch
- rpardini: note how SPI/mtd is not yet supported for this scenario

Co-authored-by: Ricardo Pardini <ricardo@pardini.net> (squash/splits, shellfmt)

* `rock-s0`/`rockpi-s`: use `BOOT_SCENARIO=binman`; move blobs to armbian/rkbin

- Move rk3308 boot blobs to armbian/rkbin
  - delete obsolete ones
- Alter rock-s0 and rockpi-s to use the new "binman" BOOT_SCENARIO

Co-authored-by: Ricardo Pardini <ricardo@pardini.net> (shellfmt; small fixes; squashes)
This commit is contained in:
brentr
2024-11-22 23:31:39 -08:00
committed by GitHub
parent cc4513958f
commit fc54623c4a
6 changed files with 149 additions and 121 deletions

View File

@@ -1,13 +1,32 @@
# Rockchip RK3308 quad core 512MB SoC WiFi # Rockchip RK3308 quad core 512MB SoC WiFi
# https://radxa.com/products/rocks/s0 # https://radxa.com/products/rocks/s0
# This board is very similar to the older RockPi-S model
source "${SRC}/config/boards/rockpi-s.conf"
BOARD_NAME="Rock S0" BOARD_NAME="Rock S0"
BOARD_MAINTAINER="brentr" BOARDFAMILY=rockchip64
BOARDFAMILY="rockchip64" BOARD_MAINTAINER=brentr
BOOTCONFIG="rock-s0-rk3308_defconfig"
BOOT_FDT_FILE="rockchip/rk3308-rock-s0.dtb" BOOTCONFIG=rock-s0-rk3308_defconfig
KERNEL_TARGET="current,edge" BOOT_FDT_FILE=rockchip/rk3308-rock-s0.dtb
KERNEL_TEST_TARGET="current"
KERNEL_TARGET=current,edge
KERNEL_TEST_TARGET=current
DEFAULT_CONSOLE=serial
SERIALCON=ttyS0
MODULES_BLACKLIST="rockchipdrm analogix_dp dw_mipi_dsi dw_hdmi gpu_sched lima hantro_vpu panfrost"
HAS_VIDEO_OUTPUT=no
BOOTBRANCH_BOARD=tag:v2024.10
BOOTPATCHDIR=v2024.10
BOOT_SCENARIO=binman
DDR_BLOB=rk33/rk3308_ddr_589MHz_uart0_m0_v2.07.bin
BL31_BLOB=rk33/rk3308_bl31_v2.26.elf
OVERLAY_PREFIX=rk3308
function post_family_config__rocks0() {
declare -g BOOTDIR="u-boot-${BOARD}"
declare -g BOOTSCRIPT=boot-rockchip64-ttyS0.cmd:boot.cmd
unset family_tweaks_bsp # disable from rockchip64_common
}

View File

@@ -1,66 +1,35 @@
# Rockchip RK3308 quad core 256-512MB SoC WiFi # Rockchip RK3308 quad core 256-512MB SoC WiFi
# https://radaxa.com/products/rockpi/pis # https://radxa.com/products/rockpi/pis
BOARD_NAME="Rockpi S" BOARD_NAME="Rockpi S"
BOARDFAMILY="rockchip64" BOARDFAMILY=rockchip64
BOARD_MAINTAINER="brentr" BOARD_MAINTAINER=brentr
BOOTCONFIG="rock-pi-s-rk3308_defconfig"
BOOT_FDT_FILE="rockchip/rk3308-rock-pi-s.dtb"
DEFAULT_CONSOLE="serial" BOOTCONFIG=rock-pi-s-rk3308_defconfig
SERIALCON="ttyS0" BOOT_FDT_FILE=rockchip/rk3308-rock-pi-s.dtb
KERNEL_TARGET="current,edge"
KERNEL_TEST_TARGET="current" KERNEL_TARGET=current,edge
KERNEL_TEST_TARGET=current
DEFAULT_CONSOLE=serial
SERIALCON=ttyS0
MODULES_BLACKLIST="rockchipdrm analogix_dp dw_mipi_dsi dw_hdmi gpu_sched lima hantro_vpu panfrost" MODULES_BLACKLIST="rockchipdrm analogix_dp dw_mipi_dsi dw_hdmi gpu_sched lima hantro_vpu panfrost"
HAS_VIDEO_OUTPUT="no" HAS_VIDEO_OUTPUT=no
BOOTBRANCH_BOARD="tag:v2022.04"
BOOTPATCHDIR="u-boot-rockchip64-v2022.04"
OVERLAY_PREFIX='rk3308' BOOTBRANCH_BOARD=tag:v2024.10
BOOTPATCHDIR=v2024.10
BOOT_SCENARIO=binman
DDR_BLOB=rk33/rk3308_ddr_589MHz_uart0_m0_v2.07.bin
BL31_BLOB=rk33/rk3308_bl31_v2.26.elf
#comment out line below for an image that will NOT boot from the built-in SDNAND OVERLAY_PREFIX=rk3308
IDBLOADER_BLOB=$SRC/packages/blobs/rockchip/rk3308_idbloader_ddr589MHz_uart0_m0_v2.06.136sd.bin
#The SDNAND capabilty IDBLOADER_BLOB requires the U-Boot and Linux serial console on UART0 function post_family_config__rockpis() {
#Linux will hang on reboot if the console remains on UART2 declare -g BOOTDIR="u-boot-${BOARD}"
declare -g BOOTSCRIPT=boot-rockchip64-ttyS0.cmd:boot.cmd
#Note: IDBLOADER_BLOB is derived from
# https://dl.radxa.com/rockpis/images/loader/rk3308_loader_ddr589MHz_uart0_m0_v2.06.136sd.bin
#by using the rkdeveloptool to "upgrade" the previous DDR_BLOB loader on the SDNAND
#To recreate it, build the image with IDBLOADER_BLOB unset and boot Rock PI-S in MASKROM mode
#On your host (connected to the RockPi-S's USB-C port):
# rdeveloptool db rk3308_loader_ddr589MHz_uart0_m0_v2.06.136sd.bin
# rdeveloptool wl 0 newly_built_image.img
# rdeveloptool ul rk3308_loader_ddr589MHz_uart0_m0_v2.06.136sd.bin #this writes 280 sectors
#Then, reset the RockPi-S to boot from SDNAND. Using that running image:
# dd if=/dev/mmcblk0 of=rk3308_idbloader_ddr589MHz_uart0_m0_v2.06.136sd.bin skip=64 count=280
function post_family_config___uboot_config() {
display_alert "$BOARD" "u-boot ${BOOTBRANCH_BOARD} overrides" "info"
unset uboot_custom_postprocess family_tweaks_bsp # disable stuff from rockchip64_common
BOOTSCRIPT=boot-rockchip64-ttyS0.cmd:boot.cmd
uboot_custom_postprocess() {
# TODO: remove this diversion from common caused by different loaderimage params
run_host_x86_binary_logged $RKBIN_DIR/tools/loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x600000 --size 1024 1 &&
if [ -r "$IDBLOADER_BLOB" ]; then
echo "Installing $IDBLOADER_BLOB"
echo "Capable of booting from built-in SDNAND"
cp $IDBLOADER_BLOB idbloader.bin
else
[ "$IDBLOADER_BLOB" ] && echo "Missing $IDBLOADER_BLOB"
echo "WARNING: This image will not boot from built-in SDNAND"
tools/mkimage -n rk3308 -T rksd -d $RKBIN_DIR/$DDR_BLOB idbloader.bin &&
cat $RKBIN_DIR/$MINILOADER_BLOB >> idbloader.bin
fi &&
run_host_x86_binary_logged $RKBIN_DIR/tools/trust_merger --replace bl31.elf $RKBIN_DIR/$BL31_BLOB trust.ini
}
family_tweaks_bsp() { #Install udev script that derives fixed, unique MAC addresses for net interfaces
family_tweaks_bsp() { #overrides rockchip64_common.inc
#Install udev script that derives fixed, unique MAC addresses for net interfaces
#that are assigned random ones -- like RockPI-S's WiFi network interfaces #that are assigned random ones -- like RockPI-S's WiFi network interfaces
bsp=$SRC/packages/bsp/rockpis bsp=$SRC/packages/bsp/rockpis
rules=etc/udev/rules.d rules=etc/udev/rules.d
@@ -68,7 +37,6 @@ function post_family_config___uboot_config() {
install -m 755 $bsp/lib/udev/fixEtherAddr $destination/lib/udev && install -m 755 $bsp/lib/udev/fixEtherAddr $destination/lib/udev &&
install -m 644 $bsp/$rules/05-fixMACaddress.rules $destination/$rules install -m 644 $bsp/$rules/05-fixMACaddress.rules $destination/$rules
} }
} }
function pre_install_kernel_debs__enforce_cma() { function pre_install_kernel_debs__enforce_cma() {

View File

@@ -56,6 +56,7 @@ esac
# - tpl-spl-blob: uses mainline u-boot TPL and SPL with proprietary rockchip ATF blob # - tpl-spl-blob: uses mainline u-boot TPL and SPL with proprietary rockchip ATF blob
# - tpl-blob-atf-mainline: proprietary rockchip ddrbin + mainline u-boot SPL + mainline ATF # - tpl-blob-atf-mainline: proprietary rockchip ddrbin + mainline u-boot SPL + mainline ATF
# - blobless: mainline u-boot TPL + mainline u-boot SPL + mainline ATF # - blobless: mainline u-boot TPL + mainline u-boot SPL + mainline ATF
# - binman: u-boot builds full boot image from information in device tree. See: https://docs.u-boot.org/en/latest/develop/package/binman.html
#BOOT_SOC=`expr $BOOTCONFIG : '.*\(rk[[:digit:]]\+.*\)_.*'` #BOOT_SOC=`expr $BOOTCONFIG : '.*\(rk[[:digit:]]\+.*\)_.*'`
BOOT_SOC=${BOOT_SOC:=$(expr $BOOTCONFIG : '.*\(rk[[:digit:]]\+.*\)_.*' || true)} BOOT_SOC=${BOOT_SOC:=$(expr $BOOTCONFIG : '.*\(rk[[:digit:]]\+.*\)_.*' || true)}
@@ -80,12 +81,6 @@ case "$BOOT_SOC" in
DDR_BLOB="${DDR_BLOB:-"rk33/rk3308_ddr_589MHz_uart2_m1_v1.30.bin"}" DDR_BLOB="${DDR_BLOB:-"rk33/rk3308_ddr_589MHz_uart2_m1_v1.30.bin"}"
MINILOADER_BLOB="${MINILOADER_BLOB:-"rk33/rk3308_miniloader_v1.22.bin"}" MINILOADER_BLOB="${MINILOADER_BLOB:-"rk33/rk3308_miniloader_v1.22.bin"}"
BL31_BLOB="${BL31_BLOB:-"rk33/rk3308_bl31_v2.22.elf"}" BL31_BLOB="${BL31_BLOB:-"rk33/rk3308_bl31_v2.22.elf"}"
if [[ ${BRANCH} == legacy ]]; then
DDR_BLOB="${DDR_BLOB:-"rk33/rk3308_ddr_589MHz_uart2_m0_v1.26.bin"}"
MINILOADER_BLOB="${MINILOADER_BLOB:-"rk33/rk3308_miniloader_sd_nand_v1.13.bin"}"
BL31_BLOB="${BL31_BLOB:-"rk33/rk3308_bl31_v2.10.elf"}"
fi
;; ;;
rk3328) rk3328)
@@ -157,9 +152,12 @@ case "$BOOT_SOC" in
esac esac
prepare_boot_configuration() { prepare_boot_configuration() {
ATFSOURCE=''
ATF_COMPILE='no'
case "$BOOT_SCENARIO" in case "$BOOT_SCENARIO" in
blobless | tpl-blob-atf-mainline) blobless | tpl-blob-atf-mainline)
UBOOT_TARGET_MAP="BL31=bl31.elf idbloader.img u-boot.itb;;idbloader.img u-boot.itb" UBOOT_TARGET_MAP="BL31=bl31.elf idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATF_COMPILE=yes
ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware' ATFSOURCE='https://github.com/ARM-software/arm-trusted-firmware'
ATF_COMPILER='aarch64-linux-gnu-' ATF_COMPILER='aarch64-linux-gnu-'
ATFDIR='arm-trusted-firmware' ATFDIR='arm-trusted-firmware'
@@ -171,22 +169,17 @@ prepare_boot_configuration() {
[[ $BOOT_SCENARIO == tpl-blob-atf-mainline ]] && [[ $BOOT_SCENARIO == tpl-blob-atf-mainline ]] &&
UBOOT_TARGET_MAP="BL31=bl31.elf idbloader.img u-boot.itb;;idbloader.img u-boot.itb" UBOOT_TARGET_MAP="BL31=bl31.elf idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
;; ;;
tpl-spl-blob) tpl-spl-blob)
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB idbloader.img u-boot.itb;;idbloader.img u-boot.itb" UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB idbloader.img u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE=''
ATF_COMPILE='no'
;; ;;
spl-blobs) spl-blobs)
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB spl/u-boot-spl.bin u-boot.dtb u-boot.itb;;idbloader.img u-boot.itb" UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB spl/u-boot-spl.bin u-boot.dtb u-boot.itb;;idbloader.img u-boot.itb"
ATFSOURCE=''
ATF_COMPILE='no'
;; ;;
only-blobs) only-blobs)
UBOOT_TARGET_MAP="u-boot-dtb.bin;;idbloader.bin uboot.img trust.bin" UBOOT_TARGET_MAP="u-boot-dtb.bin;;idbloader.bin uboot.img trust.bin"
ATFSOURCE='' ;;
ATF_COMPILE='no' binman)
UBOOT_TARGET_MAP="BL31=$RKBIN_DIR/$BL31_BLOB ROCKCHIP_TPL=$RKBIN_DIR/$DDR_BLOB;;u-boot-rockchip.bin"
;; ;;
esac esac
@@ -206,17 +199,22 @@ prepare_boot_configuration() {
} }
uboot_custom_postprocess() { uboot_custom_postprocess() {
[[ -z ${BOOT_SOC} ]] && exit_with_error "BOOT_SOC not defined for scenario '${BOOT_SCENARIO}' for BOARD'=${BOARD}' and BOOTCONFIG='${BOOTCONFIG}'" [[ -z ${BOOT_SOC} ]] &&
exit_with_error "BOOT_SOC not defined for scenario '${BOOT_SCENARIO}' for BOARD'=${BOARD}' and BOOTCONFIG='${BOOTCONFIG}'"
display_alert "${BOARD}" "boots with ${BOOT_SCENARIO} scenario" "info"
if [[ $BOOT_SCENARIO == "blobless" || $BOOT_SCENARIO == "tpl-spl-blob" ]]; then case "$BOOT_SCENARIO" in
blobless | tpl-spl-blob | binman)
: :
elif [[ $BOOT_SCENARIO == "spl-blobs" || $BOOT_SCENARIO == "tpl-blob-atf-mainline" ]]; then ;;
spl-blobs | tpl-blob-atf-mainline)
# Bomb if DDR_BLOB not defined or does not exist # Bomb if DDR_BLOB not defined or does not exist
declare SPL_BIN_PATH="${RKBIN_DIR}/${DDR_BLOB}" declare SPL_BIN_PATH="${RKBIN_DIR}/${DDR_BLOB}"
[[ -z ${SPL_BIN_PATH} ]] && exit_with_error "DDR_BLOB not defined for scenario ${BOOT_SCENARIO}" [[ -z ${SPL_BIN_PATH} ]] && exit_with_error "DDR_BLOB not defined for scenario ${BOOT_SCENARIO}"
[[ ! -f "${SPL_BIN_PATH}" ]] && exit_with_error "DDR_BLOB ${SPL_BIN_PATH} does not exist for scenario ${BOOT_SCENARIO}" [[ ! -f "${SPL_BIN_PATH}" ]] && exit_with_error "DDR_BLOB ${SPL_BIN_PATH} does not exist for scenario ${BOOT_SCENARIO}"
if [[ $BOOT_SOC == "rk3576" ]]; then if [[ "$BOOT_SOC" == "rk3576" ]]; then
display_alert "boot_merger for '${BOOT_SOC}' for scenario ${BOOT_SCENARIO}" "SPL_BIN_PATH: ${SPL_BIN_PATH}" "debug" display_alert "boot_merger for '${BOOT_SOC}' for scenario ${BOOT_SCENARIO}" "SPL_BIN_PATH: ${SPL_BIN_PATH}" "debug"
RKBOOT_INI_FILE=rk3576.ini RKBOOT_INI_FILE=rk3576.ini
cp $RKBIN_DIR/rk35/RK3576MINIALL.ini $RKBOOT_INI_FILE cp $RKBIN_DIR/rk35/RK3576MINIALL.ini $RKBOOT_INI_FILE
@@ -232,19 +230,21 @@ uboot_custom_postprocess() {
display_alert "mkimage for '${BOOT_SOC}' for scenario ${BOOT_SCENARIO}" "SPL_BIN_PATH: ${SPL_BIN_PATH}" "debug" display_alert "mkimage for '${BOOT_SOC}' for scenario ${BOOT_SCENARIO}" "SPL_BIN_PATH: ${SPL_BIN_PATH}" "debug"
run_host_command_logged tools/mkimage -n "${BOOT_SOC_MKIMAGE}" -T rksd -d "${SPL_BIN_PATH}:spl/u-boot-spl.bin" idbloader.img run_host_command_logged tools/mkimage -n "${BOOT_SOC_MKIMAGE}" -T rksd -d "${SPL_BIN_PATH}:spl/u-boot-spl.bin" idbloader.img
fi fi
;;
elif [[ $BOOT_SCENARIO == "only-blobs" ]]; then only-blobs)
local tempfile local tempfile
tempfile=$(mktemp) tempfile=$(mktemp)
run_host_command_logged tools/mkimage -n "${BOOT_SOC_MKIMAGE}" -T rksd -d $RKBIN_DIR/$DDR_BLOB idbloader.bin run_host_command_logged tools/mkimage -n "${BOOT_SOC_MKIMAGE}" -T rksd -d $RKBIN_DIR/$DDR_BLOB idbloader.bin
cat $RKBIN_DIR/$MINILOADER_BLOB >> idbloader.bin cat $RKBIN_DIR/$MINILOADER_BLOB >> idbloader.bin
run_host_x86_binary_logged $RKBIN_DIR/tools/loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000 run_host_x86_binary_logged $RKBIN_DIR/tools/loaderimage --pack --uboot ./u-boot-dtb.bin uboot.img 0x200000
run_host_x86_binary_logged $RKBIN_DIR/tools/trust_merger --replace bl31.elf $RKBIN_DIR/$BL31_BLOB trust.ini run_host_x86_binary_logged $RKBIN_DIR/tools/trust_merger --replace bl31.elf $RKBIN_DIR/$BL31_BLOB trust.ini
;;
else *)
exit_with_error "Unsupported u-boot processing configuration!" exit_with_error "\"$BOOT_SCENARIO\" is an Unsupported Boot Scenario!"
fi ;;
esac
if [[ $BOOT_SUPPORT_SPI == yes ]]; then if [[ $BOOT_SUPPORT_SPI == yes ]]; then
if [[ "${BOOT_SPI_RKSPI_LOADER:-"no"}" == "yes" ]]; then if [[ "${BOOT_SPI_RKSPI_LOADER:-"no"}" == "yes" ]]; then
@@ -273,9 +273,11 @@ write_uboot_platform() {
local logging_prelude="" local logging_prelude=""
[[ $(type -t run_host_command_logged) == function ]] && logging_prelude="run_host_command_logged" [[ $(type -t run_host_command_logged) == function ]] && logging_prelude="run_host_command_logged"
if [[ -f $1/rksd_loader.img ]]; then # legacy rk3399 loader if [ -f $1/u-boot-rockchip.bin ]; then #"$BOOT_SCENARIO" == binman
${logging_prelude} dd if=$1/u-boot-rockchip.bin of=$2 bs=32k seek=1 conv=notrunc status=none
elif [ -f $1/rksd_loader.img ]; then # legacy rk3399 loader
${logging_prelude} dd if=$1/rksd_loader.img of=$2 seek=64 conv=notrunc status=none ${logging_prelude} dd if=$1/rksd_loader.img of=$2 seek=64 conv=notrunc status=none
elif [[ -f $1/u-boot.itb ]]; then # $BOOT_SCENARIO == "blobless" || $BOOT_SCENARIO == "tpl-spl-blob" elif [[ -f $1/u-boot.itb ]]; then # $BOOT_SCENARIO "blobless" or "tpl-spl-blob"
${logging_prelude} dd if=$1/idbloader.img of=$2 seek=64 conv=notrunc status=none ${logging_prelude} dd if=$1/idbloader.img of=$2 seek=64 conv=notrunc status=none
${logging_prelude} dd if=$1/u-boot.itb of=$2 seek=16384 conv=notrunc status=none ${logging_prelude} dd if=$1/u-boot.itb of=$2 seek=16384 conv=notrunc status=none
elif [[ -f $1/uboot.img ]]; then # $BOOT_SCENARIO == "only-blobs" elif [[ -f $1/uboot.img ]]; then # $BOOT_SCENARIO == "only-blobs"
@@ -288,16 +290,13 @@ write_uboot_platform() {
fi fi
} }
# @TODO: this is not ready for BOOT_SCENARIO=binman yet
write_uboot_platform_mtd() { write_uboot_platform_mtd() {
if [[ -f $1/rkspi_loader.img ]]; then if [[ -f $1/rkspi_loader.img ]]; then
dd if=$1/rkspi_loader.img of=$2 conv=notrunc status=none > /dev/null 2>&1 dd if=$1/rkspi_loader.img of=$2 conv=notrunc status=none > /dev/null 2>&1
else else
echo "SPI u-boot image not found!" echo "SPI u-boot image not found!"
exit 1 exit 1
fi fi
} }

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Brent Roman <genosenosor@gmail.com>
Date: Sat, 16 Nov 2024 20:50:41 -0800
Subject: Ensure Rock S0 v1.1 boards u-boot SPL can access MMC card
Signed-off-by: Brent Roman <genosenosor@gmail.com>
---
arch/arm/dts/rk3308-rock-s0-u-boot.dtsi | 15 ++++++++++
1 file changed, 15 insertions(+)
diff --git a/arch/arm/dts/rk3308-rock-s0-u-boot.dtsi b/arch/arm/dts/rk3308-rock-s0-u-boot.dtsi
index 84ca2ee0d5..c0d7f7b651 100644
--- a/arch/arm/dts/rk3308-rock-s0-u-boot.dtsi
+++ b/arch/arm/dts/rk3308-rock-s0-u-boot.dtsi
@@ -5,10 +5,25 @@
&emmc_pwren {
bootph-pre-ram;
bootph-some-ram;
};
+&pcfg_pull_down {
+ bootph-pre-ram;
+ bootph-some-ram;
+};
+
+&sdmmc {
+ pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_det &sdmmc_pwren &sdmmc_bus4>;
+};
+
+&sdmmc_pwren {
+ bootph-pre-ram;
+ bootph-some-ram;
+ rockchip,pins = <4 RK_PD6 0 &pcfg_pull_down>;
+};
+
&uart0 {
bootph-all;
clock-frequency = <24000000>;
};
--
Created with Armbian build tools https://github.com/armbian/build