From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fabio Estevam Date: Wed, 11 Nov 2015 19:00:41 -0200 Subject: [U-Boot] [PATCH] ARM: crt0: Pass malloc base address In-Reply-To: References: <1447273397-22833-1-git-send-email-festevam@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Simon and Albert, On Wed, Nov 11, 2015 at 6:41 PM, Fabio Estevam wrote: > Hi Simon, > > On Wed, Nov 11, 2015 at 6:26 PM, Simon Glass wrote: > >> Thanks for digging into this. But this should be set up in board_init_f_mem(): >> >> #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 >> >> Is it possible that the #ifdef logic is wrong for your board? > > Good point. Looks like this is the problem indeed. > > I have manually removed the #ifdef logic just for testing: > > --- 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; > } > > ,and then malloc() works fine in SPL. If I change the logic like this then malloc() works: --- a/common/init/board_init.c +++ b/common/init/board_init.c @@ -51,7 +51,7 @@ ulong board_init_f_mem(ulong top) arch_setup_gd(gd_ptr); #if defined(CONFIG_SYS_MALLOC_F) && \ - (!defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYS_SPL_MALLOC_START)) + (defined(CONFIG_SPL_BUILD) || !defined(CONFIG_SYS_SPL_MALLOC_START)) top -= CONFIG_SYS_MALLOC_F_LEN; gd->malloc_base = top; #endif Shouldn't we test for defined(CONFIG_SPL_BUILD) instead of !defined(CONFIG_SPL_BUILD)? Thanks