u-boot-radxa-cm5: new aport

Part-of: https://gitlab.postmarketos.org/postmarketOS/pmaports/-/merge_requests/6580

[ci:skip-build]: already built successfully in CI
This commit is contained in:
Antoine Martin
2025-06-04 18:34:18 +02:00
committed by Pablo Correa Gómez
parent 8e8149062f
commit 00633f4ce3
6 changed files with 267 additions and 0 deletions
@@ -0,0 +1,79 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Masahiro Yamada <yamada.masahiro@socionext.com>
Date: Thu, 24 May 2018 17:04:57 +0900
Subject: [PATCH] menu: fix timeout duration
For distro-boot, the TIMEOUT directive in the boot script specifies
how long to pause in units of 1/10 sec. [1]
Commit 8594753ba0a7 ("menu: only timeout when menu is displayed")
corrected this by simply dividing the timeout value by 10 in
menu_interactive_choice().
I see two problems:
- For example, "TIMEOUT 5" should wait for 0.5 sec, but the current
implementation cannot handle the granularity of 1/10 sec.
In fact, it never breaks because "m->timeout / 10" is zero,
which means no timeout.
- The menu API is used not only by cmd/pxe.c but also by
common/autoboot.c . For the latter case, the unit of the
timeout value is _second_ because its default is associated
with CONFIG_BOOTDELAY.
To fix the first issue, use DIV_ROUND_UP() so that the timeout value
is rounded up to the closest integer.
For the second issue, move the division to the boundary between
cmd/pxe.c and common/menu.c . This is a more desirable place because
the comment of struct pxe_menu says:
* timeout - time in tenths of a second to wait for a user key-press before
* booting the default label.
Then, the comment of menu_create() says:
* timeout - A delay in seconds to wait for user input. If 0, timeout is
* disabled, and the default choice will be returned unless prompt is 1.
[1] https://www.syslinux.org/wiki/index.php?title=SYSLINUX#TIMEOUT_timeout
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
cmd/pxe.c | 4 ++--
common/menu.c | 3 +--
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/cmd/pxe.c b/cmd/pxe.c
index cce48e01e..32fc299f6 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -1558,8 +1558,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
/*
* Create a menu and add items for all the labels.
*/
- m = menu_create(cfg->title, cfg->timeout, cfg->prompt, label_print,
- NULL, NULL);
+ m = menu_create(cfg->title, DIV_ROUND_UP(cfg->timeout, 10),
+ cfg->prompt, label_print, NULL, NULL);
if (!m)
return NULL;
diff --git a/common/menu.c b/common/menu.c
index c53030f36..69f98ff33 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -195,8 +195,7 @@ static inline int menu_interactive_choice(struct menu *m, void **choice)
if (!m->item_choice) {
readret = cli_readline_into_buffer("Enter choice: ",
- cbuf,
- m->timeout / 10);
+ cbuf, m->timeout);
if (readret >= 0) {
choice_item = menu_item_by_key(m, cbuf);
--
2.37.2
@@ -0,0 +1,68 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Yuntian Zhang <yt@radxa.com>
Date: Tue, 26 Apr 2022 14:16:32 +0800
Subject: [PATCH] rockchip: move crypto functions to rk3588s
rkbin uses crypto device to verify hash before passing control to bootloader. If this device is missing boot will fail.
Signed-off-by: Yuntian Zhang <yt@radxa.com>
---
arch/arm/dts/rk3588.dtsi | 15 ---------------
arch/arm/dts/rk3588s.dtsi | 15 +++++++++++++++
2 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/arch/arm/dts/rk3588.dtsi b/arch/arm/dts/rk3588.dtsi
index 8a13e8edd8..f7eb5936a8 100644
--- a/arch/arm/dts/rk3588.dtsi
+++ b/arch/arm/dts/rk3588.dtsi
@@ -429,21 +429,6 @@
status = "disabled";
};
- crypto: crypto@fe370000 {
- compatible = "rockchip,rk3588-crypto";
- reg = <0x0 0xfe370000 0x0 0x4000>;
- clocks = <&scmi_clk SCMI_CRYPTO_CORE>, <&scmi_clk SCMI_CRYPTO_PKA>;
- clock-names = "sclk_crypto", "apkclk_crypto";
- clock-frequency = <350000000>, <350000000>;
- status = "disabled";
- };
-
- rng: rng@fe378000 {
- compatible = "rockchip,trngv1";
- reg = <0x0 0xfe378000 0x0 0x200>;
- status = "disabled";
- };
-
hdptxphy1: phy@fed70000 {
compatible = "rockchip,rk3588-hdptx-phy";
reg = <0x0 0xfed70000 0x0 0x2000>;
diff --git a/arch/arm/dts/rk3588s.dtsi b/arch/arm/dts/rk3588s.dtsi
index 53ccfbaeed..ca18d3bd0c 100644
--- a/arch/arm/dts/rk3588s.dtsi
+++ b/arch/arm/dts/rk3588s.dtsi
@@ -2220,6 +2220,21 @@
arm,pl330-periph-burst;
};
+ crypto: crypto@fe370000 {
+ compatible = "rockchip,rk3588-crypto";
+ reg = <0x0 0xfe370000 0x0 0x4000>;
+ clocks = <&scmi_clk SCMI_CRYPTO_CORE>, <&scmi_clk SCMI_CRYPTO_PKA>;
+ clock-names = "sclk_crypto", "apkclk_crypto";
+ clock-frequency = <350000000>, <350000000>;
+ status = "disabled";
+ };
+
+ rng: rng@fe378000 {
+ compatible = "rockchip,trngv1";
+ reg = <0x0 0xfe378000 0x0 0x200>;
+ status = "disabled";
+ };
+
hdptxphy0: phy@fed60000 {
compatible = "rockchip,rk3588-hdptx-phy";
reg = <0x0 0xfed60000 0x0 0x2000>;
--
2.36.1
@@ -0,0 +1,16 @@
diff --git a/include/configs/rk3588_common.h.orig b/include/configs/rk3588_common.h
index d57f4a1..089b579 100644
--- a/include/configs/rk3588_common.h.orig
+++ b/include/configs/rk3588_common.h
@@ -80,7 +80,9 @@
"fdt_addr_r=0x08300000\0" \
"kernel_addr_r=0x00400000\0" \
"kernel_addr_c=0x05480000\0" \
- "ramdisk_addr_r=0x0a200000\0"
+ "kernel_comp_addr_r=0x0a200000\0" \
+ "kernel_comp_size=0x02000000\0" \
+ "ramdisk_addr_r=0xc200000\0"
#include <config_distro_bootcmd.h>
@@ -0,0 +1,82 @@
# Maintainer: Antoine Martin (ayakael) <dev@ayakael.net>
pkgname=u-boot-radxa-cm5
pkgver=2017.09
pkgrel=0
pkgdesc="U-Boot fork for the Radxa CM5"
arch="aarch64"
_carch="arm"
license="GPL-2.0"
url="https://github.com/radxa/u-boot"
makedepends="
arm-trusted-firmware
bash
bc
bison
coreutils
dtc
flex
gnutls-dev
openssl-dev
python3
py3-setuptools
python3-dev
swig
u-boot-tools
"
options="!check !tracedeps pmb:crossdirect"
_targets="rpi-cm4-io io"
_repository="u-boot"
_commit="575d1a114c66ad09e0d9d9f478c993fc243f5aec"
source="
$pkgname-$_commit.tar.gz::https://github.com/radxa/$_repository/archive/$_commit.tar.gz
0001-menu-fix-timeout-duration.patch
0002-rockchip-move-crypto-functions-to-rk3588s.patch
0003-rk3588-support-compressed-kernel.patch
disable-spl-spi-load.patch
use-python3.patch
https://github.com/radxa/rkbin/raw/efaf8526fe85521ac86f4e88b0a6a6c6cf2563a1/bin/rk35/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.19.bin
"
builddir="$srcdir/$_repository-$_commit"
build() {
touch include/config.h
LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"' > include/timestamp_autogenerated.h
LC_ALL=C date +'#define U_BOOT_TIME "%T"' >> include/timestamp_autogenerated.h
for target in $_targets; do
export BUILD_DIR="$builddir"/build_$target
export ROCKCHIP_TPL="$srcdir"/rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.19.bin
export UBOOTVERSION=rk2410-2017.09-1
export BL31="/usr/share/arm-trusted-firmware/rk3588/bl31.elf"
# python scripts for BL31 management doesn't get copied over
mkdir -p "$BUILD_DIR"/arch/arm/mach-rockchip
cp "$builddir"/arch/arm/mach-rockchip/*.py "$BUILD_DIR"/arch/arm/mach-rockchip/.
make O="$BUILD_DIR" ARCH="$_carch" radxa-cm5-$target-rk3588s_defconfig
make O="$BUILD_DIR" ARCH="$_carch" all u-boot.itb
# make idbloader.img
mkimage -n rk3588 -T rksd -d "$ROCKCHIP_TPL:$BUILD_DIR"/spl/u-boot-spl.bin "$BUILD_DIR"/idbloader.img
done
}
package() {
for target in $_targets; do
install -Dm644 "$builddir/build_$target/u-boot-dtb.bin" "$pkgdir/usr/share/u-boot/radxa-cm5/$target/u-boot.bin"
install -Dm644 "$builddir/build_$target/idbloader.img" "$pkgdir/usr/share/u-boot/radxa-cm5/$target/idbloader.img"
install -Dm644 "$builddir/build_$target/u-boot.itb" "$pkgdir/usr/share/u-boot/radxa-cm5/$target/u-boot.itb"
done
}
sha512sums="
4805d0224b8c4ffecdaf560cf493ea06df9e195b7009aa7c30457cb33ecaeea92a64e7b2004ec1903d20fecc0e711905c710bca53072eefececd41a46b4176a2 u-boot-radxa-cm5-575d1a114c66ad09e0d9d9f478c993fc243f5aec.tar.gz
36baf3b8618928e8927229353157ccecb5477e6ed868b9425a04acc2b297026084bd5ed96785292ab2ccb74b9f6328fe032b55505749b103cd68e25777dc3334 0001-menu-fix-timeout-duration.patch
364a8701898e34f6235d2de486316413b5beec95578ee450e504e9a6f5c9feec773642a8129a91eef264e9466206c082950d0793a6a3e97f638edac42e4a70bf 0002-rockchip-move-crypto-functions-to-rk3588s.patch
d80fbde984311b97b0dbd3d1bf7e740350f7c85f3bc8c22fdac93f9200c5b7c722c956dbcc3ec0f4422a72fe5c46b14c0770433efa0f6faf01520ad2ac5f9eca 0003-rk3588-support-compressed-kernel.patch
11a1e30ad0002148f32314dc60c95120d45ffe462755e0bbc7d52ee4001e3283ffb87ba6f58d41feb0c40d456ef42c03857f98f8921c9a7bb810bbf404abedb3 disable-spl-spi-load.patch
1164247343518c9820ce2bf1302f18079b9af81f6ef164e5b9d2c5cbad00ac20e1943bb44d48862c0d4a2f0b7448f9fa35d02d2f66e90c34033d999b3a968443 use-python3.patch
0b529e57a7206471a66dcdb98dab3f8deeff333d587c2ebdd08febb40ab9b44e2d51de364d2383ed80dd2b38764ccb552a48f9e34da43607f1e08d385af3f161 rk3588_ddr_lp4_2112MHz_lp5_2400MHz_v1.19.bin
"
@@ -0,0 +1,12 @@
diff --git a/configs/radxa-cm5-rpi-cm4-io-rk3588s_defconfig.orig b/configs/radxa-cm5-rpi-cm4-io-rk3588s_defconfig
index 72ca6e7cb..bd1b0289d 100644
--- a/configs/radxa-cm5-rpi-cm4-io-rk3588s_defconfig.orig
+++ b/configs/radxa-cm5-rpi-cm4-io-rk3588s_defconfig
@@ -23,6 +23,7 @@ CONFIG_TARGET_EVB_RK3588=y
CONFIG_SPL_LIBDISK_SUPPORT=y
CONFIG_SPL_SPI_FLASH_SUPPORT=y
CONFIG_SPL_SPI_SUPPORT=y
+# CONFIG_SPL_SPI_LOAD is not set
CONFIG_DEFAULT_DEVICE_TREE="rk3588s-radxa-cm5-rpi-cm4-io"
CONFIG_DEBUG_UART=y
CONFIG_FIT=y
@@ -0,0 +1,10 @@
diff --git a/arch/arm/mach-rockchip/decode_bl31.py.orig b/arch/arm/mach-rockchip/decode_bl31.py
index 42fa32d23..1cff8c3a4 100755
--- a/arch/arm/mach-rockchip/decode_bl31.py.orig
+++ b/arch/arm/mach-rockchip/decode_bl31.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python3
#
# Copyright (C) 2020 Rockchip Electronics Co., Ltd
#