rockchip: mkimage: Update init code size limit for PX30/RK3326/RK3328
cover rockchip: mkimage: Update init code size limit for PX30/RK3326/RK3328
mkimage is enforcing a smaller init code size limit than what BootROM can handle on PX30/RK3326 and RK3328.
- PX30/RK3326 is limited to 10 KiB when 12 KiB is supported.
- RK3328 is limited to 30 KiB when 32 KiB is supported.
This series updates mkimage to allow using max possible init code size supported on the affected SoCs.
Due to end of SRAM typically being used as TPL_STACK, use of the fully supported init code size is not always possible using current defconfig. However, if stack and malloc area is placed in e.g. PMU SRAM or in the BootROM reserved area the init code could use all available space.
BootROM on RK3288 can support up to 80 KiB init code size when loaded over USB, however only 32 KiB is supported when loaded from MMC. So current limit of 32 KiB have been left unchanged for RK3288.
Jonas Karlman (2):
rockchip: mkimage: Update init code size limit for PX30/RK3326
rockchip: mkimage: Update init code size limit for RK3328
tools/rkcommon.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.55.0
PATCH 1/2 rockchip: mkimage: Update init code size limit for PX30/RK3326
The PX30/RK3326 has 16 KiB SYSTEM SRAM at [0xff0e0000, 0xff0e4000) and 8 KiB PMU SRAM at [0xff020000, 0xff022000). With 4 KiB of the initial SYSTEM SRAM typically reserved for BootROM during early boot.
BootROM will load init code of up to 12 KiB (0x3000 bytes) to address 0xff0e1000 in SYSTEM SRAM, before jumping to it.
BootROM of RK3326 typically jumps to init code with following registers:
x0: 00000000 00000000
x1: 00000000 a000414c
x2: 00000000 00000000
x3: 00000000 00000000
sp: 00000000 ff0e0f50
mkimage is enforcing a 10 KiB init code size limit for PX30/RK3326. However, the BootRAM can load up to 12 KiB of init code.
Change the init code size limit to 12 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on PX30/RK3326.
--- tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkcommon.c +1 -1
@@ -137,7 +137,7 @@ struct spl_info { };static struct spl_info spl_infos[] = { - {"px30" ,"RK33" ,0x2800 , false,RK_HEADER_V1 }, + {"px30" ,"RK33" ,0x4000 -0x1000 , false,RK_HEADER_V1 }, {"rk3036" ,"RK30" ,0x1000 , false,RK_HEADER_V1 }, {"rk3066" ,"RK30" ,0x8000 -0x800 , true,RK_HEADER_V1 }, {"rk3128" ,"RK31" ,0x1800 , false,RK_HEADER_V1 },
Signature · 1 line
2.55.0
Re: [PATCH 1/2] rockchip: mkimage: Update init code size limit for PX30/RK3326
Hi Jonas,
Quoted 16 lines · Jonas Karlman
The PX30/RK3326 has 16 KiB SYSTEM SRAM at [
0xff0e0000,0xff0e4000) and 8 KiB PMU SRAM at [0xff020000,0xff022000). With 4 KiB of the initial SYSTEM SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 12 KiB (
0x3000bytes) to address0xff0e1000in SYSTEM SRAM, before jumping to it.BootROM of RK3326 typically jumps to init code with following registers:
x0: 00000000 00000000 x1: 00000000 a000414c x2: 00000000 00000000 x3: 00000000 00000000 sp: 00000000 ff0e0f50
Quoted 5 lines
mkimage is enforcing a 10 KiB init code size limit for PX30/RK3326. However, the BootRAM can load up to 12 KiB of init code.
Quoted 1 line
Change the init code size limit to 12 KiB using the <size> - <reserved>
pattern to closer match the actual limit of BootROM on PX30/RK3326.
This matches the current value in Rockchip's downstream fork, c.f. https://github.com/rockchip-linux/u-boot/blob/next-dev/tools/rkcommon.c and specifically https://github.com/rockchip-linux/u-boot/commit/3bbe0d2f9129303e9f36d3ddfa3485653e188ecd. I will add this to the commit log when merging.
Thanks!
Quentin
PATCH 2/2 rockchip: mkimage: Update init code size limit for RK3328
In reply to Jonas KarlmanThe RK3328 has 36 KiB SRAM at [0xff090000, 0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.
BootROM will load init code of up to 32 KiB (0x8000 bytes) to address 0xff091000 in SRAM, before jumping to it.
BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004
x1: 00000000 32334b52
x2: 00000000 ff520000
x3: 00000000 ff500000
sp: 00000000 ff090f50
mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
--- tools/rkcommon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rkcommon.c +1 -1
@@ -145,7 +145,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 - 0x800, false, RK_HEADER_V1 }, + { "rk3328", "RK32", 0x9000 - 0x1000, false, RK_HEADER_V1 }, { "rk3368", "RK33", 0x8000 - 0x1000, false, RK_HEADER_V1 }, { "rk3399", "RK33", 0x30000 - 0x2000, false, RK_HEADER_V1 }, { "rk3506", "RK35", 0xC000 - 0x1000, false, RK_HEADER_V2 },
Signature · 1 line
2.55.0
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
Hi Jonas,
Quoted 15 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50
Quoted 6 lines
mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses 0x8000 - 0x800 so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.
Cheers,
Quentin
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.
Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so _reset was placed at the very end of binary, in the last and lost 2 KiB.
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in rkcommon.c beside PX30 and RK3328 matches the runtime limitations.
On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Please reconsider and/or hopefully Kever is able to confirm my findings.
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
Hi Jonas,
Quoted 39 lines · Jonas Karlman
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so
_resetwas placed at the very end of binary, in the last and lost 2 KiB.
Quoted 9 lines
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
How can you be sure that we aren't corrupting the BootROM stack? Between TPL and SPL we actually go back to BootROM so code from there run for sure after TPL has run.
Quoted 9 lines
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in
rkcommon.cbeside PX30 and RK3328 matches the runtime limitations.On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Please reconsider and/or hopefully Kever is able to confirm my findings.
I'm not sure we'll get to see Kever much anymore and I don't know who exactly we should be asking. I've been told Chaoyi Chen might be a good point of contact now, so trying this here.
@Chaoyi, can you confirm we can use 32KiB of SRAM on RK3328? See https://lore.kernel.org/u-boot/[email protected]/t/#u for the whole context.
Cheers,
Quentin
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
Hi Quentin,
Quoted 52 lines · Quentin Schulz
Hi Jonas,
Quoted 39 lines · Jonas Karlman
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so
_resetwas placed at the very end of binary, in the last and lost 2 KiB.Quoted 9 lines
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
Quoted 3 lines
How can you be sure that we aren't corrupting the BootROM stack? Between TPL and SPL we actually go back to BootROM so code from there run for sure after TPL has run.
We cannot be 100% sure, however as stated in the commit message, the BootROM stack is located in the initial 4 KiB of SRAM, [0xff090000, 0xff091000), and its stack-pointer is typically at 0xff090f50 when entering into the init code, i.e. it matches the pattern used for all other Rockchip SoCs where the BootROM stack is located before the init code load address.
The issue with RK3328 is likely that some datasheets/TRMs mentioned 32 KiB of SRAM in some places and the correct 36 KiB in others. Right now, we reserve initial 4 KiB for BootROM, allow 30 KiB for init code and for no reason restrict use of the last 2 KiB of SRAM.
The limits imposed by mkimage should not care about what the init code does, it should only impose real HW limits and not make assumption on what U-Boot TPL is doing. Let's say I created a custom binary that takes up entire load address to end of SRAM and can safely run, right now mkimage cannot be used for such binary due to this self-imposed limit, for all other Rockchip SoCs such binary would be accepted by mkimage.
Any limits e.g. due to use of TPL stack, malloc area or back to BootROM feature is specific to the U-Boot TPL binary and should be limited using TPL_MAX_SIZE or similar, not by the init code size limit of mkimage.
Quoted 11 lines
Quoted 10 lines
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in
rkcommon.cbeside PX30 and RK3328 matches the runtime limitations.On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Please reconsider and/or hopefully Kever is able to confirm my findings.
Quoted 7 lines
I'm not sure we'll get to see Kever much anymore and I don't know who exactly we should be asking. I've been told Chaoyi Chen might be a good point of contact now, so trying this here.
@Chaoyi, can you confirm we can use 32KiB of SRAM on RK3328? See
https://lore.kernel.org/u-boot/[email protected]/t/#u
for the whole context.
Would be nice to get a confirmation, however my runtime testing should already help prove that we can load and run a 32 KiB binary on this SoC, and that the limit imposed by mkimage is correct for all other SoCs I could run same test on: rk3228, rk3288, rk3308, rk3326 (after patch 1), rk3399, all rk35xx variants, rv1106, rv1103b and rv1126b.
Regards,
Jonas
Quoted 3 lines
Cheers,
Quentin
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
In reply to Quentin SchulzHi Quentin,
Quoted 61 lines · Quentin Schulz
Hi Jonas,
Quoted 39 lines · Jonas Karlman
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so
_resetwas placed at the very end of binary, in the last and lost 2 KiB.Quoted 9 lines
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
How can you be sure that we aren't corrupting the BootROM stack? Between TPL and SPL we actually go back to BootROM so code from there run for sure after TPL has run.
Quoted 7 lines
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in
rkcommon.cbeside PX30 and RK3328 matches the runtime limitations.On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Quoted 7 lines
Quoted 2 lines
Please reconsider and/or hopefully Kever is able to confirm my findings.
I'm not sure we'll get to see Kever much anymore and I don't know who exactly we should be asking. I've been told Chaoyi Chen might be a good point of contact now, so trying this here.
@Chaoyi, can you confirm we can use 32KiB of SRAM on RK3328? See https://lore.kernel.org/u-boot/[email protected]/t/#u for the whole context.
I'm not quite sure whether I caught what you meant. And I guess you want to know the stack and data ranges used by the RK3288 Bootrom?
If that is the case, then the RK3288 BootROM will use the 0–4KB space for the stack and data, while the remaining SRAM stores the init code.
Signature · 2 lines
Best, Chaoyi
Quentin Schulz
Acked-byRe: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
Hi Chaoyi,
Quoted 69 lines · Chaoyi Chen
Hi Quentin,
Quoted 66 lines · Quentin Schulz
Hi Jonas,
Quoted 39 lines · Jonas Karlman
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so
_resetwas placed at the very end of binary, in the last and lost 2 KiB.Quoted 9 lines
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
How can you be sure that we aren't corrupting the BootROM stack? Between TPL and SPL we actually go back to BootROM so code from there run for sure after TPL has run.
Quoted 9 lines
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in
rkcommon.cbeside PX30 and RK3328 matches the runtime limitations.On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Please reconsider and/or hopefully Kever is able to confirm my findings.
I'm not sure we'll get to see Kever much anymore and I don't know who exactly we should be asking. I've been told Chaoyi Chen might be a good point of contact now, so trying this here.
Quoted 9 lines
Quoted 2 lines
@Chaoyi, can you confirm we can use 32KiB of SRAM on RK3328? See https://lore.kernel.org/u-boot/[email protected]/t/#u for the whole context.
I'm not quite sure whether I caught what you meant. And I guess you want to know the stack and data ranges used by the RK3288 Bootrom?
If that is the case, then the RK3288 BootROM will use the 0–4KB space for the stack and data, while the remaining SRAM stores the init code.
With the SRAM being 36KiB according to the RK3328 v1.2 datasheet and your comment above, we should be able to use 32KiB for the init code as stated by Jonas in this patch.
However, Rockchip's downstream U-Boot limits the size to 30KiB (0x8000 - 0x800), c.f. https://github.com/rockchip-linux/u-boot/blob/1c535d65b8509f388d09e49fb6961f49fda35a1d/tools/rkcommon.c#L143. I was thus asking for confirmation because we are about to diverge from Rockchip's downstream U-Boot and I don't like to do this, especially for things we (non-Rockchip people) cannot know if it's not documented.
My understanding with your answer is that Jonas's patch to increase the max init code size from 30KiB to 32KiB is fine, and I will therefore merge this patch. Please shout in the next few days if that is incorrect, so I don't merge it.
Thanks Chaoyi for the prompt answer, much appreciated!
Cheers,
Quentin
Re: [PATCH 2/2] rockchip: mkimage: Update init code size limit for RK3328
In reply to Chaoyi ChenQuoted 69 lines · Chaoyi Chen
Hi Quentin,
Quoted 66 lines · Quentin Schulz
Hi Jonas,
Quoted 39 lines · Jonas Karlman
Hi Quentin,
Quoted 20 lines · Quentin Schulz
Hi Jonas,
Quoted 17 lines · Jonas Karlman
The RK3328 has 36 KiB SRAM at [
0xff090000,0xff099000). With 4 KiB of the initial SRAM typically reserved for BootROM during early boot.BootROM will load init code of up to 32 KiB (
0x8000bytes) to address0xff091000in SRAM, before jumping to it.BootROM typically jumps to init code with following registers:
x0: 00000000 ff091004 x1: 00000000 32334b52 x2: 00000000 ff520000 x3: 00000000 ff500000 sp: 00000000 ff090f50mkimage is enforcing a 30 KiB init code size limit for RK3328. However, the BootRAM can load up to 32 KiB of init code.
s/BootRAM/BootROM/
Quoted 7 lines
Quoted 4 lines
Change the init code size limit to 32 KiB using the <size> - <reserved> pattern to closer match the actual limit of BootROM on RK3328.
Downstream still uses
0x8000-0x800so unless someone from Rockchip confirms this is safe, I would rather not modify what we have today.Maybe my commit message was unclear, but I have runtime confirmed that BootROM is capable of loading binary code up to 32 KiB from SD-card and eMMC and the code was fully functional even when padded so
_resetwas placed at the very end of binary, in the last and lost 2 KiB.Quoted 9 lines
Most likely the mkimage size limit was used to impose limitations for stack and malloc area, very similar to the issue with PX30/RK3326.
Runtime test consisted of running a minimal <2 KiB TPL binary that only initialized DEBUG UART and dumped passed x0-x6/r0-r6 and stack pointer. The binary used no malloc area, its stack was pointed to PMU SRAM or at half of BootROM reserved stack area, and the binary was .space padded to push code to very end of the loaded binary.
How can you be sure that we aren't corrupting the BootROM stack? Between TPL and SPL we actually go back to BootROM so code from there run for sure after TPL has run.
Quoted 9 lines
I did similar runtime tests on all rk3288/rk33xx/rk35xx/rv11xx SoCs I have access to and all current limits in
rkcommon.cbeside PX30 and RK3328 matches the runtime limitations.On RK3288 (96 KiB SRAM) we can even load a binary up to full 96 KiB, however from SD-card, only current limit of 32 KiB worked.
Please reconsider and/or hopefully Kever is able to confirm my findings.
I'm not sure we'll get to see Kever much anymore and I don't know who exactly we should be asking. I've been told Chaoyi Chen might be a good point of contact now, so trying this here.
Quoted 9 lines
Quoted 2 lines
@Chaoyi, can you confirm we can use 32KiB of SRAM on RK3328? See https://lore.kernel.org/u-boot/[email protected]/t/#u for the whole context.
I'm not quite sure whether I caught what you meant. And I guess you want to know the stack and data ranges used by the RK3288 Bootrom?
If that is the case, then the RK3288 BootROM will use the 0–4KB space for the stack and data, while the remaining SRAM stores the init code.
Typo.. It is RK3328.
Signature · 2 lines
Best, Chaoyi
Re: (subset) [PATCH 0/2] rockchip: mkimage: Update init code size limit for PX30/RK3326/RK3328
In reply to Jonas KarlmanQuoted 10 lines · Jonas Karlman
mkimage is enforcing a smaller init code size limit than what BootROM can handle on PX30/RK3326 and RK3328.
- PX30/RK3326 is limited to 10 KiB when 12 KiB is supported.
- RK3328 is limited to 30 KiB when 32 KiB is supported.This series updates mkimage to allow using max possible init code size supported on the affected SoCs.
[...]
Applied to https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip (u-boot-rockchip-2027.01), thanks!
[2/2] rockchip: mkimage: Update init code size limit for RK3328
https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/7fcc2b3948860d1146bc84bb523ba185d892b09c
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
Re: (subset) [PATCH 0/2] rockchip: mkimage: Update init code size limit for PX30/RK3326/RK3328
Quoted 10 lines · Quentin Schulz
Quoted 9 lines · Jonas Karlman
mkimage is enforcing a smaller init code size limit than what BootROM can handle on PX30/RK3326 and RK3328.
- PX30/RK3326 is limited to 10 KiB when 12 KiB is supported.
- RK3328 is limited to 30 KiB when 32 KiB is supported.This series updates mkimage to allow using max possible init code size supported on the affected SoCs.
Quoted 7 lines
Quoted 1 line
[...]
Applied to https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip (u-boot-rockchip-2027.01), thanks!
[2/2] rockchip: mkimage: Update init code size limit for RK3328
https://git.u-boot-project.org/u-boot/custodians/u-boot-rockchip/-/commit/7fcc2b3948860d1146bc84bb523ba185d892b09c
And b4 ty missed that I also merged patch 1/2:
Cheers,
Quentin