Skip to contentSkip to conversation

imx8mp_evk: Make SPL binary size smaller

PATCH New Fabio Estevam 4 participants 17 messages May 7, 2020 – May 10, 2020 Arm i.MX and Layerscape

lore
Share & tools
lore

Fabio Estevam

author reviewer
#0 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK") caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

Reduce the SPL size by the same amount so that it can boot again.

Further SPL reduction work is needed, such as removing driver model support in SPL.

Just to provide a comparison: NXP U-Boot tree has a SPL binary size of 64kB versus 96KB in U-Boot mainline.

---
Hi,

I plan to reduce SPL size even further by removing SPL_DM=y, but this needs more time to accomplish, so I prefer to give a small SPL reduction at this time, just to allow the board to boot again.

Also, will try to come up with a SPL size detection in build time, as it is hard to debug such issues in run-time.

 configs/imx8mp_evk_defconfig | 4 ----
 1 file changed, 4 deletions(-)
configs/imx8mp_evk_defconfig +0 -4
index 44b2935f69..00f4ccbe0d 100644
@@ -33,7 +33,6 @@ CONFIG_SPL_BOOTROM_SUPPORT=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_POWER_SUPPORT=y
-CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="u-boot=> "
 # CONFIG_CMD_EXPORTENV is not set
@@ -79,8 +78,5 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
-CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
-CONFIG_SYSRESET_WATCHDOG=y
 # CONFIG_WATCHDOG is not set
-CONFIG_IMX_WATCHDOG=y
Signature · 1 line
2.17.1
#1 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 20 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK") caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

Reduce the SPL size by the same amount so that it can boot again.

Further SPL reduction work is needed, such as removing driver model support in SPL.

Just to provide a comparison: NXP U-Boot tree has a SPL binary size of 64kB versus 96KB in U-Boot mainline.

---
Hi,

I plan to reduce SPL size even further by removing SPL_DM=y, but this needs more time to accomplish, so I prefer to give a small SPL reduction at this time, just to allow the board to boot again.

Quoted 5 lines

Also, will try to come up with a SPL size detection in build time, as it is hard to debug such issues in run-time.

 configs/imx8mp_evk_defconfig | 4 ----
 1 file changed, 4 deletions(-)

So the obvious question is, if you call hang(), does the SPL still reset or does it fail?

#2 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Fabio Estevam

Hello Fabio,

Quoted 3 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK") caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

Just to check, the addition of the clock driver probably lead to the same issue? So the clock driver is potentially working, it is just too big for SPL?

Quoted 12 lines

Reduce the SPL size by the same amount so that it can boot again.

Further SPL reduction work is needed, such as removing driver model support in SPL.

Just to provide a comparison: NXP U-Boot tree has a SPL binary size of 64kB versus 96KB in U-Boot mainline.

---
Hi,

Quoted 6 lines

I plan to reduce SPL size even further by removing SPL_DM=y, but this needs more time to accomplish, so I prefer to give a small SPL reduction at this time, just to allow the board to boot again.

Also, will try to come up with a SPL size detection in build time, as it is hard to debug such issues in run-time.

The SPL linker script already has checks for SPL size. See arch/arm/cpu/u-boot-spl.lds line 81 and following. Maybe you just need to properly set those config-options for your board?

Quoted 24 lines
 configs/imx8mp_evk_defconfig | 4 ----
 1 file changed, 4 deletions(-)
configs/imx8mp_evk_defconfig +0 -4
index 44b2935f69..00f4ccbe0d 100644
@@ -33,7 +33,6 @@ CONFIG_SPL_BOOTROM_SUPPORT=y
 CONFIG_SPL_SEPARATE_BSS=y
 CONFIG_SPL_I2C_SUPPORT=y
 CONFIG_SPL_POWER_SUPPORT=y
-CONFIG_SPL_WATCHDOG_SUPPORT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="u-boot=> "
 # CONFIG_CMD_EXPORTENV is not set
@@ -79,8 +78,5 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
-CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
-CONFIG_SYSRESET_WATCHDOG=y
 # CONFIG_WATCHDOG is not set
-CONFIG_IMX_WATCHDOG=y
Signature · 1 line
Harald
author reviewer
#3 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Hi Harald

Quoted 3 lines · Harald Seiler

Just to check, the addition of the clock driver probably lead to the same issue? So the clock driver is potentially working, it is just too big for SPL?

That's correct.

Quoted 3 lines

The SPL linker script already has checks for SPL size. See arch/arm/cpu/u-boot-spl.lds line 81 and following. Maybe you just need to properly set those config-options for your board?

Yes, we do this for imx6. Will implement the same for imx8m.

Thanks

author reviewer
#4 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Fabio Estevam
Quoted 4 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK") caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

The new SPL size is 97kB, which is below the limit define in imx8mp_evk.h:
#define CONFIG_SPL_MAX_SIZE (152 * 1024)

It seems the problem is not related to SPL size.

Peng, do you have any ideas?

Thanks

#5 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 10 lines · Fabio Estevam
Quoted 4 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP EVK") caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

The new SPL size is 97kB, which is below the limit define in imx8mp_evk.h:
#define CONFIG_SPL_MAX_SIZE (152 * 1024)

It seems the problem is not related to SPL size.

Disable tiny printf in SPL, because that's really broken with dm_dump_all(), run dm_dump_all() just after power_init_board() in board/freescale/imx8m{p,q}_evk/spl.c and compare the results. There is likely gonna be a missing driver, my bet would still be on the clock.

author reviewer
#6 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Hi Marek,

Quoted 4 lines · Marek Vasut

Disable tiny printf in SPL, because that's really broken with dm_dump_all(), run dm_dump_all() just after power_init_board() in board/freescale/imx8m{p,q}_evk/spl.c and compare the results. There is likely gonna be a missing driver, my bet would still be on the clock.

That's a good suggestion. Yes, the clock drivers are missing for i.MX8MP.

Here is the comparison against a i.MX8MM EVK:
https://pastebin.com/raw/XVc6AAvr

I will activate them on SPL tomorrow.

Also, I noticed that i.MX8MM EVK has the following watchdog issues on master:

U-Boot SPL 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300) Normal Boot
WDT: Started without servicing (60s timeout)
Trying to boot from MMC1

U-Boot 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300)

CPU:   Freescale i.MX8MMQ rev1.0 at 1200 MHz
Reset cause: POR
Model: FSL i.MX8MM EVK board
DRAM:  2 GiB
WDT:   Started without servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial

Net:
Warning: ethernet at 30be0000 using MAC address from ROM
eth0: ethernet at 30be0000
Hit any key to stop autoboot: 0
u-boot=>

It reboots after staying 60s in the U-Boot prompt.

Thanks

#7 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 9 lines · Fabio Estevam

Hi Marek,

Quoted 4 lines · Marek Vasut

Disable tiny printf in SPL, because that's really broken with dm_dump_all(), run dm_dump_all() just after power_init_board() in board/freescale/imx8m{p,q}_evk/spl.c and compare the results. There is likely gonna be a missing driver, my bet would still be on the clock.

Quoted 6 lines

That's a good suggestion. Yes, the clock drivers are missing for i.MX8MP.

Here is the comparison against a i.MX8MM EVK:
https://pastebin.com/raw/XVc6AAvr

I will activate them on SPL tomorrow.

Great, thanks.

Quoted 20 lines

Also, I noticed that i.MX8MM EVK has the following watchdog issues on master:

U-Boot SPL 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300) Normal Boot
WDT: Started without servicing (60s timeout)
Trying to boot from MMC1

U-Boot 2020.07-rc1-00387-g67887903af (May 07 2020 - 23:49:27 -0300)

CPU:   Freescale i.MX8MMQ rev1.0 at 1200 MHz
Reset cause: POR
Model: FSL i.MX8MM EVK board
DRAM:  2 GiB
WDT:   Started without servicing (60s timeout)
MMC:   FSL_SDHC: 1, FSL_SDHC: 2
Loading Environment from MMC... OK
In:    serial
Out:   serial
Err:   serial
Quoted 7 lines

Net:
Warning: ethernet at 30be0000 using MAC address from ROM
eth0: ethernet at 30be0000
Hit any key to stop autoboot: 0
u-boot=>

It reboots after staying 60s in the U-Boot prompt.

Enable CONFIG_WATCHDOG in your U-Boot config, that will enable WDT servicing.

author reviewer
#8 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Hi Marek,

Quoted 2 lines · Marek Vasut

Enable CONFIG_WATCHDOG in your U-Boot config, that will enable WDT servicing.

Thanks. I changed the defconfig like this:

configs/imx8mm_evk_defconfig +0 -1
@@ -85,5 +85,4 @@ CONFIG_SPL_SYSRESET=y
 CONFIG_SYSRESET_PSCI=y
 CONFIG_SYSRESET_WATCHDOG=y
 CONFIG_DM_THERMAL=y
-# CONFIG_WATCHDOG is not set
 CONFIG_IMX_WATCHDOG=y

I will submit this patch and for other boards tomorrow.

Thanks

author reviewer
#9 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Fabio Estevam

Hi Marek,

Quoted 1 line · Fabio Estevam

I will activate them on SPL tomorrow.

After activating the SPL clocks I see:

clk 69 [ ] imx_clk_gate2 | |
`-- dram1_root_clk

The dram1_root_clk is not getting turned on.

This clock is marked as CLK_IS_CRITICAL, but it seems that U-Boot core clock driver does not handle it yet.

I have also tried to enable it manually by doing:

clk_get_by_id(IMX8MP_CLK_DRAM_CORE, &clk);
clk_enable(clk);
clk_get_by_id(IMX8MP_CLK_DRAM1_ROOT, &clk);
clk_enable(clk);

but it did not work.

The complete clock dump is here:
https://pastebin.com/raw/40U6hQny

Thanks

author reviewer
#10 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 5 lines · Fabio Estevam

Hi Marek,

On Thu, May 7, 2020 at 11:56 PM Fabio Estevam <[email protected]> wrote:

Quoted 8 lines
Quoted 1 line

I will activate them on SPL tomorrow.

After activating the SPL clocks I see:

clk 69 [ ] imx_clk_gate2 | |
`-- dram1_root_clk

The dram1_root_clk is not getting turned on.

Looks at the iMX8MM EVK log:
https://pastebin.com/raw/XVc6AAvr

It also has:

[ ] clk_gate | | `-- dram_pll_out

So it seems the problem is somewhere else.

Thanks

#11 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 15 lines · Fabio Estevam
Quoted 5 lines · Fabio Estevam

Hi Marek,

On Thu, May 7, 2020 at 11:56 PM Fabio Estevam <[email protected]> wrote:

Quoted 8 lines
Quoted 1 line

I will activate them on SPL tomorrow.

After activating the SPL clocks I see:

clk 69 [ ] imx_clk_gate2 | |
`-- dram1_root_clk

The dram1_root_clk is not getting turned on.

Quoted 8 lines

Looks at the iMX8MM EVK log:
https://pastebin.com/raw/XVc6AAvr

It also has:

[ ] clk_gate | | `-- dram_pll_out

So it seems the problem is somewhere else.

Maybe you also need entries like
126dcc925d ("ARM: imx: imx8mm: Add missing clock entries for FEC clock") for MX8MP ?

#13 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Fabio Estevam
Quoted 10 lines · Fabio Estevam

Hi Marek,

Quoted 3 lines · Marek Vasut

Maybe you also need entries like
126dcc925d ("ARM: imx: imx8mm: Add missing clock entries for FEC clock") for MX8MP ?

That only affects U-Boot proper, not SPL.

Quoted 7 lines

imx8mm clock driver also does not register Ethernet clocks in SPL:

/* clks not needed in SPL stage */
#ifndef CONFIG_SPL_BUILD
clk_dm(IMX8MM_CLK_ENET_REF, imx8m_clk_composite("enet_ref",
imx8mm_enet_ref_sels, base + 0xa980));
.....

Don't you need similar entry for WDT ?

author reviewer
#12 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Marek Vasut

Hi Marek,

Quoted 3 lines · Marek Vasut

Maybe you also need entries like
126dcc925d ("ARM: imx: imx8mm: Add missing clock entries for FEC clock") for MX8MP ?

That only affects U-Boot proper, not SPL.

imx8mm clock driver also does not register Ethernet clocks in SPL:

/* clks not needed in SPL stage */
#ifndef CONFIG_SPL_BUILD
clk_dm(IMX8MM_CLK_ENET_REF, imx8m_clk_composite("enet_ref",
imx8mm_enet_ref_sels, base + 0xa980));
.....

Thanks

author reviewer
#14 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Marek Vasut
Quoted 1 line · Marek Vasut

Don't you need similar entry for WDT ?

arch/arm/mach-imx/imx8m/clock_slice.c already contains the wdog entries.

Thanks

#15 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

In reply to Fabio Estevam
Quoted 10 lines

Subject: Re: [PATCH] imx8mp_evk: Make SPL binary size smaller

Quoted 2 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP

EVK")

Quoted 2 lines

caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

Quoted 6 lines

The new SPL size is 97kB, which is below the limit define in imx8mp_evk.h:
#define CONFIG_SPL_MAX_SIZE (152 * 1024)

It seems the problem is not related to SPL size.

Peng, do you have any ideas?

The following patch will make it boot again, not perfect, I need think more out an elegant fix. Disable DM SPL? Or recalculate the address. Enable DM consumes too much
on chip ocram malloc area. Need to think about it how we could use less ocram for SPL malloc area.

include/configs/imx8mp_evk.h +4 -4
index 80e5738961..b90a4f6932 100644
@@ -23,15 +23,15 @@
 #ifdef CONFIG_SPL_BUILD
 /*#define CONFIG_ENABLE_DDR_TRAINING_DEBUG*/
 #define CONFIG_SPL_LDSCRIPT            "arch/arm/cpu/armv8/u-boot-spl.lds"
-#define CONFIG_SPL_STACK               0x990000
-#define CONFIG_SPL_BSS_START_ADDR      0x0095e000
-#define CONFIG_SPL_BSS_MAX_SIZE        0x2000  /* 8 KB */
+#define CONFIG_SPL_STACK               0x98fc00
+#define CONFIG_SPL_BSS_START_ADDR      0x0098fc00
+#define CONFIG_SPL_BSS_MAX_SIZE        0x400   /* 1 KB */
 #define CONFIG_SYS_SPL_MALLOC_START    0x42200000
 #define CONFIG_SYS_SPL_MALLOC_SIZE     SZ_512K /* 512 KB */
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 
-#define CONFIG_MALLOC_F_ADDR           0x940000
+#define CONFIG_MALLOC_F_ADDR           0x950000
 
 #define CONFIG_SPL_ABORT_ON_RAW_IMAGE
 

Regards,
Peng.

Quoted 2 lines

Thanks

#16 lore raw

PATCH 1/1 imx8mp_evk: Make SPL binary size smaller

Quoted 15 lines · Peng Fan
Quoted 15 lines

Subject: Re: [PATCH] imx8mp_evk: Make SPL binary size smaller

Quoted 2 lines · Fabio Estevam

Commit f24dea4e1b52 ("ARM: imx8m: Fix reset in SPL on NXP iMX8MP

EVK")

Quoted 2 lines

caused the u-boot-spl.bin binary size to grow by around 2000 bytes, which makes the board to fail to boot.

The new SPL size is 97kB, which is below the limit define in imx8mp_evk.h:
#define CONFIG_SPL_MAX_SIZE (152 * 1024)

It seems the problem is not related to SPL size.

Quoted 7 lines
Quoted 1 line

Peng, do you have any ideas?

The following patch will make it boot again, not perfect, I need think more out an elegant fix. Disable DM SPL? Or recalculate the address. Enable DM consumes too much
on chip ocram malloc area. Need to think about it how we could use less ocram for SPL malloc area.

Can't you put the malloc area and stack into DRAM ? Look at SPL_STACK_R and MALLOC_SIMPLE