Hi Alexey, On 2026-07-13T10:02:41, Alexey Charkov <[email protected]> wrote: > rockchip: mkimage: Add rk3576 align and sd-card workaround > > The BootROM on RK3576 has an issue loading boot images from an SD-card. > This issue can be worked around by injecting an initial boot image > before TPL that: > > writel(0x3ffff800, 0x3ff803b0) > > Prepend an image containing binary code that does this and return to > BootROM to load next image, TPL. > > Signed-off-by: Jonas Karlman <[email protected]> > [switch from pre-built binary to from-source build via existing Makefiles, > add commentary on what the magic write does based on JTAG debugging of > the boot process] > Signed-off-by: Alexey Charkov <[email protected]> > > arch/arm/mach-rockchip/rk3576/Makefile | 10 +++++++++ > arch/arm/mach-rockchip/rk3576/rk3576-boost.c | 31 > ++++++++++++++++++++++++++++ > tools/rkcommon.c | 22 +++++++++++++++++++- > 3 files changed, 62 insertions(+), 1 deletion(-)
> diff --git a/arch/arm/mach-rockchip/rk3576/Makefile > b/arch/arm/mach-rockchip/rk3576/Makefile > @@ -7,3 +7,13 @@ > +quiet_cmd_rk3576boost = BOOST $@ > + cmd_rk3576boost = $(CC) -nostdlib -ffreestanding -Os -c -o [email protected] $< && \ > + $(OBJCOPY) -O binary -j .text [email protected] $@ Since the object is never linked, any relocations end up unapplied in the output binary. Toolchains defaulting to -fstack-protector-strong or PIE can emit references to __stack_chk_guard or GOT loads, which objcopy silently bakes in as broken code. Please can you add -fno-stack-protector and -fno-pic (or reuse the kbuild flags)? Also, nothing guarantees that _start() is at offset 0 of .text if a second function is ever added to this file - a comment on that constraint would help. The intermediate [email protected] file also needs adding to clean-files. > diff --git a/arch/arm/mach-rockchip/rk3576/rk3576-boost.c > b/arch/arm/mach-rockchip/rk3576/rk3576-boost.c > @@ -0,0 +1,31 @@ > + uint32_t *sram = (void *)(SYS_SRAM_BASE + OFFSET); This is effectively an MMIO-style poke into live ROM state, so please make it a volatile pointer (writel() semantics) rather than relying on the optimiser keeping a plain store. > diff --git a/tools/rkcommon.c b/tools/rkcommon.c > @@ -288,6 +288,26 @@ int rkcommon_check_params(struct image_tool_params > *params) > + if (!strcmp(params->imagename, "rk3576")) { > + char *boost = "arch/arm/mach-rockchip/rk3576/rk3576-boost.bin"; As mentioned on the cover letter, mkimage is shipped standalone (e.g. as u-boot-tools) and is documented for creating idbloader.img by hand, so with this change any rk3576 image can only be created from a U-Boot build tree containing this file. Passing the boost binary in as a normal datafile from the build system would keep the tool independent of the source layout. Also, just to check: this path is shared by rksd and rkspi, so the workaround is prepended to SPI images as well - is that intended, given the issue is SD-card specific? If binman is used to create the image, it could pass mkimage a parameter pointing to the file. > diff --git a/tools/rkcommon.c b/tools/rkcommon.c > @@ -288,6 +288,26 @@ int rkcommon_check_params(struct image_tool_params > *params) > + for (i = ARRAY_SIZE(spl_params.images) - 1; i > 0; i--) > + spl_params.images[i] = spl_params.images[i - 1]; Patch 5 allows four input files; if all four slots are used, this shift silently drops the last image. Please can you error out when images[3] is already set? Regards, Simon
