[RFC PATCH 0/8] Build Rockchip final images using binman

My original goal was to produce SPI images for Rockchip platforms (specifically for me, ROCKPro64, and in the future ROCK64). Looking into it, it seemed nicer to just switch the SD/MMC image generation over to binman as well in the process.
This is my attempt to move Rockchip final full image generation to binman, adding the option to make full SPI images as well. I'm sending this as RFC patches because I'm not sure whether this is the ideal way to do this, whether this is even something we'd even want to do, and exactly what I might be breaking by doing this.
Other questions:
- I noticed that ATF generation for ARM64 Rockchip is done via a Python script instead of binman. I don't currently know how to change that over to binman, but is that something worth pursuing as part of this?
Please give me your feedback!
Andrew Abbott (8): binman: mkimage: Support ':'-separated inputs rockchip: Add binman definitions for final images soc: rockchip: Include common U-Boot dtsi file board: rockchip: Move SPI U-Boot offset to config rockchip: Remove obsolete Makefile targets rockchip: Enable binman for ARM64 doc: rockchip: Update for new binman image generation board: rockpro64: Enable building SPI image
Kconfig | 4 +- Makefile | 31 +--------- arch/arm/Kconfig | 2 +- arch/arm/dts/rk3308-u-boot.dtsi | 2 + arch/arm/dts/rk3328-u-boot.dtsi | 2 + arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi | 1 - arch/arm/dts/rk3368-u-boot.dtsi | 1 + arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi | 4 -- arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 1 - arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 4 -- arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 -- arch/arm/dts/rk3568-u-boot.dtsi | 2 + arch/arm/dts/rockchip-u-boot.dtsi | 59 ++++++++++++++++++-- arch/arm/mach-rockchip/Kconfig | 7 +-- arch/arm/mach-rockchip/rk3399/Kconfig | 1 + configs/lion-rk3368_defconfig | 1 + configs/pinebook-pro-rk3399_defconfig | 1 + configs/puma-rk3399_defconfig | 2 +- configs/roc-pc-rk3399_defconfig | 1 + configs/rockpro64-rk3399_defconfig | 1 + doc/board/rockchip/rockchip.rst | 34 ++++------- tools/binman/etype/mkimage.py | 33 +++++++---- 22 files changed, 107 insertions(+), 91 deletions(-)

mkimage supports combining multiple input binaries separating them with colons (':'). This is used at least for Rockchip platforms to encode payload offsets and sizes in the image header. It is required for Rockchip SPI boot since for the rkspi format, after the input binary combining, the entire image is spread across only the first 2K bytes of each 4K block.
Previous to this change, multiple inputs to a binman mkimage node would just be concatenated and the combined input would be passed as the -d argument to mkimage. Now, the inputs are instead passed colon-separated.
Signed-off-by: Andrew Abbott andrew@mirx.dev ---
This is a bit of a messy implementation for now and would probably break existing uses of mkimage that rely on the concatenation behaviour.
Questions:
- Should this be a separate entry type, or an option to the mkimage entry type that enables this behaviour?
- What kind of test(s) should I add?
--- tools/binman/etype/mkimage.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
diff --git a/tools/binman/etype/mkimage.py b/tools/binman/etype/mkimage.py index 5f6def2287..8cea618fbd 100644 --- a/tools/binman/etype/mkimage.py +++ b/tools/binman/etype/mkimage.py @@ -51,21 +51,30 @@ class Entry_mkimage(Entry): self.ReadEntries()
def ObtainContents(self): - # Use a non-zero size for any fake files to keep mkimage happy - data, input_fname, uniq = self.collect_contents_to_file( - self._mkimage_entries.values(), 'mkimage', 1024) - if data is None: - return False - output_fname = tools.get_output_filename('mkimage-out.%s' % uniq) - if self.mkimage.run_cmd('-d', input_fname, *self._args, - output_fname) is not None: + # For multiple inputs to mkimage, we want to separate them by colons. + # This is needed for eg. the rkspi format, which treats the first data + # file as the "init" and the second as "boot" and sets the image header + # accordingly, then makes the image so that only the first 2 KiB of each + # 4KiB block is used. + + data_filenames = [] + for entry in self._mkimage_entries.values(): + # First get the input data and put it in a file. If any entry is not + # available, try later. + if not entry.ObtainContents(): + return False + + input_fname = tools.get_output_filename('mkimage-in.%s' % entry.GetUniqueName()) + data_filenames.append(input_fname) + tools.write_file(input_fname, entry.GetData()) + + output_fname = tools.get_output_filename('mkimage-out.%s' % self.GetUniqueName()) + if self.mkimage.run_cmd('-d', ":".join(data_filenames), *self._args, output_fname): self.SetContents(tools.read_file(output_fname)) + return True else: - # Bintool is missing; just use the input data as the output self.record_missing_bintool(self.mkimage) - self.SetContents(data) - - return True + return False
def ReadEntries(self): """Read the subnodes to find out what should go in this image"""

Currently, building for Rockchip targets produces:
- idbloader.img - rksd-formatted TPL with SPL appended; or - rksd-formatted SPL - u-boot.itb - U-Boot Proper FIT image - u-boot-rockchip.bin - idbloader.img + u-boot.itb, padded the correct amount for SD/MMC usage.
For RK3399 targets:
- u-boot.rom - SPI image specific to the bob Chromebook target (see c4cea2bbf995764f325a907061c22ecd6768cf7b).
This commit adds binman definitions to produce these images:
- idbloader.img - u-boot-rockchip-sdmmc.bin - [TPL + ] SPL all rksd-formatted + u-boot.itb padded for SD/MMC usage. - u-boot-rockchip-spi.bin - [TPL + ] SPL all rkspi-formatted + u-boot.itb padded for SPI usage.
This commit also generalizes the CONFIG_ROCKCHIP_SPI_IMAGE config setting - it now means to generate a generic SPI flash image, in addition to the generic SD/MMC image.
Signed-off-by: Andrew Abbott andrew@mirx.dev ---
Question: Does this break/not play nicely with rockchip-optee generation? It creates u-boot.itb for rk3288 targets. That would need to run before what I've implemented here?
--- arch/arm/dts/rockchip-u-boot.dtsi | 59 +++++++++++++++++++++++++++---- arch/arm/mach-rockchip/Kconfig | 7 ++-- 2 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index eae3ee715d..05d79e6c55 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -13,17 +13,64 @@
#ifdef CONFIG_SPL &binman { - simple-bin { - filename = "u-boot-rockchip.bin"; - pad-byte = <0xff>; + sdmmc-idbloader { + filename = "idbloader.img";
- blob { - filename = "idbloader.img"; + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T", "rksd"; + +#ifdef CONFIG_TPL + u-boot-tpl {}; +#endif + u-boot-spl {}; }; + }; + + sdmmc-image { + filename = "u-boot-rockchip-sdmmc.bin"; + pad-byte = <0xff>; + + idbloader { + filename = "idbloader.img"; + type = "blob"; + };
- u-boot-img { +#ifdef CONFIG_ARM64 + u-boot-fit { + filename = "u-boot.itb"; + type = "blob"; offset = <CONFIG_SPL_PAD_TO>; }; +#else + u-boot-img {}; +#endif }; }; + +#ifdef CONFIG_ROCKCHIP_SPI_IMAGE +&binman { + spi-image { + filename = "u-boot-rockchip-spi.bin"; + pad-byte = <0xff>; + + mkimage { + args = "-n", CONFIG_SYS_SOC, "-T", "rkspi"; + +#ifdef CONFIG_TPL + u-boot-tpl {}; +#endif + u-boot-spl {}; + }; + +#ifdef CONFIG_ARM64 + blob { + filename = "u-boot.itb"; + offset = <CONFIG_SYS_SPI_U_BOOT_OFFS>; + }; +#else + u-boot-img {}; #endif + }; +}; +#endif // CONFIG_ROCKCHIP_SPI_IMAGE +#endif // CONFIG_SPL diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 18aff5480b..7149b9a530 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -415,12 +415,11 @@ config SPL_MMC
config ROCKCHIP_SPI_IMAGE bool "Build a SPI image for rockchip" - depends on HAS_ROM help Some Rockchip SoCs support booting from SPI flash. Enable this - option to produce a 4MB SPI-flash image (called u-boot.rom) - containing U-Boot. The image is built by binman. U-Boot sits near - the start of the image. + option to produce an SPI-flash image (called u-boot-rockchip-spi.bin) + containing TPL (if enabled) and SPL, and U-Boot proper at the offset + CONFIG_SYS_SPI_U_BOOT_OFFS. The image is built by binman.
config LNX_KRNL_IMG_TEXT_OFFSET_BASE default SYS_TEXT_BASE

On 4/25/22 02:03, Andrew Abbott wrote:
Currently, building for Rockchip targets produces:
- idbloader.img
- rksd-formatted TPL with SPL appended; or
- rksd-formatted SPL
- u-boot.itb
- U-Boot Proper FIT image
- u-boot-rockchip.bin
- idbloader.img + u-boot.itb, padded the correct amount for SD/MMC usage.
For RK3399 targets:
- u-boot.rom
- SPI image specific to the bob Chromebook target (see c4cea2bbf995764f325a907061c22ecd6768cf7b).
This commit adds binman definitions to produce these images:
- idbloader.img
- u-boot-rockchip-sdmmc.bin
- [TPL + ] SPL all rksd-formatted + u-boot.itb padded for SD/MMC usage.
- u-boot-rockchip-spi.bin
- [TPL + ] SPL all rkspi-formatted + u-boot.itb padded for SPI usage.
This commit also generalizes the CONFIG_ROCKCHIP_SPI_IMAGE config setting - it now means to generate a generic SPI flash image, in addition to the generic SD/MMC image.
Signed-off-by: Andrew Abbott andrew@mirx.dev
Question: Does this break/not play nicely with rockchip-optee generation? It creates u-boot.itb for rk3288 targets. That would need to run before what I've implemented here?
arch/arm/dts/rockchip-u-boot.dtsi | 59 +++++++++++++++++++++++++++---- arch/arm/mach-rockchip/Kconfig | 7 ++-- 2 files changed, 56 insertions(+), 10 deletions(-)
diff --git a/arch/arm/dts/rockchip-u-boot.dtsi b/arch/arm/dts/rockchip-u-boot.dtsi index eae3ee715d..05d79e6c55 100644 --- a/arch/arm/dts/rockchip-u-boot.dtsi +++ b/arch/arm/dts/rockchip-u-boot.dtsi @@ -13,17 +13,64 @@
#ifdef CONFIG_SPL &binman {
- simple-bin {
filename = "u-boot-rockchip.bin";
Hi,
This name "u-boot-rockchip.bin"is in use in user space scripts and shows up in examples on the web. No desire for yet another naming variant. What you change must give exact the same result as we had in the existing situation.
"git am <patch>" gives these warnings:
warning: 3 lines add whitespace errors.
Resulting dtsi is full of TAB and alignment issues. Use an editor with TAB highlighter.
There's a trend to solve everything in python. Don't have knowledge about python, but there's a 3rd image format for NAND [1]. Could someone advise how to fit the extra XXX padding option in the mkimage.py file? (Simon ?)
Could someone from Rockchip give info on whether the SD or SPI image format has similarity to the NAND image format to reuse code? (Kever ?)
Missing are u-boot documents on Rockchip file formats itself other then reading the /tools/rkxxx.c code.
Currently there's a small section about rkimage, rksd and rkspi in README.rockchip. Move that to rockchip.rst as well when busy with image formats in this serie?
Johan
===
[1] [PATCH v4 11/19] rockchip: mkimage: add support for rockchip nand boot image https://lore.kernel.org/u-boot/45576df80a77657cb2245ea1d1fc2e69908a909d.1502...
pad-byte = <0xff>;
- sdmmc-idbloader {
filename = "idbloader.img";
blob {
filename = "idbloader.img";
mkimage {
args = "-n", CONFIG_SYS_SOC, "-T", "rksd";
+#ifdef CONFIG_TPL
u-boot-tpl {};
+#endif
};u-boot-spl {};
- };
- sdmmc-image {
filename = "u-boot-rockchip-sdmmc.bin";
pad-byte = <0xff>;
idbloader {
filename = "idbloader.img";
type = "blob";
};
u-boot-img {
+#ifdef CONFIG_ARM64
u-boot-fit {
filename = "u-boot.itb";
};type = "blob"; offset = <CONFIG_SPL_PAD_TO>;
+#else
u-boot-img {};
+#endif }; };
+#ifdef CONFIG_ROCKCHIP_SPI_IMAGE +&binman {
- spi-image {
filename = "u-boot-rockchip-spi.bin";
pad-byte = <0xff>;
mkimage {
args = "-n", CONFIG_SYS_SOC, "-T", "rkspi";
+#ifdef CONFIG_TPL
u-boot-tpl {};
+#endif
u-boot-spl {};
};
+#ifdef CONFIG_ARM64
blob {
filename = "u-boot.itb";
offset = <CONFIG_SYS_SPI_U_BOOT_OFFS>;
};
+#else
u-boot-img {};
#endif
- };
+}; +#endif // CONFIG_ROCKCHIP_SPI_IMAGE +#endif // CONFIG_SPL diff --git a/arch/arm/mach-rockchip/Kconfig b/arch/arm/mach-rockchip/Kconfig index 18aff5480b..7149b9a530 100644 --- a/arch/arm/mach-rockchip/Kconfig +++ b/arch/arm/mach-rockchip/Kconfig @@ -415,12 +415,11 @@ config SPL_MMC
config ROCKCHIP_SPI_IMAGE bool "Build a SPI image for rockchip"
- depends on HAS_ROM help Some Rockchip SoCs support booting from SPI flash. Enable this
option to produce a 4MB SPI-flash image (called u-boot.rom)
containing U-Boot. The image is built by binman. U-Boot sits near
the start of the image.
option to produce an SPI-flash image (called u-boot-rockchip-spi.bin)
containing TPL (if enabled) and SPL, and U-Boot proper at the offset
CONFIG_SYS_SPI_U_BOOT_OFFS. The image is built by binman.
config LNX_KRNL_IMG_TEXT_OFFSET_BASE default SYS_TEXT_BASE

On Wed Apr 27, 2022 at 7:22 PM AEST, Johan Jonker wrote:
Hi,
This name "u-boot-rockchip.bin"is in use in user space scripts and shows up in examples on the web. No desire for yet another naming variant. What you change must give exact the same result as we had in the existing situation.
"git am <patch>" gives these warnings:
warning: 3 lines add whitespace errors.
Resulting dtsi is full of TAB and alignment issues. Use an editor with TAB highlighter.
Thanks for your feedback! I'll fix whitespace issues in all the patches in the next version, as well as renaming "u-boot-rockchip-sdmmc.bin" to "u-boot-rockchip.bin" - that should be equivalent to the original output.
Regards, Andrew

On 27/04/2022 12:22, Johan Jonker wrote:
[...]
There's a trend to solve everything in python. Don't have knowledge about python, but there's a 3rd image format for NAND [1]. Could someone advise how to fit the extra XXX padding option in the mkimage.py file? (Simon ?)
Binman's mkimage support is mostly a wrapper around the mkimage executable, so that patch would need to be applied first. Assuming you want to run something like the example in that patch:
mkimage -n rk3066 -T rknand -d <tpl>:<spl> -X 16384,1 <out>
I think you'd only need something like the first patch of this series for binman to get the multiple inputs working, and I expect a binman dtb fragment like the following would then work for the above command:
mkimage { args = "-n", CONFIG_SYS_SOC, "-T", "rknand", "-X", "16384,1";
u-boot-tpl { };
u-boot-spl { }; };
Could someone from Rockchip give info on whether the SD or SPI image format has similarity to the NAND image format to reuse code? (Kever ?)
Missing are u-boot documents on Rockchip file formats itself other then reading the /tools/rkxxx.c code.
(I don't know the formats' details, so can't comment on those.)
Currently there's a small section about rkimage, rksd and rkspi in README.rockchip. Move that to rockchip.rst as well when busy with image formats in this serie?
Johan
===
[1] [PATCH v4 11/19] rockchip: mkimage: add support for rockchip nand boot image https://lore.kernel.org/u-boot/45576df80a77657cb2245ea1d1fc2e69908a909d.1502...

This pulls in binman definitions so images can be built for all Rockchip platforms.
Signed-off-by: Andrew Abbott andrew@mirx.dev --- arch/arm/dts/rk3308-u-boot.dtsi | 2 ++ arch/arm/dts/rk3328-u-boot.dtsi | 2 ++ arch/arm/dts/rk3368-u-boot.dtsi | 1 + arch/arm/dts/rk3568-u-boot.dtsi | 2 ++ 4 files changed, 7 insertions(+)
diff --git a/arch/arm/dts/rk3308-u-boot.dtsi b/arch/arm/dts/rk3308-u-boot.dtsi index 4bfad31fba..ab5bfc2ce9 100644 --- a/arch/arm/dts/rk3308-u-boot.dtsi +++ b/arch/arm/dts/rk3308-u-boot.dtsi @@ -3,6 +3,8 @@ *(C) Copyright 2019 Rockchip Electronics Co., Ltd */
+#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3328-u-boot.dtsi b/arch/arm/dts/rk3328-u-boot.dtsi index 1633558264..d4a7540a92 100644 --- a/arch/arm/dts/rk3328-u-boot.dtsi +++ b/arch/arm/dts/rk3328-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2019 Rockchip Electronics Co., Ltd */
+#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &emmc; diff --git a/arch/arm/dts/rk3368-u-boot.dtsi b/arch/arm/dts/rk3368-u-boot.dtsi index 2767c2678d..b37da4e851 100644 --- a/arch/arm/dts/rk3368-u-boot.dtsi +++ b/arch/arm/dts/rk3368-u-boot.dtsi @@ -3,6 +3,7 @@ * Copyright (c) 2020 Theobroma Systems Design und Consulting GmbH */
+#include "rockchip-u-boot.dtsi" #include <dt-bindings/memory/rk3368-dmc.h>
/ { diff --git a/arch/arm/dts/rk3568-u-boot.dtsi b/arch/arm/dts/rk3568-u-boot.dtsi index 5a80dda275..fa9b6ae23b 100644 --- a/arch/arm/dts/rk3568-u-boot.dtsi +++ b/arch/arm/dts/rk3568-u-boot.dtsi @@ -3,6 +3,8 @@ * (C) Copyright 2021 Rockchip Electronics Co., Ltd */
+#include "rockchip-u-boot.dtsi" + / { aliases { mmc0 = &sdhci;

This needs to be accessible to binman (via CONFIG_ preprocessor macros) so it can build SPI images using the correct offset.
The documentation at 'doc/device-tree-bindings/config.txt' says that the 'u-boot,spl-payload-offset' device tree option simply overrides 'CONFIG_SYS_SPI_U_BOOT_OFFS', so this change should not functionally change the offset for any of the affected boards.
Signed-off-by: Andrew Abbott andrew@mirx.dev --- arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi | 1 - arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi | 4 ---- arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi | 1 - arch/arm/dts/rk3399-roc-pc-u-boot.dtsi | 4 ---- arch/arm/dts/rk3399-rockpro64-u-boot.dtsi | 4 ---- configs/lion-rk3368_defconfig | 1 + configs/pinebook-pro-rk3399_defconfig | 1 + configs/puma-rk3399_defconfig | 2 +- configs/roc-pc-rk3399_defconfig | 1 + configs/rockpro64-rk3399_defconfig | 1 + 10 files changed, 5 insertions(+), 15 deletions(-)
diff --git a/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi b/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi index 7826d1e70b..6840182f03 100644 --- a/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi +++ b/arch/arm/dts/rk3368-lion-haikou-u-boot.dtsi @@ -7,7 +7,6 @@
/ { config { - u-boot,spl-payload-offset = <0x40000>; /* @ 256KB */ u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ };
diff --git a/arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi b/arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi index 2d87bea933..d1d0ac460d 100644 --- a/arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi +++ b/arch/arm/dts/rk3399-pinebook-pro-u-boot.dtsi @@ -10,10 +10,6 @@ chosen { u-boot,spl-boot-order = "same-as-spl", &sdhci, &spiflash, &sdmmc; }; - - config { - u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */ - }; };
&edp { diff --git a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi index e0476ab25c..f3f8619716 100644 --- a/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi +++ b/arch/arm/dts/rk3399-puma-haikou-u-boot.dtsi @@ -14,7 +14,6 @@
/ { config { - u-boot,spl-payload-offset = <0x40000>; /* @ 256KB */ u-boot,mmc-env-offset = <0x4000>; /* @ 16KB */ u-boot,efi-partition-entries-offset = <0x200000>; /* 2MB */ u-boot,boot-led = "module_led"; diff --git a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi index e3c9364e35..a54e554d8a 100644 --- a/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi +++ b/arch/arm/dts/rk3399-roc-pc-u-boot.dtsi @@ -11,10 +11,6 @@ u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdhci, &sdmmc; };
- config { - u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */ - }; - vcc_hub_en: vcc_hub_en-regulator { compatible = "regulator-fixed"; enable-active-high; diff --git a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi index 37dff04adf..bd65496df3 100644 --- a/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi +++ b/arch/arm/dts/rk3399-rockpro64-u-boot.dtsi @@ -9,10 +9,6 @@ chosen { u-boot,spl-boot-order = "same-as-spl", &spi_flash, &sdmmc, &sdhci; }; - - config { - u-boot,spl-payload-offset = <0x60000>; /* @ 384KB */ - }; };
&spi1 { diff --git a/configs/lion-rk3368_defconfig b/configs/lion-rk3368_defconfig index 426913816b..91630c822b 100644 --- a/configs/lion-rk3368_defconfig +++ b/configs/lion-rk3368_defconfig @@ -17,6 +17,7 @@ CONFIG_DEBUG_UART_BASE=0xFF180000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_SPL_SPI_FLASH_SUPPORT=y CONFIG_SPL_SPI=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_SYS_LOAD_ADDR=0x800800 CONFIG_DEBUG_UART=y CONFIG_FIT=y diff --git a/configs/pinebook-pro-rk3399_defconfig b/configs/pinebook-pro-rk3399_defconfig index 8ca1d0708f..c5ebf62f02 100644 --- a/configs/pinebook-pro-rk3399_defconfig +++ b/configs/pinebook-pro-rk3399_defconfig @@ -24,6 +24,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_SPL_MTD_SUPPORT=y CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPIO=y diff --git a/configs/puma-rk3399_defconfig b/configs/puma-rk3399_defconfig index 7ce2dc0719..6b7898be49 100644 --- a/configs/puma-rk3399_defconfig +++ b/configs/puma-rk3399_defconfig @@ -27,7 +27,7 @@ CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200 CONFIG_SPL_I2C=y CONFIG_SPL_POWER=y CONFIG_SPL_SPI_LOAD=y -CONFIG_SYS_SPI_U_BOOT_OFFS=0x20000 +CONFIG_SYS_SPI_U_BOOT_OFFS=0x40000 CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y CONFIG_CMD_I2C=y diff --git a/configs/roc-pc-rk3399_defconfig b/configs/roc-pc-rk3399_defconfig index 4684fa6e74..2d7e2ad563 100644 --- a/configs/roc-pc-rk3399_defconfig +++ b/configs/roc-pc-rk3399_defconfig @@ -25,6 +25,7 @@ CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x20000 CONFIG_SPL_ENV_SUPPORT=y CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y diff --git a/configs/rockpro64-rk3399_defconfig b/configs/rockpro64-rk3399_defconfig index e6f7a8469a..8c45a6c575 100644 --- a/configs/rockpro64-rk3399_defconfig +++ b/configs/rockpro64-rk3399_defconfig @@ -23,6 +23,7 @@ CONFIG_MISC_INIT_R=y CONFIG_SPL_STACK_R=y CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x10000 CONFIG_SPL_SPI_LOAD=y +CONFIG_SYS_SPI_U_BOOT_OFFS=0x60000 CONFIG_TPL=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_GPT=y

These are obsoleted by a previous patch which added binman image definitions for Rockchip SD/MMC and SPI images.
Signed-off-by: Andrew Abbott andrew@mirx.dev --- Makefile | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-)
diff --git a/Makefile b/Makefile index 7937a4cfd3..cf6ec63c34 100644 --- a/Makefile +++ b/Makefile @@ -984,16 +984,15 @@ INPUTS-y += u-boot-with-dtb.bin endif
ifeq ($(CONFIG_ARCH_ROCKCHIP),y) -# On ARM64 this target is produced by binman so we don't need this dep ifeq ($(CONFIG_ARM64),y) ifeq ($(CONFIG_SPL),y) # TODO: Get binman to generate this too -INPUTS-y += u-boot-rockchip.bin +INPUTS-y += u-boot.itb endif else ifeq ($(CONFIG_SPL),y) -# Generate these inputs for binman which will create the output files -INPUTS-y += idbloader.img u-boot.img +# Generate this input for binman which will create the output files +INPUTS-y += u-boot.img endif endif endif @@ -1481,30 +1480,6 @@ OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE $(call if_changed,pad_cat)
-ifeq ($(CONFIG_ARCH_ROCKCHIP),y) - -# TPL + SPL -ifeq ($(CONFIG_SPL)$(CONFIG_TPL),yy) -MKIMAGEFLAGS_u-boot-tpl-rockchip.bin = -n $(CONFIG_SYS_SOC) -T rksd -tpl/u-boot-tpl-rockchip.bin: tpl/u-boot-tpl.bin FORCE - $(call if_changed,mkimage) -idbloader.img: tpl/u-boot-tpl-rockchip.bin spl/u-boot-spl.bin FORCE - $(call if_changed,cat) -else -MKIMAGEFLAGS_idbloader.img = -n $(CONFIG_SYS_SOC) -T rksd -idbloader.img: spl/u-boot-spl.bin FORCE - $(call if_changed,mkimage) -endif - -ifeq ($(CONFIG_ARM64),y) -OBJCOPYFLAGS_u-boot-rockchip.bin = -I binary -O binary \ - --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff -u-boot-rockchip.bin: idbloader.img u-boot.itb FORCE - $(call if_changed,pad_cat) -endif # CONFIG_ARM64 - -endif # CONFIG_ARCH_ROCKCHIP - ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy) MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE)

Binman is now being used to build the final flashable images for Rockchip devices, thus enabling it for all Rockchip targets here. But it is not yet being used to generate the FIT image (u-boot.itb), thus we need to force it to be built.
Signed-off-by: Andrew Abbott andrew@mirx.dev ---
Question: Will this causes issues with eg. Chromebook gru/bob, which build u-boot.itb with binman already?
--- Kconfig | 4 ++-- arch/arm/Kconfig | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Kconfig b/Kconfig index bdae59e06f..99e5491f08 100644 --- a/Kconfig +++ b/Kconfig @@ -406,8 +406,8 @@ config BUILD_TARGET default "u-boot-with-spl.sfp" if TARGET_SOCFPGA_GEN5 default "u-boot-spl.kwb" if ARCH_MVEBU && SPL default "u-boot-elf.srec" if RCAR_GEN3 - default "u-boot.itb" if !BINMAN && SPL_LOAD_FIT && (ARCH_ROCKCHIP || \ - ARCH_SUNXI || RISCV || ARCH_ZYNQMP) + default "u-boot.itb" if ARCH_ROCKCHIP || (!BINMAN && SPL_LOAD_FIT && \ + (ARCH_SUNXI || RISCV || ARCH_ZYNQMP)) default "u-boot.kwb" if ARCH_KIRKWOOD default "u-boot-with-spl.bin" if ARCH_AT91 && SPL_NAND_SUPPORT default "u-boot-with-spl.imx" if ARCH_MX6 && SPL diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 57946f61fa..7697c74edf 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1961,7 +1961,7 @@ config ARCH_STM32MP config ARCH_ROCKCHIP bool "Support Rockchip SoCs" select BLK - select BINMAN if SPL_OPTEE || (SPL && !ARM64) + select BINMAN if SPL select DM select DM_GPIO select DM_I2C

Signed-off-by: Andrew Abbott andrew@mirx.dev --- doc/board/rockchip/rockchip.rst | 34 +++++++++++---------------------- 1 file changed, 11 insertions(+), 23 deletions(-)
diff --git a/doc/board/rockchip/rockchip.rst b/doc/board/rockchip/rockchip.rst index 4ca7b00b1f..1639ce4f72 100644 --- a/doc/board/rockchip/rockchip.rst +++ b/doc/board/rockchip/rockchip.rst @@ -172,14 +172,14 @@ Flashing SD Card ^^^^^^^
-All Rockchip platforms (except rk3128 which doesn't use SPL) are now -supporting a single boot image using binman and pad_cat. +All Rockchip platforms, (except rk3128 which doesn't use SPL) generate a +SD/MMC full boot image using binman.
To write an image that boots from a SD card (assumed to be /dev/sda):
.. code-block:: bash
- sudo dd if=u-boot-rockchip.bin of=/dev/sda seek=64 + sudo dd if=u-boot-rockchip-sdmmc.bin of=/dev/sda seek=64 sync
eMMC @@ -224,31 +224,19 @@ is u-boot-dtb.img SPI ^^^
-The SPI boot method requires the generation of idbloader.img with help of the mkimage tool. +Some platforms also generate a SPI flash full boot image, controlled by the +CONFIG_ROCKCHIP_SPI_IMAGE configuration option.
-SPL-alone SPI boot image: +This image can be copied onto an SD card and written to SPI flash. Note that +the offset at which the image should be written to is different between SoCs.
-.. code-block:: bash - - ./tools/mkimage -n rk3399 -T rkspi -d spl/u-boot-spl.bin idbloader.img - -TPL+SPL SPI boot image: - -.. code-block:: bash - - ./tools/mkimage -n rk3399 -T rkspi -d tpl/u-boot-tpl.bin:spl/u-boot-spl.bin idbloader.img +* RK3399: 0x0
-Copy SPI boot images into SD card and boot from SD: - -.. code-block:: bash +Replace <offset> with the offset for your SoC::
sf probe - load mmc 1:1 $kernel_addr_r idbloader.img - sf erase 0 +$filesize - sf write $kernel_addr_r 0 ${filesize} - load mmc 1:1 ${kernel_addr_r} u-boot.itb - sf erase 0x60000 +$filesize - sf write $kernel_addr_r 0x60000 ${filesize} + load mmc 1:1 $kernel_addr_r u-boot-rockchip-spi.bin + sf update $kernel_addr_r <offset> ${filesize}
2. Package the image with Rockchip miniloader ---------------------------------------------

Signed-off-by: Andrew Abbott andrew@mirx.dev --- arch/arm/mach-rockchip/rk3399/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/arm/mach-rockchip/rk3399/Kconfig b/arch/arm/mach-rockchip/rk3399/Kconfig index c1f251316c..4a049935df 100644 --- a/arch/arm/mach-rockchip/rk3399/Kconfig +++ b/arch/arm/mach-rockchip/rk3399/Kconfig @@ -84,6 +84,7 @@ config TARGET_ROCK960_RK3399
config TARGET_ROCKPRO64_RK3399 bool "Pine64 Rockpro64 board" + select ROCKCHIP_SPI_IMAGE help Rockro64 is SBC produced by Pine64. Key features:
participants (3)
-
Alper Nebi Yasak
-
Andrew Abbott
-
Johan Jonker