Commit 9ac4fc82 authored by Fabio Estevam's avatar Fabio Estevam Committed by Tom Rini

board_init: Change the logic to setup malloc_base

Prior to commit 5ba534d2 ("arm: Switch 32-bit ARM to using generic
global_data setup") we used to have assembly code that configured the
malloc_base address.

Since this commit we use the board_init_f_mem() function in C to setup
malloc_base address.

In board_init_f_mem() there was a deliberate choice to support only
early malloc() or full malloc() in SPL, but not both.

Adapt this logic to allow both to be used, one after the other, in SPL.

This issue has been observed in a Congatec board, where we need to
retrieve the manufacturing information from the SPI NOR (the SPI API
calls malloc) prior to configuring the DRAM. In this case as malloc_base
was not configured we always see malloc to fail.

With this change we are able to use malloc in SPL prior to DRAM gets

Also update the CONFIG_SYS_SPL_MALLOC_START entry in the README file.
Signed-off-by: default avatarFabio Estevam <>
Reviewed-by: default avatarSimon Glass <>
parent bc80109b
......@@ -3577,6 +3577,9 @@ FIT uImage format:
Starting address of the malloc pool used in SPL.
When this option is set the full malloc is used in SPL and
it is set up by spl_init() and before that, the simple malloc()
can be used if CONFIG_SYS_MALLOC_F is defined.
The size of the malloc pool used in SPL.
......@@ -50,8 +50,7 @@ ulong board_init_f_mem(ulong top)
#if defined(CONFIG_SYS_MALLOC_F) && \
#if defined(CONFIG_SYS_MALLOC_F)
gd->malloc_base = top;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment