From e28dafa3e2abfd2de713e58828e8a500b5155896 Mon Sep 17 00:00:00 2001 From: amazingfate Date: Sat, 2 Nov 2024 01:02:14 +0800 Subject: [PATCH 1/2] rk3576: fix booting from boot.scr --- config/bootscripts/boot-rk3576.cmd | 86 +++++++++++++++++++ config/sources/families/rk35xx.conf | 8 +- ...he-error-that-the-command-source-fai.patch | 26 ++++++ ...stent-return-type-of-command_process.patch | 35 ++++++++ .../defconfig/armsom-cm5-io-rk3576_defconfig | 1 - .../defconfig/armsom-sige5-rk3576_defconfig | 1 - 6 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 config/bootscripts/boot-rk3576.cmd create mode 100644 patch/u-boot/legacy/u-boot-armsom-rk3576/0001-cmd-source-fix-the-error-that-the-command-source-fai.patch create mode 100644 patch/u-boot/legacy/u-boot-armsom-rk3576/0002-cmd-inconsistent-return-type-of-command_process.patch diff --git a/config/bootscripts/boot-rk3576.cmd b/config/bootscripts/boot-rk3576.cmd new file mode 100644 index 000000000000..d39734a766e4 --- /dev/null +++ b/config/bootscripts/boot-rk3576.cmd @@ -0,0 +1,86 @@ +# DO NOT EDIT THIS FILE +# +# Please edit /boot/armbianEnv.txt to set supported parameters +# + +setenv load_addr "0x48000000" +setenv overlay_error "false" +# default values +setenv rootdev "/dev/mmcblk0p1" +setenv verbosity "1" +setenv console "both" +setenv bootlogo "false" +setenv rootfstype "ext4" +setenv docker_optimizations "on" +setenv earlycon "off" + +test -n "${distro_bootpart}" || distro_bootpart=1 + +echo "Boot script loaded from ${devtype} ${devnum}:${distro_bootpart}" + +if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}armbianEnv.txt; then + load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}armbianEnv.txt + env import -t ${load_addr} ${filesize} +fi + +if test "${logo}" = "disabled"; then setenv logo "logo.nologo"; fi + +if test "${console}" = "display" || test "${console}" = "both"; then setenv consoleargs "console=tty1"; fi +if test "${console}" = "serial" || test "${console}" = "both"; then setenv consoleargs "console=ttyS2,1500000 ${consoleargs}"; fi +if test "${earlycon}" = "on"; then setenv consoleargs "earlycon ${consoleargs}"; fi +if test "${bootlogo}" = "true"; then + setenv consoleargs "splash plymouth.ignore-serial-consoles ${consoleargs}" +else + setenv consoleargs "splash=verbose ${consoleargs}" +fi + +# get PARTUUID of first partition on SD/eMMC the boot script was loaded from +if test "${devtype}" = "mmc"; then part uuid mmc ${devnum}:${distro_bootpart} partuuid; fi + +setenv bootargs "root=${rootdev} rootwait rootfstype=${rootfstype} ${consoleargs} consoleblank=0 loglevel=${verbosity} ubootpart=${partuuid} usb-storage.quirks=${usbstoragequirks} ${extraargs} ${extraboardargs}" + +if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory"; fi + +load ${devtype} ${devnum}:${distro_bootpart} ${ramdisk_addr_r} ${prefix}uInitrd +load ${devtype} ${devnum}:${distro_bootpart} ${kernel_addr_r} ${prefix}Image + +load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtb/${fdtfile} +fdt addr ${fdt_addr_r} +fdt resize 65536 +for overlay_file in ${overlays}; do + if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-${overlay_file}.dtbo; then + echo "Applying kernel provided DT overlay ${overlay_prefix}-${overlay_file}.dtbo" + fdt apply ${load_addr} || setenv overlay_error "true" + elif load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_file}.dtbo; then + echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" + fdt apply ${load_addr} || setenv overlay_error "true" + fi +done +for overlay_file in ${user_overlays}; do + if load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then + echo "Applying user provided DT overlay ${overlay_file}.dtbo" + fdt apply ${load_addr} || setenv overlay_error "true" + fi +done +if test "${overlay_error}" = "true"; then + echo "Error applying DT overlays, restoring original DT" + load ${devtype} ${devnum}:${distro_bootpart} ${fdt_addr_r} ${prefix}dtb/${fdtfile} +else + if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-fixup.scr; then + load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}dtb/rockchip/overlay/${overlay_prefix}-fixup.scr + echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" + source ${load_addr} + fi + if test -e ${devtype} ${devnum}:${distro_bootpart} ${prefix}fixup.scr; then + load ${devtype} ${devnum}:${distro_bootpart} ${load_addr} ${prefix}fixup.scr + echo "Applying user provided fixup script (fixup.scr)" + source ${load_addr} + fi +fi + +echo "Trying 'kaslrseed' command... Info: 'Unknown command' can be safely ignored since 'kaslrseed' does not apply to all boards." +kaslrseed # @TODO: This gives an error (Unknown command ' kaslrseed ' - try 'help') on many devices since CONFIG_CMD_KASLRSEED is not enabled +booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r} + +# Recompile with: +# mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr diff --git a/config/sources/families/rk35xx.conf b/config/sources/families/rk35xx.conf index 7b2ec33e248b..c252a5cd6c59 100644 --- a/config/sources/families/rk35xx.conf +++ b/config/sources/families/rk35xx.conf @@ -14,11 +14,16 @@ BOOTBRANCH='branch:next-dev-v2024.03' # Always use same version as rk3588, they BOOTPATCHDIR="legacy/u-boot-radxa-rk35xx" OVERLAY_PREFIX='rk35xx' +if [[ "$BOOT_SOC" == "rk3576" ]]; then + BOOTSCRIPT='boot-rk3576.cmd:boot.cmd' +else + BOOTSCRIPT='boot-rk35xx.cmd:boot.cmd' +fi + case $BRANCH in legacy) display_alert "WARNING: 'legacy' branch" "is deprecated and slated for removal. Please switch to another branch unless you know what you're doing :)" "wrn" - BOOTSCRIPT='boot-rk35xx.cmd:boot.cmd' BOOTDIR='u-boot-rockchip64' declare -g KERNEL_MAJOR_MINOR="5.10" # Major and minor versions of this kernel. declare -g -i KERNEL_GIT_CACHE_TTL=120 # 2 minutes; this is a high-traffic repo @@ -28,7 +33,6 @@ case $BRANCH in ;; vendor) - BOOTSCRIPT='boot-rk35xx.cmd:boot.cmd' BOOTDIR='u-boot-rockchip64' declare -g KERNEL_MAJOR_MINOR="6.1" # Major and minor versions of this kernel. declare -g -i KERNEL_GIT_CACHE_TTL=120 # 2 minutes; this is a high-traffic repo diff --git a/patch/u-boot/legacy/u-boot-armsom-rk3576/0001-cmd-source-fix-the-error-that-the-command-source-fai.patch b/patch/u-boot/legacy/u-boot-armsom-rk3576/0001-cmd-source-fix-the-error-that-the-command-source-fai.patch new file mode 100644 index 000000000000..c3c313e294ef --- /dev/null +++ b/patch/u-boot/legacy/u-boot-armsom-rk3576/0001-cmd-source-fix-the-error-that-the-command-source-fai.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Stephen +Date: Mon, 8 Nov 2021 14:30:00 +0800 +Subject: cmd: source: fix the error that the command source failed to execute + +Signed-off-by: Stephen +--- + cmd/source.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/cmd/source.c b/cmd/source.c +index 111111111111..222222222222 100644 +--- a/cmd/source.c ++++ b/cmd/source.c +@@ -87,7 +87,7 @@ source (ulong addr, const char *fit_uname) + * past the zero-terminated sequence of image lengths to get + * to the actual image data + */ +- while (*data++ != IMAGE_PARAM_INVAL); ++ while (*data++); + break; + #endif + #if defined(CONFIG_FIT) +-- +Armbian + diff --git a/patch/u-boot/legacy/u-boot-armsom-rk3576/0002-cmd-inconsistent-return-type-of-command_process.patch b/patch/u-boot/legacy/u-boot-armsom-rk3576/0002-cmd-inconsistent-return-type-of-command_process.patch new file mode 100644 index 000000000000..0c2469f1c092 --- /dev/null +++ b/patch/u-boot/legacy/u-boot-armsom-rk3576/0002-cmd-inconsistent-return-type-of-command_process.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Heinrich Schuchardt +Date: Mon, 1 Aug 2022 15:17:49 +0200 +Subject: cmd: inconsistent return type of command_process() + +The declarations in the header and in the implementation must match. + +Reported-by: Sergei Antonov +Signed-off-by: Heinrich Schuchardt +Reviewed-by: Simon Glass +--- + include/command.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/include/command.h b/include/command.h +index 111111111111..222222222222 100644 +--- a/include/command.h ++++ b/include/command.h +@@ -137,10 +137,10 @@ enum command_ret_t { + * is left unchanged. + * @param ticks If ticks is not null, this function set it to the + * number of ticks the command took to complete. +- * @return 0 if the command succeeded, 1 if it failed ++ * @return 0 if command succeeded, else non-zero (CMD_RET_...) + */ +-int cmd_process(int flag, int argc, char * const argv[], +- int *repeatable, unsigned long *ticks); ++enum command_ret_t cmd_process(int flag, int argc, char *const argv[], ++ int *repeatable, unsigned long *ticks); + + void fixup_cmdtable(cmd_tbl_t *cmdtp, int size); + +-- +Armbian + diff --git a/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-cm5-io-rk3576_defconfig b/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-cm5-io-rk3576_defconfig index bc85fc327d09..fa69a379cf38 100644 --- a/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-cm5-io-rk3576_defconfig +++ b/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-cm5-io-rk3576_defconfig @@ -189,7 +189,6 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x2207 CONFIG_USB_GADGET_PRODUCT_NUM=0x350e CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_UFS=y -CONFIG_ROCKCHIP_UFS=y CONFIG_DM_VIDEO=y CONFIG_DISPLAY=y CONFIG_DRM_ROCKCHIP=y diff --git a/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-sige5-rk3576_defconfig b/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-sige5-rk3576_defconfig index 9f08dd8eb371..73125b562a72 100644 --- a/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-sige5-rk3576_defconfig +++ b/patch/u-boot/legacy/u-boot-armsom-rk3576/defconfig/armsom-sige5-rk3576_defconfig @@ -189,7 +189,6 @@ CONFIG_USB_GADGET_VENDOR_NUM=0x2207 CONFIG_USB_GADGET_PRODUCT_NUM=0x350e CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_UFS=y -CONFIG_ROCKCHIP_UFS=y CONFIG_DM_VIDEO=y CONFIG_DISPLAY=y CONFIG_DRM_ROCKCHIP=y From 28e82fec3c5f83993200bd8d21b791ab25da57b5 Mon Sep 17 00:00:00 2001 From: amazingfate Date: Sat, 2 Nov 2024 01:02:40 +0800 Subject: [PATCH 2/2] rk3576: use boot.scr instead of extlinux --- config/boards/armsom-cm5-io.csc | 1 - config/boards/armsom-sige5.csc | 1 - 2 files changed, 2 deletions(-) diff --git a/config/boards/armsom-cm5-io.csc b/config/boards/armsom-cm5-io.csc index d85c04d261cd..69d626cd48f3 100644 --- a/config/boards/armsom-cm5-io.csc +++ b/config/boards/armsom-cm5-io.csc @@ -8,7 +8,6 @@ BOOT_LOGO="desktop" BOOT_FDT_FILE="rockchip/rk3576-armsom-cm5-io.dtb" BOOT_SCENARIO="spl-blobs" IMAGE_PARTITION_TABLE="gpt" -SRC_EXTLINUX="yes" BOARD_MAINTAINER="" function post_family_config_branch_vendor__armsom-cm5-io_use_vendor_uboot() { diff --git a/config/boards/armsom-sige5.csc b/config/boards/armsom-sige5.csc index ff2308816b96..c2ba55781dc8 100644 --- a/config/boards/armsom-sige5.csc +++ b/config/boards/armsom-sige5.csc @@ -8,7 +8,6 @@ BOOT_LOGO="desktop" BOOT_FDT_FILE="rockchip/rk3576-armsom-sige5.dtb" BOOT_SCENARIO="spl-blobs" IMAGE_PARTITION_TABLE="gpt" -SRC_EXTLINUX="yes" BOARD_MAINTAINER="" function post_family_config_branch_vendor__armsom-sige7_use_vendor_uboot() {