[PATCH v5 0/6] rockchip: Use external TPL binary to create a working firmware image

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the boot flow.
For RK356x there is no support to initialize DRAM using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.
This adds a new rockchip-tpl entry to binman and make use of this new entry in rockchip-u-boot.dtsi.
Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK356x.
The last patch fixes an allow-missing issue for mkimage entry, something that needs to be working for CI pipeline. The patch is based on [1] from the "binman: Show missing blob message" series at [2].
Changes in v5: - Add patch to fix issue with allow-missing - Split init size limit patch in two
Changes in v4: - Only change init size limit for rk3328 and rk3568 - Drop update evb-rk3568_defconfig patch
Changes in v3: - Move test function last - Add help text to Kconfig option - Add build step for rk3568 to documentation - Resync init size limit table - Drop missing message RFC patch
Changes in v2: - Renamed external-tpl to rockchip-tpl - Renamed EXTERNAL_TPL to ROCKCHIP_TPL - Add CONFIG_ROCKCHIP_EXTERNAL_TPL Kconfig option - New patch to sync init size limit in mkimage - New RFC patch to improve allow-missing/fake-ext-blobs handling for binman mkimage entry
[1] https://patchwork.ozlabs.org/project/uboot/patch/20230219220158.4160763-7-jo... [2] https://patchwork.ozlabs.org/project/uboot/cover/20230219220158.4160763-1-jo...
Jonas Karlman (6): binman: Add support for a rockchip-tpl entry rockchip: Use an external TPL binary on RK3568 Revert "board: rockchip: Fix binman_init failure on EVB-RK3568" rockchip: mkimage: Update init size limit for RK3328 rockchip: mkimage: Update init size limit for RK3568 binman: Mark mkimage entry missing when its subnodes is missing
Makefile | 1 + arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++-- arch/arm/mach-rockchip/Kconfig | 8 +++++++ configs/evb-rk3568_defconfig | 1 - doc/board/rockchip/rockchip.rst | 11 +++++++++ tools/binman/entries.rst | 14 +++++++++++ tools/binman/etype/mkimage.py | 24 ++++++++++++++++++- tools/binman/etype/rockchip_tpl.py | 20 ++++++++++++++++ tools/binman/ftest.py | 18 ++++++++++++++ tools/binman/missing-blob-help | 5 ++++ tools/binman/test/277_rockchip_tpl.dts | 16 +++++++++++++ .../test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++ tools/rkcommon.c | 4 ++-- 13 files changed, 145 insertions(+), 6 deletions(-) create mode 100644 tools/binman/etype/rockchip_tpl.py create mode 100644 tools/binman/test/277_rockchip_tpl.dts create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts

The rockchip-tpl entry can be used when an external TPL binary should be used instead of the normal U-Boot TPL.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com --- v5: - No change
v4: - No change
v3: - Move test function last - Collect r-b and t-b tags
v2: - Rename external-tpl to rockchip-tpl - Missing message moved to this patch
tools/binman/entries.rst | 14 ++++++++++++++ tools/binman/etype/rockchip_tpl.py | 20 ++++++++++++++++++++ tools/binman/ftest.py | 7 +++++++ tools/binman/missing-blob-help | 5 +++++ tools/binman/test/277_rockchip_tpl.dts | 16 ++++++++++++++++ 5 files changed, 62 insertions(+) create mode 100644 tools/binman/etype/rockchip_tpl.py create mode 100644 tools/binman/test/277_rockchip_tpl.dts
diff --git a/tools/binman/entries.rst b/tools/binman/entries.rst index 7a04a613992d..e177860a6a82 100644 --- a/tools/binman/entries.rst +++ b/tools/binman/entries.rst @@ -1386,6 +1386,20 @@ For example, this creates an image with a pre-load header and a binary::
+.. _etype_rockchip_tpl: + +Entry: rockchip-tpl: Rockchip TPL binary +---------------------------------------- + +Properties / Entry arguments: + - rockchip-tpl-path: Filename of file to read into the entry, + typically <soc>_ddr_<version>.bin + +This entry holds an external TPL binary used by some Rockchip SoCs +instead of normal U-Boot TPL, typically to initialize DRAM. + + + .. _etype_scp:
Entry: scp: System Control Processor (SCP) firmware blob diff --git a/tools/binman/etype/rockchip_tpl.py b/tools/binman/etype/rockchip_tpl.py new file mode 100644 index 000000000000..74f58ba8570c --- /dev/null +++ b/tools/binman/etype/rockchip_tpl.py @@ -0,0 +1,20 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for Rockchip TPL binary +# + +from binman.etype.blob_named_by_arg import Entry_blob_named_by_arg + +class Entry_rockchip_tpl(Entry_blob_named_by_arg): + """Rockchip TPL binary + + Properties / Entry arguments: + - rockchip-tpl-path: Filename of file to read into the entry, + typically <soc>_ddr_<version>.bin + + This entry holds an external TPL binary used by some Rockchip SoCs + instead of normal U-Boot TPL, typically to initialize DRAM. + """ + def __init__(self, section, etype, node): + super().__init__(section, etype, node, 'rockchip-tpl') + self.external = True diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 062f54adb0ed..48ac1540bfd8 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -90,6 +90,7 @@ TEE_OS_DATA = b'this is some tee OS data' ATF_BL2U_DATA = b'bl2u' OPENSBI_DATA = b'opensbi' SCP_DATA = b'scp' +ROCKCHIP_TPL_DATA = b'rockchip-tpl' TEST_FDT1_DATA = b'fdt1' TEST_FDT2_DATA = b'test-fdt2' ENV_DATA = b'var1=1\nvar2="2"' @@ -205,6 +206,7 @@ class TestFunctional(unittest.TestCase): TestFunctional._MakeInputFile('bl2u.bin', ATF_BL2U_DATA) TestFunctional._MakeInputFile('fw_dynamic.bin', OPENSBI_DATA) TestFunctional._MakeInputFile('scp.bin', SCP_DATA) + TestFunctional._MakeInputFile('rockchip-tpl.bin', ROCKCHIP_TPL_DATA)
# Add a few .dtb files for testing TestFunctional._MakeInputFile('%s/test-fdt1.dtb' % TEST_FDT_SUBDIR, @@ -6386,6 +6388,11 @@ fdt fdtmap Extract the devicetree blob from the fdtmap self.assertEqual(['u-boot', 'atf-2'], fdt_util.GetStringList(node, 'loadables'))
+ def testPackRockchipTpl(self): + """Test that an image with a Rockchip TPL binary can be created""" + data = self._DoReadFile('277_rockchip_tpl.dts') + self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)]) +
if __name__ == "__main__": unittest.main() diff --git a/tools/binman/missing-blob-help b/tools/binman/missing-blob-help index 4448ac93112a..f3a44d08acce 100644 --- a/tools/binman/missing-blob-help +++ b/tools/binman/missing-blob-help @@ -34,6 +34,11 @@ If CONFIG_WDT_K3_RTI_LOAD_FW is enabled, a firmware image is needed for the R5F core(s) to trigger the system reset. One possible source is https://github.com/siemens/k3-rti-wdt.
+rockchip-tpl: +An external TPL is required to initialize DRAM. Get the external TPL +binary and build with ROCKCHIP_TPL=/path/to/ddr.bin. One possible source +for the external TPL binary is https://github.com/rockchip-linux/rkbin. + tee-os: See the documentation for your board. You may need to build Open Portable Trusted Execution Environment (OP-TEE) with TEE=/path/to/tee.bin diff --git a/tools/binman/test/277_rockchip_tpl.dts b/tools/binman/test/277_rockchip_tpl.dts new file mode 100644 index 000000000000..269f56e2545c --- /dev/null +++ b/tools/binman/test/277_rockchip_tpl.dts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + rockchip-tpl { + filename = "rockchip-tpl.bin"; + }; + }; +};

On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
The rockchip-tpl entry can be used when an external TPL binary should be used instead of the normal U-Boot TPL.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com
Reviewed-by: Jagan Teki jagan@edgeble.ai

Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.
However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.
Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com --- v5: - No change
v4: - No change
v3: - Add help text to Kconfig option - Add build step for rk3568 to documentation - Collect r-b and t-b tags
v2: - Rename external-tpl-path to rockchip-tpl-path - Rename EXTERNAL_TPL to ROCKCHIP_TPL - Add CONFIG_ROCKCHIP_EXTERNAL_TPL option
Makefile | 1 + arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++-- arch/arm/mach-rockchip/Kconfig | 8 ++++++++ doc/board/rockchip/rockchip.rst | 11 +++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index bc1ee94fb74e..67701f20eb6d 100644 --- a/Makefile +++ b/Makefile @@ -1336,6 +1336,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ -a opensbi-path=${OPENSBI} \ -a default-dt=$(default_dt) \ -a scp-path=$(SCP) \ + -a rockchip-tpl-path=$(ROCKCHIP_TPL) \ -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \ -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \ -a spl-dtb=$(CONFIG_SPL_OF_REAL) \ diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index 6c662a72d4f9..2878b80926c4 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -20,9 +20,12 @@ mkimage { filename = "idbloader.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL + rockchip-tpl { + }; +#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif @@ -134,9 +137,12 @@ mkimage { filename = "idbloader-spi.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL + rockchip-tpl { + }; +#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b678ec41318e..0b191b364264 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -401,6 +401,14 @@ config TPL_ROCKCHIP_COMMON_BOARD common board is a basic TPL board init which can be shared for most of SoCs to avoid copy-paste for different SoCs.
+config ROCKCHIP_EXTERNAL_TPL + bool "Use external TPL binary" + default y if ROCKCHIP_RK3568 + help + Some Rockchip SoCs require an external TPL to initialize DRAM. + Enable this option and build with ROCKCHIP_TPL=/path/to/ddr.bin to + include the external TPL in the image built by binman. + config ROCKCHIP_BOOT_MODE_REG hex "Rockchip boot mode flag register address" help diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst index 28c837a38200..ac4dcce1a77d 100644 --- a/doc/board/rockchip/rockchip.rst +++ b/doc/board/rockchip/rockchip.rst @@ -86,6 +86,8 @@ List of mainline supported Rockchip boards: - Radxa ROCK Pi 4 (rock-pi-4-rk3399) - Rockchip Evb-RK3399 (evb_rk3399) - Theobroma Systems RK3399-Q7 SoM - Puma (puma_rk3399) +* rk3568 + - Rockchip Evb-RK3568 (evb-rk3568) * rv1108 - Rockchip Evb-rv1108 (evb-rv1108) - Elgin-R1 (elgin-rv1108) @@ -167,6 +169,15 @@ To build rk3399 boards: make evb-rk3399_defconfig make CROSS_COMPILE=aarch64-linux-gnu-
+To build rk3568 boards: + +.. code-block:: bash + + export BL31=../rkbin/bin/rk35/rk3568_bl31_v1.34.elf + export ROCKCHIP_TPL=../rkbin/bin/rk35/rk3568_ddr_1560MHz_v1.13.bin + make evb-rk3568_defconfig + make CROSS_COMPILE=aarch64-linux-gnu- + Flashing --------

On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.
However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.
Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com
v5:
- No change
v4:
- No change
v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags
v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option
Makefile | 1 + arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++-- arch/arm/mach-rockchip/Kconfig | 8 ++++++++ doc/board/rockchip/rockchip.rst | 11 +++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index bc1ee94fb74e..67701f20eb6d 100644 --- a/Makefile +++ b/Makefile @@ -1336,6 +1336,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ -a opensbi-path=${OPENSBI} \ -a default-dt=$(default_dt) \ -a scp-path=$(SCP) \
-a rockchip-tpl-path=$(ROCKCHIP_TPL) \ -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \ -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \ -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index 6c662a72d4f9..2878b80926c4 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -20,9 +20,12 @@ mkimage { filename = "idbloader.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif @@ -134,9 +137,12 @@ mkimage { filename = "idbloader-spi.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b678ec41318e..0b191b364264 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -401,6 +401,14 @@ config TPL_ROCKCHIP_COMMON_BOARD common board is a basic TPL board init which can be shared for most of SoCs to avoid copy-paste for different SoCs.
+config ROCKCHIP_EXTERNAL_TPL
bool "Use external TPL binary"
default y if ROCKCHIP_RK3568
Can you add RK3588 as well.
With that,
Reviewed-by: Jagan Teki jagan@edgeble.ai

On 2023-02-28 10:19, Jagan Teki wrote:
On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.
However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.
Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com
v5:
- No change
v4:
- No change
v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags
v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option
Makefile | 1 + arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++-- arch/arm/mach-rockchip/Kconfig | 8 ++++++++ doc/board/rockchip/rockchip.rst | 11 +++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index bc1ee94fb74e..67701f20eb6d 100644 --- a/Makefile +++ b/Makefile @@ -1336,6 +1336,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ -a opensbi-path=${OPENSBI} \ -a default-dt=$(default_dt) \ -a scp-path=$(SCP) \
-a rockchip-tpl-path=$(ROCKCHIP_TPL) \ -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \ -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \ -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index 6c662a72d4f9..2878b80926c4 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -20,9 +20,12 @@ mkimage { filename = "idbloader.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif @@ -134,9 +137,12 @@ mkimage { filename = "idbloader-spi.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b678ec41318e..0b191b364264 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -401,6 +401,14 @@ config TPL_ROCKCHIP_COMMON_BOARD common board is a basic TPL board init which can be shared for most of SoCs to avoid copy-paste for different SoCs.
+config ROCKCHIP_EXTERNAL_TPL
bool "Use external TPL binary"
default y if ROCKCHIP_RK3568
Can you add RK3588 as well.
I will send a separate patch to enable this for RK3588.
Regards, Jonas
With that,
Reviewed-by: Jagan Teki jagan@edgeble.ai

On Wed, 1 Mar 2023 at 02:26, Jonas Karlman jonas@kwiboo.se wrote:
On 2023-02-28 10:19, Jagan Teki wrote:
On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
Rockchip SoCs typically use U-Boot TPL to initialize DRAM, then jumps back to BootRom to load next stage, U-Boot SPL, into DRAM. BootRom then jumps to U-Boot SPL to continue the normal boot flow.
However, there is no support to initialize DRAM on RK35xx SoCs using U-Boot TPL and instead an external TPL binary must be used to generate a bootable u-boot-rockchip.bin image.
Add CONFIG_ROCKCHIP_EXTERNAL_TPL to indicate that an external TPL should be used. Build U-Boot with ROCKCHIP_TPL=/path/to/ddr.bin to generate a bootable u-boot-rockchip.bin image for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com Tested-by: Eugen Hristev eugen.hristev@collabora.com
v5:
- No change
v4:
- No change
v3:
- Add help text to Kconfig option
- Add build step for rk3568 to documentation
- Collect r-b and t-b tags
v2:
- Rename external-tpl-path to rockchip-tpl-path
- Rename EXTERNAL_TPL to ROCKCHIP_TPL
- Add CONFIG_ROCKCHIP_EXTERNAL_TPL option
Makefile | 1 + arch/arm/dts/rockchip-u-boot.dtsi | 10 ++++++++-- arch/arm/mach-rockchip/Kconfig | 8 ++++++++ doc/board/rockchip/rockchip.rst | 11 +++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile index bc1ee94fb74e..67701f20eb6d 100644 --- a/Makefile +++ b/Makefile @@ -1336,6 +1336,7 @@ cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ -a opensbi-path=${OPENSBI} \ -a default-dt=$(default_dt) \ -a scp-path=$(SCP) \
-a rockchip-tpl-path=$(ROCKCHIP_TPL) \ -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \ -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \ -a spl-dtb=$(CONFIG_SPL_OF_REAL) \
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index 6c662a72d4f9..2878b80926c4 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -20,9 +20,12 @@ mkimage { filename = "idbloader.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif @@ -134,9 +137,12 @@ mkimage { filename = "idbloader-spi.img"; args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; -#ifdef CONFIG_TPL multiple-data-files;
+#ifdef CONFIG_ROCKCHIP_EXTERNAL_TPL
rockchip-tpl {
};
+#elif defined(CONFIG_TPL) u-boot-tpl { }; #endif diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index b678ec41318e..0b191b364264 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -401,6 +401,14 @@ config TPL_ROCKCHIP_COMMON_BOARD common board is a basic TPL board init which can be shared for most of SoCs to avoid copy-paste for different SoCs.
+config ROCKCHIP_EXTERNAL_TPL
bool "Use external TPL binary"
default y if ROCKCHIP_RK3568
Can you add RK3588 as well.
I will send a separate patch to enable this for RK3588.
Ok, thanks.

Tested full series on bananapi r2pro
Tested-by: Frank Wunderlich frank-w@public-files.de
regards Frank

Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB, sync the init size limit from vendor u-boot to fix this.
Set init size limit to 30KiB (+2KiB) for RK3328.
This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Kever Yang kever.yang@rock-chips.com --- v5: - Split patch in two - Collect r-b tag
v4: - Only change limit for rk3328 and rk3568
v3: - Sync with vendor u-boot as-is - Update commit message to include size changes
v2: - New patch
tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 1f1eaa16752b..70bc66fdba6e 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -129,7 +129,7 @@ static struct spl_info spl_infos[] = { { "rk322x", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, { "rk3288", "RK32", 0x8000, false, RK_HEADER_V1 }, { "rk3308", "RK33", 0x40000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3328", "RK32", 0x8000 - 0x1000, false, RK_HEADER_V1 }, + { "rk3328", "RK32", 0x8000 - 0x800, false, RK_HEADER_V1 }, { "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 }, { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 },

On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
Latest vendor TPL for RK3328 has grown past the current init size limit of 28KiB, sync the init size limit from vendor u-boot to fix this.
Set init size limit to 30KiB (+2KiB) for RK3328.
This makes it possible to use latest vendor TPL on RK3328 without getting a size limit error running the mkimage command.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Kever Yang kever.yang@rock-chips.com
Reviewed-by: Jagan Teki jagan@amarulasolutions.com Tested-by: Jagan Teki jagan@amarulasolutions.com # roc-rk3328-cc

The current init size limit of 76KiB is too big to fit in the 64KiB SRAM on RK3568, sync init size limit from vendor u-boot to fix this.
Set init size limit to 60KiB (-16KiB) for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Kever Yang kever.yang@rock-chips.com --- v5: - Split patch in two - Collect r-b tag
v4: - Only change limit for rk3328 and rk3568
v3: - Sync with vendor u-boot as-is - Update commit message to include size changes
v2: - New patch
tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/rkcommon.c b/tools/rkcommon.c index 70bc66fdba6e..0d29110a4dec 100644 --- a/tools/rkcommon.c +++ b/tools/rkcommon.c @@ -134,7 +134,7 @@ static struct spl_info spl_infos[] = { { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, { "rv1108", "RK11", 0x1800, false, RK_HEADER_V1 }, { "rv1126", "110B", 0x10000 - 0x1000, false, RK_HEADER_V1 }, - { "rk3568", "RK35", 0x14000 - 0x1000, false, RK_HEADER_V2 }, + { "rk3568", "RK35", 0x10000 - 0x1000, false, RK_HEADER_V2 }, };
/**

On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
The current init size limit of 76KiB is too big to fit in the 64KiB SRAM on RK3568, sync init size limit from vendor u-boot to fix this.
Set init size limit to 60KiB (-16KiB) for RK3568.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Kever Yang kever.yang@rock-chips.com
Reviewed-by: Jagan Teki jagan@edgeble.ai

An external TPL binary is now expected to be provided using ROCKCHIP_TPL when building RK3568 targets.
This reverts commit 31500e7bcfaca08ab7c2879f502a6cf852410244.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com --- v5: - No change
v4: - No change
v3: - Collect r-b tag
v2: - Collect r-b tag
configs/evb-rk3568_defconfig | 1 - 1 file changed, 1 deletion(-)
diff --git a/configs/evb-rk3568_defconfig b/configs/evb-rk3568_defconfig index c7e0e5a796f4..0f72925b3a32 100644 --- a/configs/evb-rk3568_defconfig +++ b/configs/evb-rk3568_defconfig @@ -65,5 +65,4 @@ CONFIG_BAUDRATE=1500000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYS_NS16550_MEM32=y CONFIG_SYSRESET=y -# CONFIG_BINMAN_FDT is not set CONFIG_ERRNO_STR=y

On Sun, 26 Feb 2023 at 00:31, Jonas Karlman jonas@kwiboo.se wrote:
An external TPL binary is now expected to be provided using ROCKCHIP_TPL when building RK3568 targets.
This reverts commit 31500e7bcfaca08ab7c2879f502a6cf852410244.
Signed-off-by: Jonas Karlman jonas@kwiboo.se Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Kever Yang kever.yang@rock-chips.com
Reviewed-by: Jagan Teki jagan@amarulasolutions.com

Using the mkimage entry with the multiple-data-files prop and having a missing external blob result in an unexpected ValueError exception using the --allow-missing flag.
ValueError: Filename 'missing.bin' not found in input path (...)
Fix this by using _pathname that is resolved by ObtainContents for blob entries, ObtainContents also handles allow missing for external blobs.
Mark mkimage entry as missing and return without running mkimage when missing entries is reported by CheckMissing.
Signed-off-by: Jonas Karlman jonas@kwiboo.se --- v5: - New patch based on [1]
[1] https://patchwork.ozlabs.org/project/uboot/patch/20230219220158.4160763-7-jo...
tools/binman/etype/mkimage.py | 24 ++++++++++++++++++- tools/binman/ftest.py | 11 +++++++++ .../test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index cb264c3cad0b..8a13d5ea8d77 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -156,7 +156,8 @@ class Entry_mkimage(Entry): for entry in self._mkimage_entries.values(): if not entry.ObtainContents(fake_size=fake_size): return False - fnames.append(tools.get_input_filename(entry.GetDefaultFilename())) + if entry._pathname: + fnames.append(entry._pathname) input_fname = ":".join(fnames) else: data, input_fname, uniq = self.collect_contents_to_file( @@ -171,6 +172,13 @@ class Entry_mkimage(Entry): outfile = self._filename if self._filename else 'mkimage-out.%s' % uniq output_fname = tools.get_output_filename(outfile)
+ missing_list = [] + self.CheckMissing(missing_list) + self.missing = bool(missing_list) + if self.missing: + self.SetContents(b'') + return self.allow_missing + args = ['-d', input_fname] if self._data_to_imagename: args += ['-n', input_fname] @@ -216,6 +224,20 @@ class Entry_mkimage(Entry): if self._imagename: self._imagename.SetAllowFakeBlob(allow_fake)
+ def CheckMissing(self, missing_list): + """Check if any entries in this section have missing external blobs + + If there are missing (non-optional) blobs, the entries are added to the + list + + Args: + missing_list: List of Entry objects to be added to + """ + for entry in self._mkimage_entries.values(): + entry.CheckMissing(missing_list) + if self._imagename: + self._imagename.CheckMissing(missing_list) + def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 48ac1540bfd8..d74aa90a6207 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6393,6 +6393,17 @@ fdt fdtmap Extract the devicetree blob from the fdtmap data = self._DoReadFile('277_rockchip_tpl.dts') self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
+ def testMkimageMissingBlobMultiple(self): + """Test missing blob with mkimage entry and multiple-data-files""" + with test_util.capture_sys_output() as (stdout, stderr): + self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=True) + err = stderr.getvalue() + self.assertIn("is missing external blobs and is non-functional", err) + + with self.assertRaises(ValueError) as e: + self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=False) + self.assertIn("not found in input path", str(e.exception)) +
if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts b/tools/binman/test/278_mkimage_missing_multiple.dts new file mode 100644 index 000000000000..f84aea49ead9 --- /dev/null +++ b/tools/binman/test/278_mkimage_missing_multiple.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + mkimage { + args = "-n test -T script"; + multiple-data-files; + + blob-ext { + filename = "missing.bin"; + }; + }; + }; +};

On Sat, 25 Feb 2023 at 12:01, Jonas Karlman jonas@kwiboo.se wrote:
Using the mkimage entry with the multiple-data-files prop and having a missing external blob result in an unexpected ValueError exception using the --allow-missing flag.
ValueError: Filename 'missing.bin' not found in input path (...)
Fix this by using _pathname that is resolved by ObtainContents for blob entries, ObtainContents also handles allow missing for external blobs.
Mark mkimage entry as missing and return without running mkimage when missing entries is reported by CheckMissing.
Signed-off-by: Jonas Karlman jonas@kwiboo.se
v5:
- New patch based on [1]
[1] https://patchwork.ozlabs.org/project/uboot/patch/20230219220158.4160763-7-jo...
tools/binman/etype/mkimage.py | 24 ++++++++++++++++++- tools/binman/ftest.py | 11 +++++++++ .../test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts
Reviewed-by: Simon Glass sjg@chromium.org

On 2023/2/26 03:01, Jonas Karlman wrote:
Using the mkimage entry with the multiple-data-files prop and having a missing external blob result in an unexpected ValueError exception using the --allow-missing flag.
ValueError: Filename 'missing.bin' not found in input path (...)
Fix this by using _pathname that is resolved by ObtainContents for blob entries, ObtainContents also handles allow missing for external blobs.
Mark mkimage entry as missing and return without running mkimage when missing entries is reported by CheckMissing.
Signed-off-by: Jonas Karlman jonas@kwiboo.se
Reviewed-by: Kever Yang kever.yang@rock-chips.com
Thanks, - Kever
v5:
- New patch based on [1]
[1] https://patchwork.ozlabs.org/project/uboot/patch/20230219220158.4160763-7-jo...
tools/binman/etype/mkimage.py | 24 ++++++++++++++++++- tools/binman/ftest.py | 11 +++++++++ .../test/278_mkimage_missing_multiple.dts | 19 +++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 tools/binman/test/278_mkimage_missing_multiple.dts
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index cb264c3cad0b..8a13d5ea8d77 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -156,7 +156,8 @@ class Entry_mkimage(Entry): for entry in self._mkimage_entries.values(): if not entry.ObtainContents(fake_size=fake_size): return False
fnames.append(tools.get_input_filename(entry.GetDefaultFilename()))
if entry._pathname:
fnames.append(entry._pathname) input_fname = ":".join(fnames) else: data, input_fname, uniq = self.collect_contents_to_file(
@@ -171,6 +172,13 @@ class Entry_mkimage(Entry): outfile = self._filename if self._filename else 'mkimage-out.%s' % uniq output_fname = tools.get_output_filename(outfile)
missing_list = []
self.CheckMissing(missing_list)
self.missing = bool(missing_list)
if self.missing:
self.SetContents(b'')
return self.allow_missing
args = ['-d', input_fname] if self._data_to_imagename: args += ['-n', input_fname]
@@ -216,6 +224,20 @@ class Entry_mkimage(Entry): if self._imagename: self._imagename.SetAllowFakeBlob(allow_fake)
- def CheckMissing(self, missing_list):
"""Check if any entries in this section have missing external blobs
If there are missing (non-optional) blobs, the entries are added to the
list
Args:
missing_list: List of Entry objects to be added to
"""
for entry in self._mkimage_entries.values():
entry.CheckMissing(missing_list)
if self._imagename:
self._imagename.CheckMissing(missing_list)
def CheckFakedBlobs(self, faked_blobs_list): """Check if any entries in this section have faked external blobs
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 48ac1540bfd8..d74aa90a6207 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -6393,6 +6393,17 @@ fdt fdtmap Extract the devicetree blob from the fdtmap data = self._DoReadFile('277_rockchip_tpl.dts') self.assertEqual(ROCKCHIP_TPL_DATA, data[:len(ROCKCHIP_TPL_DATA)])
def testMkimageMissingBlobMultiple(self):
"""Test missing blob with mkimage entry and multiple-data-files"""
with test_util.capture_sys_output() as (stdout, stderr):
self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=True)
err = stderr.getvalue()
self.assertIn("is missing external blobs and is non-functional", err)
with self.assertRaises(ValueError) as e:
self._DoTestFile('278_mkimage_missing_multiple.dts', allow_missing=False)
self.assertIn("not found in input path", str(e.exception))
if __name__ == "__main__": unittest.main()
diff --git a/tools/binman/test/278_mkimage_missing_multiple.dts b/tools/binman/test/278_mkimage_missing_multiple.dts new file mode 100644 index 000000000000..f84aea49ead9 --- /dev/null +++ b/tools/binman/test/278_mkimage_missing_multiple.dts @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+/ {
- #address-cells = <1>;
- #size-cells = <1>;
- binman {
mkimage {
args = "-n test -T script";
multiple-data-files;
blob-ext {
filename = "missing.bin";
};
};
- };
+};
participants (5)
-
Frank Wunderlich
-
Jagan Teki
-
Jonas Karlman
-
Kever Yang
-
Simon Glass