[U-Boot] Using spi_alloc_slave() from SPL

Fabio Estevam festevam at gmail.com
Thu Aug 6 21:29:02 CEST 2015


On Thu, Aug 6, 2015 at 3:24 PM, Fabio Estevam <festevam at gmail.com> wrote:
> 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:

Ok, with this change malloc() does not fail 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,12 @@ void board_init_f(ulong dummy)
        /* UART clocks enabled and gd valid - init serial console */
        preloader_console_init();

+       gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+       gd->malloc_ptr = 0;
+       ptr = malloc(64);
+       if (!ptr)
+               puts("*** malloc returned NULL\n");
+
        /* DDR initialization */
        spl_dram_init();

Regards,

Fabio Estevam


More information about the U-Boot mailing list