
Hi,
On 6 August 2015 at 12:24, Fabio Estevam festevam@gmail.com wrote:
On Thu, Aug 6, 2015 at 2:03 PM, Stefano Babic sbabic@denx.de wrote:
This is in RAM, of course. Increasing the size by 3KiB is not IMHO for i.MX6 a problem, there is enough space in IRAM. But what is surprising is that Fabio gets a Null pointer by malloc().
Yes, so I did a simpler patch that shows the malloc() issue with SPL:
--- a/board/freescale/mx6sabresd/mx6sabresd.c +++ b/board/freescale/mx6sabresd/mx6sabresd.c @@ -692,6 +692,7 @@ int checkboard(void) #ifdef CONFIG_SPL_BUILD #include <spl.h> #include <libfdt.h> +#include <malloc.h>
const struct mx6dq_iomux_ddr_regs mx6_ddr_ioregs = { .dram_sdclk_0 = 0x00020030, @@ -822,6 +823,7 @@ static void spl_dram_init(void)
void board_init_f(ulong dummy) {
void __iomem *ptr; /* setup AIPS and disable watchdog */ arch_cpu_init();
@@ -837,6 +839,10 @@ void board_init_f(ulong dummy) /* UART clocks enabled and gd valid - init serial console */ preloader_console_init();
ptr = malloc(64);
if (!ptr)
puts("*** malloc returned NULL\n");
/* DDR initialization */ spl_dram_init();
when I run it:
U-Boot SPL 2015.07-08201-gfb44bcd-dirty (Aug 06 2015 - 15:19:54) *** malloc returned NULL
Even if I put the malloc() after spl_dram_init() it still returns NULL.
Please check the README about the SPL flow. From what I can see malloc() is not available before board_init_r() in SPL.
However, if you add a call to spl_init() from your board_init_f(), then early malloc would be available. Enable this with CONFIG_SYS_MALLOC_F_... as people explained.
It would be nice if someone could tidy this up so there is only one generic board_init_f(), and it calls board-specific code from there.
Regards, Simon