Skip to contentSkip to conversation

Add a config for AM335x High Security EVM

PATCH New Andrew F. Davis 4 participants 14 messages Jan 27, 2017 – Feb 2, 2017

lore
Share & tools
lore
#0 lore raw

v4 cover Add a config for AM335x High Security EVM

Hello all,

This series is [0] and [1] together due to a dependency. Both are modified as suggested in the comments.

Thanks,
Andrew

[0]: https://patchwork.ozlabs.org/patch/713945/
[1]: https://patchwork.ozlabs.org/patch/715820/

Changes from v3:
- Reworked v2 as per Tom's comments

Andrew F. Davis (3):
malloc_simple: Add debug statements to memalign_simple
spl: Remove overwrite of relocated malloc limit
defconfig: Add a config for AM335x High Security EVM

 MAINTAINERS                     |  1 +
 common/malloc_simple.c          |  6 +++-
 common/spl/spl.c                |  7 ++++-
 configs/am335x_hs_evm_defconfig | 62 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 configs/am335x_hs_evm_defconfig
Signature · 1 line
2.11.0
#1 lore raw

PATCH v4 1/3 malloc_simple: Add debug statements to memalign_simple

Add debug statements to memalign_simple to match malloc_simple.

---
 common/malloc_simple.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
common/malloc_simple.c +5 -1
index 0f6bcbcc71..611400265b 100644
@@ -39,10 +39,14 @@ void *memalign_simple(size_t align, size_t bytes)
 
 	addr = ALIGN(gd->malloc_base + gd->malloc_ptr, align);
 	new_ptr = addr + bytes - gd->malloc_base;
-	if (new_ptr > gd->malloc_limit)
+	if (new_ptr > gd->malloc_limit) {
+		debug("space exhausted\n");
 		return NULL;
+	}
+
 	ptr = map_sysmem(addr, bytes);
 	gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr));
+	debug("%lx\n", (ulong)ptr);
 
 	return ptr;
 }
Signature · 1 line
2.11.0
#2 lore raw

PATCH v4 1/3 malloc_simple: Add debug statements to memalign_simple

Quoted 3 lines · Andrew F. Davis

Add debug statements to memalign_simple to match malloc_simple.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170127/9c0033d9/attachment.sig>
#3 lore raw

PATCH v4 1/3 malloc_simple: Add debug statements to memalign_simple

In reply to Andrew F. Davis
Quoted 4 lines · Andrew F. Davis

Add debug statements to memalign_simple to match malloc_simple.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170128/808905cb/attachment.sig>
#4 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

In reply to Andrew F. Davis

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

---
 common/spl/spl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/spl/spl.c +6 -1
index 462c3a2b97..a3808a988b 100644
@@ -183,7 +183,12 @@ int spl_init(void)
 	int ret;
 
 	debug("spl_init()\n");
-#if defined(CONFIG_SYS_MALLOC_F_LEN)
+/*
+ * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
+ * malloc_limit in spl_relocate_stack_gd
+ */
+#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
+	!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
 #ifdef CONFIG_MALLOC_F_ADDR
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
Signature · 1 line
2.11.0
#5 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

Quoted 7 lines · Andrew F. Davis

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170127/00cfb235/attachment.sig>
#6 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

In reply to Andrew F. Davis
Quoted 8 lines · Andrew F. Davis

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170128/72697987/attachment.sig>
#7 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

In reply to Andrew F. Davis

On 27/01/17 16:39, Andrew F. Davis wrote:

Hi,

Quoted 5 lines

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

I am sorry to say this, but this very patch breaks SPL boot on sunxi boards (tested on the Pine64, the Orangepi PC2 (with a similar ARMv8 SoC) and the OrangePi Zero (ARMv7 Allwinner H3 SoC).

U-Boot SPL 2017.03-rc1-00022-gf77309d (Feb 01 2017 - 23:27:19)
DRAM: 1024 MiB
Trying to boot from MMC1
MMC Device 0 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

sunxi boards both use the default CONFIG_SYS_MALLOC_F_LEN=0x400 and CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000.

At the moment the code there is beyond me, so I can't really say how this breaks, but it clearly does: reverting this patch makes U-Boot happy again.

Any ideas?

Cheers,
Andre.

Quoted 25 lines
---
 common/spl/spl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/spl/spl.c +6 -1
index 462c3a2b97..a3808a988b 100644
@@ -183,7 +183,12 @@ int spl_init(void)
 	int ret;
 
 	debug("spl_init()\n");
-#if defined(CONFIG_SYS_MALLOC_F_LEN)
+/*
+ * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
+ * malloc_limit in spl_relocate_stack_gd
+ */
+#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
+	!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
 #ifdef CONFIG_MALLOC_F_ADDR
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
#8 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

Quoted 22 lines · Andr? Przywara

On 27/01/17 16:39, Andrew F. Davis wrote:

Hi,

Quoted 5 lines

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

I am sorry to say this, but this very patch breaks SPL boot on sunxi boards (tested on the Pine64, the Orangepi PC2 (with a similar ARMv8 SoC) and the OrangePi Zero (ARMv7 Allwinner H3 SoC).

U-Boot SPL 2017.03-rc1-00022-gf77309d (Feb 01 2017 - 23:27:19)
DRAM: 1024 MiB
Trying to boot from MMC1
MMC Device 0 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 8 lines

sunxi boards both use the default CONFIG_SYS_MALLOC_F_LEN=0x400 and CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000.

At the moment the code there is beyond me, so I can't really say how this breaks, but it clearly does: reverting this patch makes U-Boot happy again.

Any ideas?

Arg. I'll try and poke at this but my A20-OLinuXino-Lime2 is (FEL at least) booting so I hadn't seen this. Can you confirm that pine64, or these other boards, also fail when FEL booting? I ask since if they pass that way I need to pencil in some time to figure out another way to test that HW, or at least make additional testing of that hardware easier. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170201/3b566edd/attachment.sig>
#9 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

On 02/02/17 00:08, Tom Rini wrote:

Hi Tom,

thanks for the quick reply!

Quoted 30 lines · Andr? Przywara
Quoted 29 lines · Andrew F. Davis

Hi,

Quoted 5 lines

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

I am sorry to say this, but this very patch breaks SPL boot on sunxi boards (tested on the Pine64, the Orangepi PC2 (with a similar ARMv8 SoC) and the OrangePi Zero (ARMv7 Allwinner H3 SoC).

U-Boot SPL 2017.03-rc1-00022-gf77309d (Feb 01 2017 - 23:27:19)
DRAM: 1024 MiB
Trying to boot from MMC1
MMC Device 0 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

sunxi boards both use the default CONFIG_SYS_MALLOC_F_LEN=0x400 and CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000.

At the moment the code there is beyond me, so I can't really say how this breaks, but it clearly does: reverting this patch makes U-Boot happy again.

Quoted 8 lines
Quoted 1 line

Any ideas?

Arg. I'll try and poke at this but my A20-OLinuXino-Lime2 is (FEL at least) booting so I hadn't seen this. Can you confirm that pine64, or these other boards, also fail when FEL booting? I ask since if they pass that way I need to pencil in some time to figure out another way to test that HW, or at least make additional testing of that hardware easier. Thanks!

Yeah, sorry, but FEL boot seems to work, with or without this patch. I guess it's due to the MMC driver malloc'ing something, which would happen after DRAM availability. FEL boot just returns to the caller, so no malloc.
And I agree it's nasty to do boot testing with SD cards, I use FEL mostly as well.

Cheers,
Andre.

#10 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

In reply to André Przywara
Quoted 22 lines · Andr? Przywara

On 27/01/17 16:39, Andrew F. Davis wrote:

Hi,

Quoted 5 lines

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

I am sorry to say this, but this very patch breaks SPL boot on sunxi boards (tested on the Pine64, the Orangepi PC2 (with a similar ARMv8 SoC) and the OrangePi Zero (ARMv7 Allwinner H3 SoC).

U-Boot SPL 2017.03-rc1-00022-gf77309d (Feb 01 2017 - 23:27:19)
DRAM: 1024 MiB
Trying to boot from MMC1
MMC Device 0 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 2 lines

sunxi boards both use the default CONFIG_SYS_MALLOC_F_LEN=0x400 and CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000.

In your case, before this patch malloc_limit is MALLOC_F_LEN(0x400), after this patch malloc_limit is SPL_STACK_R_MALLOC_SIMPLE_LEN(0x100000) . Stack relocated address is 0x4fe00000(is this in DDR?). SPL_STACK_R is mainly targetted for relocating SPL stack to DDR.
- Is 1MB available at 0x4fe00000?
- Can you reduce the size or change SPL_STACK_R to DDR and verify?

Thanks and regards,
Lokesh

Quoted 36 lines

At the moment the code there is beyond me, so I can't really say how this breaks, but it clearly does: reverting this patch makes U-Boot happy again.

Any ideas?

Cheers,
Andre.

Quoted 25 lines
---
 common/spl/spl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/spl/spl.c +6 -1
index 462c3a2b97..a3808a988b 100644
@@ -183,7 +183,12 @@ int spl_init(void)
 	int ret;
 
 	debug("spl_init()\n");
-#if defined(CONFIG_SYS_MALLOC_F_LEN)
+/*
+ * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
+ * malloc_limit in spl_relocate_stack_gd
+ */
+#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
+	!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
 #ifdef CONFIG_MALLOC_F_ADDR
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
#11 lore raw

PATCH v4 2/3 spl: Remove overwrite of relocated malloc limit

Hi Lokesh,

thanks for having a look!

Quoted 25 lines · Lokesh Vutla
Quoted 22 lines · Andr? Przywara

On 27/01/17 16:39, Andrew F. Davis wrote:

Hi,

Quoted 5 lines

spl_init on some boards is called after stack and heap relocation, on some platforms spl_relocate_stack_gd is called to handle setting the limit to its value CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN when simple SPL malloc is enabled during relocation. spl_init should then not re-assign the old pre-relocation limit when this is defined.

I am sorry to say this, but this very patch breaks SPL boot on sunxi boards (tested on the Pine64, the Orangepi PC2 (with a similar ARMv8 SoC) and the OrangePi Zero (ARMv7 Allwinner H3 SoC).

U-Boot SPL 2017.03-rc1-00022-gf77309d (Feb 01 2017 - 23:27:19)
DRAM: 1024 MiB
Trying to boot from MMC1
MMC Device 0 not found
spl: could not find mmc device. error: -19
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Quoted 7 lines
Quoted 2 lines

sunxi boards both use the default CONFIG_SYS_MALLOC_F_LEN=0x400 and CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x100000.

In your case, before this patch malloc_limit is MALLOC_F_LEN(0x400), after this patch malloc_limit is SPL_STACK_R_MALLOC_SIMPLE_LEN(0x100000) . Stack relocated address is 0x4fe00000(is this in DDR?). SPL_STACK_R is mainly targetted for relocating SPL stack to DDR.

Yes, this is at DDR (which starts at 1G).

Quoted 1 line

- Is 1MB available at 0x4fe00000?

Yes, the smallest board I have has 256MB, though I've seen this on boards with one GB as well. But even in the worst case this is 2 MB below end of DDR.
The BSS is at 0x4ff80000, but that shouldn't conflict then.

Is this address actually the _starting_ address for the malloc heap? So malloc uses memory above this address, the stack below? Or does malloc use some stack allocation for its purpose?

Quoted 1 line

- Can you reduce the size or change SPL_STACK_R to DDR and verify?

I will check tonight (no boards here at the moment).

Thanks for the explanation and the pointers, this gives me something to debug on.

Cheers,
Andre

Quoted 40 lines

Thanks and regards,
Lokesh

Quoted 36 lines

At the moment the code there is beyond me, so I can't really say how this breaks, but it clearly does: reverting this patch makes U-Boot happy again.

Any ideas?

Cheers,
Andre.

Quoted 25 lines
---
 common/spl/spl.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
common/spl/spl.c +6 -1
index 462c3a2b97..a3808a988b 100644
@@ -183,7 +183,12 @@ int spl_init(void)
 	int ret;
 
 	debug("spl_init()\n");
-#if defined(CONFIG_SYS_MALLOC_F_LEN)
+/*
+ * with CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN we set malloc_base and
+ * malloc_limit in spl_relocate_stack_gd
+ */
+#if defined(CONFIG_SYS_MALLOC_F_LEN) && \
+	!defined(CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN)
 #ifdef CONFIG_MALLOC_F_ADDR
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
#12 lore raw

PATCH v4 3/3 defconfig: Add a config for AM335x High Security EVM

In reply to Andrew F. Davis

Add a new defconfig file for the AM335x High Security EVM. This config is specific for the case of memory device booting. Memory device booting is handled separatly from peripheral booting on HS devices as the load address changes.

This defconfig is the same as for the non-secure part, except for:
CONFIG_TI_SECURE_DEVICE option set to 'y' CONFIG_ISW_ENTRY_ADDR updated for secure images. CONFIG_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_SPL_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_USE_TINY_PRINTF option set to 'y' to reduce SPL size CONFIG_SPL_SYS_MALLOC_SIMPLE set to 'y' to reduce SPL size

---
 MAINTAINERS                     |  1 +
 configs/am335x_hs_evm_defconfig | 62 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)
 create mode 100644 configs/am335x_hs_evm_defconfig
MAINTAINERS +1 -0
index 0e05c0ecff..eaa2c3bbb8 100644
@@ -441,6 +441,7 @@ F:	arch/arm/mach-omap2/omap5/sec_entry_cpu1.S
 F:	arch/arm/mach-omap2/omap5/sec-fxns.c
 F:	arch/arm/mach-omap2/sec-common.c
 F:	arch/arm/mach-omap2/config_secure.mk
+F:	configs/am335x_hs_evm_defconfig
 F:	configs/am43xx_hs_evm_defconfig
 F:	configs/am57xx_hs_evm_defconfig
 F:	configs/dra7xx_hs_evm_defconfig
configs/am335x_hs_evm_defconfig new file +62 -0

62 lines not on this page · raw message

Signature · 1 line
2.11.0
#13 lore raw

PATCH v4 3/3 defconfig: Add a config for AM335x High Security EVM

Quoted 13 lines · Andrew F. Davis

Add a new defconfig file for the AM335x High Security EVM. This config is specific for the case of memory device booting. Memory device booting is handled separatly from peripheral booting on HS devices as the load address changes.

This defconfig is the same as for the non-secure part, except for:
CONFIG_TI_SECURE_DEVICE option set to 'y' CONFIG_ISW_ENTRY_ADDR updated for secure images. CONFIG_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_SPL_FIT_IMAGE_POST_PROCESS option set to 'y' CONFIG_USE_TINY_PRINTF option set to 'y' to reduce SPL size CONFIG_SPL_SYS_MALLOC_SIMPLE set to 'y' to reduce SPL size

Quoted 2 lines

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170128/6d7bbba5/attachment.sig>