MLK-17153-2 imx8mq_arm2: Resolve malloc memory problem for SPL NAND boot
authorYe Li <ye.li@nxp.com>
Tue, 12 Dec 2017 06:02:19 +0000 (00:02 -0600)
committerYe Li <ye.li@nxp.com>
Fri, 24 May 2019 09:25:09 +0000 (02:25 -0700)
When using SPL NAND boot, the required malloc memory is larger than SD/eMMC boot.
Since we have used out OCRAM (for ATF) and OCRAM_S, there is no enough memory could be
allocated.

The solution is moving the malloc memory pool to DDR. The malloc pool is initialized in
board_init_r, so we moved the VDD_DRAM adjustment and DDR init to board_init_f. Then the DDR
can setup before memory pool initialization. Because the i2c and PMIC driver needs to malloc
data, this change has to enable malloc_f pool by setting CONFIG_MALLOC_F_ADDR to previous
malloc address on OCRAM_S.

Signed-off-by: Ye Li <ye.li@nxp.com>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
(cherry picked from commit ab1895fb5e38d216ff86de292a44776099d159ab)
(cherry picked from commit de084efbc91de971f10c745bbc94f960cdb813a9)

board/freescale/imx8mq_arm2/spl.c
include/configs/imx8mq_arm2.h

index fe09750..6b095ae 100644 (file)
@@ -197,16 +197,6 @@ int power_init_board(void)
 
 void spl_board_init(void)
 {
-       enable_tzc380();
-
-       /* Adjust pmic voltage to 1.0V for 800M */
-       setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
-
-       power_init_board();
-
-       /* DDR initialization */
-       spl_dram_init();
-
        /* Serial download mode */
        if (is_usb_boot()) {
                puts("Back to ROM, SDP\n");
@@ -227,6 +217,8 @@ int board_fit_config_name_match(const char *name)
 
 void board_init_f(ulong dummy)
 {
+       int ret;
+
        /* Clear global data */
        memset((void *)gd, 0, sizeof(gd_t));
 
@@ -243,5 +235,21 @@ void board_init_f(ulong dummy)
        /* Clear the BSS. */
        memset(__bss_start, 0, __bss_end - __bss_start);
 
+       ret = spl_init();
+       if (ret) {
+               debug("spl_init() failed: %d\n", ret);
+               hang();
+       }
+
+       enable_tzc380();
+
+       /* Adjust pmic voltage VDD_DRAM to 1.0V for DRAM RUN >= 2400MHZ */
+       setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
+
+       power_init_board();
+
+       /* DDR initialization */
+       spl_dram_init();
+
        board_init_r(NULL, 0);
 }
index 02bb9ad..0dee1ab 100644 (file)
 #define CONFIG_SPL_MMC_SUPPORT
 #define CONFIG_SPL_BSS_START_ADDR      0x00180000
 #define CONFIG_SPL_BSS_MAX_SIZE        0x2000  /* 8 KB */
-#define CONFIG_SYS_SPL_MALLOC_START    0x00182000
-#define CONFIG_SYS_SPL_MALLOC_SIZE     0x2000  /* 8 KB */
+#define CONFIG_SYS_SPL_MALLOC_START    0x42200000
+#define CONFIG_SYS_SPL_MALLOC_SIZE     0x80000 /* 512 KB */
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 
+#define CONFIG_MALLOC_F_ADDR           0x182000 /* malloc f used before GD_FLG_FULL_MALLOC_INIT set */
+
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE /* For RAW image gives a error info not panic */
 
 #undef CONFIG_DM_MMC