Hi Albert,
On Wed, Nov 11, 2015 at 6:33 PM, Albert ARIBAUD
<[email protected]> wrote:
>> +#if defined(CONFIG_SYS_MALLOC_F_LEN)
>> + sub sp, sp, #CONFIG_SYS_MALLOC_F_LEN
>> + str sp, [r9, #GD_MALLOC_BASE]
>> +#endif
>
> NAK, as this only papers over the actual issue. Board_init_f_mem should
> have set the malloc base in GD. Therefore, rather than doing it again
> later, we must determine why it was not properly done earlier.11111
>
> Can you give me the toolchain version, board name and commit ID that I
> could use to reproduce the *faulty* build and check the generated code?
Sure, I am testing top of head U-boot (cad049907). Target is
mx6sabresd_spl_defconfig.
Toolchain is: arm-linux-gnueabi-gcc (Ubuntu/Linaro 4.7.3-12ubuntu1) 4.7.3
In order to reproduce the malloc failure, please apply this patch
against mainline:
--- a/board/freescale/mx6sabresd/mx6sabresd.c
+++ b/board/freescale/mx6sabresd/mx6sabresd.c
@@ -30,6 +30,7 @@
#include "../common/pfuze.h"
#include <asm/arch/mx6-ddr.h>
#include <usb.h>
+#include <malloc.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -833,6 +834,8 @@ static void spl_dram_init(void)
void board_init_f(ulong dummy)
{
+ void __iomem *ptr;
+
/* setup AIPS and disable watchdog */
arch_cpu_init();
@@ -848,6 +851,12 @@ void board_init_f(ulong dummy)
/* UART clocks enabled and gd valid - init serial console */
preloader_console_init();
+ spl_init();
+
+ ptr = malloc(64);
+ if (!ptr)
+ puts("******* malloc returned NULL\n");
+
/* DDR initialization */
spl_dram_init();
Also, as I just explained to Simon if I remove the ifdefery like this:
--- a/common/init/board_init.c
+++ b/common/init/board_init.c
@@ -50,11 +50,8 @@ ulong board_init_f_mem(ulong top)
#endif
arch_setup_gd(gd_ptr);
-#if defined(CONFIG_SYS_MALLOC_F) && \
- (!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYS_SPL_MALLOC_START))
top -= CONFIG_SYS_MALLOC_F_LEN;
gd->malloc_base = top;
-#endif
return top;
}
Then malloc() works fine in SPL.
So it seems I need to find a way to make CONFIG_SPL_BUILD=n or
CONFIG_SYS_SPL_MALLOC_START=n.
Thanks,
Fabio Estevam
_______________________________________________
U-Boot mailing list
[email protected]
http://lists.denx.de/mailman/listinfo/u-boot