[U-Boot] Using spi_alloc_slave() from SPL

Fabio Estevam festevam at gmail.com
Thu Aug 6 20:24:59 CEST 2015


On Thu, Aug 6, 2015 at 2:03 PM, Stefano Babic <sbabic at 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.

Regards,

Fabio Estevam


More information about the U-Boot mailing list