make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
Subsystems (8)
v2 cover make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
Some platforms like RK3036 has very small sram to run spl code, so it has no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stake.
As the long discussion in [1] [2], I make this series out, try to make spl and normal u-boot stage use independent SYS_MALLOC_F_LEN.
[1]https://lists.denx.de/pipermail/u-boot/2017-July/297370.html [2]https://lists.denx.de/pipermail/u-boot/2017-July/297504.html
Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon
- set spl pre relocation malloc pool by CONFIG_SPL_SYS_MALLOC_F_LEN
Andy Yan (9):
make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
mips: spl and normal u-boot stage set SYS_MALLOC_F indepently
powerpc: spl and normal u-boot stage set SYS_MALLOC_F indepently
microblaze: spl and normal u-boot stage set SYS_MALLOC_F indepently
rockchip: set malloc pool size to 0 before relocation in spl state on
rk3036 based board
rockchip: disable SPL_ARCH_MEMCPY/MEMSET for rk3036
rockchip: enable SPL_LIBGENERIC for rk3036 based boards
rockchip: use debug() instead of printf when back to bootrom
rockchip: add u-boot specific dts for rk3036 sdk
Kconfig | 10 ++++++++++ arch/arm/dts/rk3036-sdk-u-boot.dtsi | 11 +++++++++++ arch/arm/mach-rockchip/bootrom.c | 2 +- arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------ arch/microblaze/cpu/start.S | 11 ++++++++--- arch/mips/cpu/start.S | 8 ++++++-- arch/powerpc/cpu/mpc83xx/start.S | 13 +++++++++---- arch/powerpc/cpu/mpc85xx/start.S | 16 ++++++++++------ arch/sandbox/cpu/start.c | 2 +- cmd/bdinfo.c | 2 +- common/Makefile | 2 +- common/board_f.c | 4 ++-- common/board_r.c | 2 +- common/dlmalloc.c | 12 ++++++------ common/init/board_init.c | 4 ++-- common/spl/spl.c | 6 +++--- configs/evb-rk3036_defconfig | 5 +++++ configs/kylin-rk3036_defconfig | 6 +++++- drivers/core/Kconfig | 8 ++++---- drivers/serial/serial-uclass.c | 4 ++-- include/asm-generic/global_data.h | 2 +- include/common.h | 11 +++++++++++ lib/asm-offsets.c | 2 +- lib/efi/efi_app.c | 2 +- 24 files changed, 102 insertions(+), 49 deletions(-) create mode 100644 arch/arm/dts/rk3036-sdk-u-boot.dtsi
Signature · 1 line
2.7.4
PATCH v2 1/9 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
Some platforms has very small sram to run spl code, so it has no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stake.
Make spl and normal u-boot stage use independent SYS_MALLOC_F_LEN, Then people can sets the pre-relocation malloc pool according to the memory space indepently.
---
Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon
Kconfig | 10 ++++++++++ arch/sandbox/cpu/start.c | 2 +- cmd/bdinfo.c | 2 +- common/Makefile | 2 +- common/board_f.c | 4 ++-- common/board_r.c | 2 +- common/dlmalloc.c | 12 ++++++------ common/init/board_init.c | 4 ++-- common/spl/spl.c | 6 +++--- drivers/core/Kconfig | 8 ++++---- drivers/serial/serial-uclass.c | 4 ++-- include/asm-generic/global_data.h | 2 +- include/common.h | 11 +++++++++++ lib/asm-offsets.c | 2 +- lib/efi/efi_app.c | 2 +- 15 files changed, 47 insertions(+), 26 deletions(-)
Kconfig +10 -0
@@ -95,6 +95,16 @@ config SYS_MALLOC_F_LEN particular needs this to operate, so that it can allocate the initial serial device and any others that are needed. +config SPL_SYS_MALLOC_F_LEN + hex "Size of malloc() pool in spl before relocation" + depends on SYS_MALLOC_F + default SYS_MALLOC_F_LEN + help + Before relocation, memory is very limited on many platforms. Still, + we can provide a small malloc() pool if needed. Driver model in + particular needs this to operate, so that it can allocate the + initial serial device and any others that are needed. + menuconfig EXPERT bool "Configure standard U-Boot features (expert users)" default y
arch/sandbox/cpu/start.c +1 -1
@@ -310,7 +310,7 @@ int main(int argc, char *argv[])memset (&data,'\0' ,sizeof (data)); gd = &data; -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif setup_ram_buf (state);
cmd/bdinfo.c +1 -1
@@ -346,7 +346,7 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,#endif #ifdef CONFIG_SYS_MALLOC_F printf ("Early malloc usage: %lx / %x\n" , gd->malloc_ptr, -CONFIG_SYS_MALLOC_F_LEN ); +get_sys_malloc_f_len ());#endif if (gd->fdt_blob)printf ("fdt_blob = %p\n" , gd->fdt_blob);
common/Makefile +1 -1
@@ -139,7 +139,7 @@ obj-y += console.o endif obj-$(CONFIG_CROS_EC) += cros_ec.o obj-y += dlmalloc.o -ifdef CONFIG_SYS_MALLOC_F_LEN +ifdef CONFIG_SYS_MALLOC_F obj-y += malloc_simple.o endif obj-y += image.o
common/board_f.c +2 -2
@@ -727,7 +727,7 @@ static int initf_bootstage(void)static int initf_console_record (void ) { -#if defined(CONFIG_CONSOLE_RECORD ) && defined(CONFIG_SYS_MALLOC_F_LEN ) +#if defined(CONFIG_CONSOLE_RECORD ) && defined(CONFIG_SYS_MALLOC_F )return console_record_init ();#else return 0 ;
@@ -736,7 +736,7 @@ static int initf_console_record(void)static int initf_dm (void ) { -#if defined(CONFIG_DM ) && defined(CONFIG_SYS_MALLOC_F_LEN ) +#if defined(CONFIG_DM ) && defined(CONFIG_SYS_MALLOC_F )int ret;bootstage_start (BOOTSTATE_ID_ACCUM_DM_F ,"dm_f" );
common/board_r.c +1 -1
@@ -256,7 +256,7 @@ static int initr_malloc(void) {ulong malloc_start; -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F debug ("Pre-reloc malloc() used %#lx bytes (%ld KB)\n" , gd->malloc_ptr, gd->malloc_ptr /1024 );#endif
common/dlmalloc.c +6 -6
@@ -1254,7 +1254,7 @@ Void_t* mALLOc(bytes) size_t bytes;INTERNAL_SIZE_T nb; -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F if (!(gd->flags &GD_FLG_FULL_MALLOC_INIT ))return malloc_simple (bytes);#endif
@@ -1522,7 +1522,7 @@ void fREe(mem) Void_t* mem;mchunkptr fwd;/* misc temp for linking */ int islr;/* track whether merging with last_remainder */ -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F /* free() is a no-op - all the memory will be freed on relocation */ if (!(gd->flags &GD_FLG_FULL_MALLOC_INIT ))return ;
@@ -1679,7 +1679,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;/* realloc of null is supposed to be same as malloc */ if (oldmem ==NULL )return mALLOc (bytes); -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F if (!(gd->flags &GD_FLG_FULL_MALLOC_INIT )) {/* This is harder to support and should not be needed */ panic ("pre-reloc realloc() is not supported" );
@@ -2074,7 +2074,7 @@ Void_t* cALLOc(n, elem_size) size_t n; size_t elem_size;return NULL ; else { -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F if (!(gd->flags &GD_FLG_FULL_MALLOC_INIT )) {MALLOC_ZERO (mem, sz);return mem;
@@ -2375,9 +2375,9 @@ int mALLOPt(param_number, value) int param_number; int value;int initf_malloc (void ) { -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F assert (gd->malloc_base);/* Set up by crt0.S */ - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_limit =get_sys_malloc_f_len (); gd->malloc_ptr =0 ;#endif
common/init/board_init.c +2 -2
@@ -47,7 +47,7 @@ ulong board_init_f_alloc_reserve(ulong top) {/* Reserve early malloc arena */ #if defined(CONFIG_SYS_MALLOC_F ) - top -=CONFIG_SYS_MALLOC_F_LEN ; + top -=get_sys_malloc_f_len ();#endif /* LAST : reserve GD (rounded up to a multiple of 16 bytes) */ top =rounddown (top-sizeof (struct global_data ),16 );
@@ -125,7 +125,7 @@ void board_init_f_init_reserve(ulong base)/* go down one 'early malloc arena' */ gd->malloc_base = base;/* next alloc will be higher by one 'early malloc arena' size */ - base +=CONFIG_SYS_MALLOC_F_LEN ; + base +=get_sys_malloc_f_len ();#endif }
common/spl/spl.c +3 -3
@@ -220,12 +220,12 @@ static int spl_common_init(bool setup_malloc)debug ("spl_early_init()\n" ); -#if defined(CONFIG_SYS_MALLOC_F_LEN ) +#if defined(CONFIG_SYS_MALLOC_F )if (setup_malloc) {#ifdef CONFIG_MALLOC_F_ADDR gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif - gd->malloc_limit =CONFIG_SYS_MALLOC_F_LEN ; + gd->malloc_limit =get_sys_malloc_f_len (); gd->malloc_ptr =0 ; }#endif
@@ -419,7 +419,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)default :debug ("Unsupported OS image.. Jumping nevertheless..\n" ); } -#if defined(CONFIG_SYS_MALLOC_F_LEN ) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE ) +#if defined(CONFIG_SYS_MALLOC_F ) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE )debug ("SPL malloc() used %#lx bytes (%ld KB)\n" , gd->malloc_ptr, gd->malloc_ptr /1024 );#endif
drivers/core/Kconfig +4 -4
@@ -16,10 +16,10 @@ config SPL_DM suitable malloc() implementation. If you are not using the full malloc() enabled by CONFIG_SYS_SPL_MALLOC_START, consider using CONFIG_SYS_MALLOC_SIMPLE. In that case you - must provide CONFIG_SYS_MALLOC_F_LEN to set the size. + must provide CONFIG_SPL_SYS_MALLOC_F_LEN to set the size. In most cases driver model will only allocate a few uclasses and devices in SPL, so 1KB should be enable. See - CONFIG_SYS_MALLOC_F_LEN for more details on how to enable it. + CONFIG_SPL_SYS_MALLOC_F_LEN for more details on how to enable it. config TPL_DM bool "Enable Driver Model for TPL"
@@ -29,10 +29,10 @@ config TPL_DM suitable malloc() implementation. If you are not using the full malloc() enabled by CONFIG_SYS_SPL_MALLOC_START, consider using CONFIG_SYS_MALLOC_SIMPLE. In that case you - must provide CONFIG_SYS_MALLOC_F_LEN to set the size. + must provide CONFIG_SPL_SYS_MALLOC_F_LEN to set the size. In most cases driver model will only allocate a few uclasses and devices in SPL, so 1KB should be enough. See - CONFIG_SYS_MALLOC_F_LEN for more details on how to enable it. + CONFIG_SPL_SYS_MALLOC_F_LEN for more details on how to enable it. Disable this for very small implementations. config DM_WARN
drivers/serial/serial-uclass.c +2 -2
@@ -23,8 +23,8 @@ DECLARE_GLOBAL_DATA_PTR;*/ static const unsigned long baudrate_table[] =CONFIG_SYS_BAUDRATE_TABLE ; -#ifndef CONFIG_SYS_MALLOC_F_LEN -#error "Serial is required before relocation - define CONFIG_SYS_MALLOC_F_LEN to make this work" +#ifndef CONFIG_SYS_MALLOC_F +#error "Serial is required before relocation - define CONFIG_$(SPL_)SYS_MALLOC_F_LEN to make this work"#endif static int serial_check_stdout (const void *blob,struct udevice **devp)
include/asm-generic/global_data.h +1 -1
@@ -88,7 +88,7 @@ typedef struct global_data {#endif unsigned int timebase_h;unsigned int timebase_l; -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F unsigned long malloc_base;/* base address of early malloc() */ unsigned long malloc_limit;/* limit address */ unsigned long malloc_ptr;/* current address */
include/common.h +11 -0
@@ -717,6 +717,17 @@ int cpu_disable(int nr);int cpu_release (int nr,int argc,char *const argv[]);#endif +#if defined(CONFIG_SYS_MALLOC_F ) +static inline int get_sys_malloc_f_len (void ) +{ +#if defined(CONFIG_SPL_BUILD ) +return CONFIG_SPL_SYS_MALLOC_F_LEN ; +#else +return CONFIG_SYS_MALLOC_F_LEN ; +#endif +} +#endif +#else /* __ASSEMBLY__ */ /* Drop a C type modifier (like in 3UL) for constants used in assembly. */
lib/asm-offsets.c +1 -1
@@ -28,7 +28,7 @@ int main(void)DEFINE (GD_SIZE ,sizeof (struct global_data ));DEFINE (GD_BD , offsetof(struct global_data , bd)); -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F DEFINE (GD_MALLOC_BASE , offsetof(struct global_data , malloc_base));#endif
lib/efi/efi_app.c +1 -1
@@ -48,7 +48,7 @@ static efi_status_t setup_memory(struct efi_priv *priv)return ret;memset (gd,'\0' ,sizeof (*gd)); - gd->malloc_base = (ulong )efi_malloc (priv,CONFIG_SYS_MALLOC_F_LEN , + gd->malloc_base = (ulong )efi_malloc (priv,get_sys_malloc_f_len (), &ret);if (!gd->malloc_base)return ret;
Signature · 1 line
2.7.4
PATCH v2 1/9 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
Quoted 9 lines · Andy Yan
Some platforms has very small sram to run spl code, so it has no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stake.
Make spl and normal u-boot stage use independentSYS_MALLOC_F_LEN, Then people can sets the pre-relocation malloc pool according to the memory space indepently.Signed-off-by Andy Yan <[email protected]>
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170718/62fe2cf3/attachment.sig>
PATCH v2 1/9 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
In reply to Andy YanHi Andy,
Quoted 58 lines · Andy Yan
Some platforms has very small sram to run spl code, so it has no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stake.
Make spl and normal u-boot stage use independentSYS_MALLOC_F_LEN, Then people can sets the pre-relocation malloc pool according to the memory space indepently.Signed-off-by Andy Yan <[email protected]>---
Changes in v2:
- introduce a new controlCONFIG_SPL_SYS_MALLOC_F_LEN, adviced by SimonKconfig | 10 ++++++++++ arch/sandbox/cpu/start.c | 2 +- cmd/bdinfo.c | 2 +- common/Makefile | 2 +- common/board_f.c | 4 ++-- common/board_r.c | 2 +- common/dlmalloc.c | 12 ++++++------ common/init/board_init.c | 4 ++-- common/spl/spl.c | 6 +++--- drivers/core/Kconfig | 8 ++++---- drivers/serial/serial-uclass.c | 4 ++-- include/asm-generic/global_data.h | 2 +- include/common.h | 11 +++++++++++ lib/asm-offsets.c | 2 +- lib/efi/efi_app.c | 2 +- 15 files changed, 47 insertions(+), 26 deletions(-)Kconfig +10
-0@@ -95,6 +95,16 @@ config SYS_MALLOC_F_LEN particular needs this to operate, so that it can allocate the initial serial device and any others that are needed. +config SPL_SYS_MALLOC_F_LEN + hex "Size of malloc() pool in spl before relocation" + depends on SYS_MALLOC_F + default SYS_MALLOC_F_LEN + help + Before relocation, memory is very limited on many platforms. Still, + we can provide a small malloc() pool if needed. Driver model in + particular needs this to operate, so that it can allocate the + initial serial device and any others that are needed. + menuconfig EXPERT bool "Configure standard U-Boot features (expert users)" default yarch/sandbox/cpu/start.c +0
-0
arch/sandbox/cpu/start.c int main(int argc, char *argv[]) · line 313
Quoted 5 lines
arch/sandbox/cpu/start.c +1
-1@@ -310,7 +310,7 @@ int main(int argc, char *argv[])memset (&data,'\0' ,sizeof (data)); gd = &data; -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F
This is a good change. Can you please split out the change to move to SYS_MALLOC_F into its own patch? It seems to be separate from the change to support an SPL version.
cmd/bdinfo.c static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, · line 349
Quoted 13 lines
arch/sandbox/cpu/start.c +0
-0gd->malloc_base =CONFIG_MALLOC_F_ADDR ;#endif setup_ram_buf (state);cmd/bdinfo.c +1
-1@@ -346,7 +346,7 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,#endif #ifdef CONFIG_SYS_MALLOC_F printf ("Early malloc usage: %lx / %x\n" , gd->malloc_ptr, -CONFIG_SYS_MALLOC_F_LEN ); +get_sys_malloc_f_len ());
Can you use CONFIG_VAL(SYS_MALLOC_F_LEN) here instead of the function?
[...]
Regards,
Simon
PATCH v2 2/9 mips: spl and normal u-boot stage set SYS_MALLOC_F indepently
In reply to Andy YanSome platforms has very small sram to run spl code, so it may have no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stage.
---
Changes in v2: None
arch/mips/cpu/start.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/mips/cpu/start.S +6 -2
@@ -60,8 +60,12 @@ sp, sp, GD_SIZE # reserve space for gd and sp, sp, t0 # force 16 byte alignment move k0, sp # save gd pointer -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F +# ifdef CONFIG_SPL_BUILD + li t2, CONFIG_SPL_SYS_MALLOC_F_LEN +# else li t2, CONFIG_SYS_MALLOC_F_LEN +# endif PTR_SUBU \ sp, sp, t2 # reserve space for early malloc and sp, sp, t0 # force 16 byte alignment
@@ -75,7 +79,7 @@ blt t0, t1, 1b PTR_ADDIU t0, PTRSIZE -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F PTR_S sp, GD_MALLOC_BASE(k0) # gd->malloc_base offset #endif .endm
Signature · 1 line
2.7.4
PATCH v2 2/9 mips: spl and normal u-boot stage set SYS_MALLOC_F indepently
2017-07-13 5:23 GMT+02:00 Andy Yan <[email protected]>:
Quoted 4 lines
Some platforms has very small sram to run spl code, so it may have no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stage.
Quoted 8 lines
Signed-off-by Andy Yan <[email protected]>---
Changes in v2: None
arch/mips/cpu/start.S | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
Quoted 31 lines
arch/mips/cpu/start.S +6
-3@@ -60,8 +60,12 @@ sp, sp, GD_SIZE # reserve space for gd and sp, sp, t0 # force 16 byte alignment move k0, sp # save gd pointer -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F +# ifdef CONFIG_SPL_BUILD + li t2, CONFIG_SPL_SYS_MALLOC_F_LEN +# else li t2, CONFIG_SYS_MALLOC_F_LEN +# endif PTR_SUBU \ sp, sp, t2 # reserve space for early malloc and sp, sp, t0 # force 16 byte alignment@@ -75,7 +79,7 @@ blt t0, t1, 1b PTR_ADDIU t0, PTRSIZE -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F PTR_S sp, GD_MALLOC_BASE(k0) # gd->malloc_base offset #endif .endm --2.7.4
PATCH v2 3/9 powerpc: spl and normal u-boot stage set SYS_MALLOC_F indepently
In reply to Andy YanSome platforms has very small sram to run spl code, so it may have no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stage.
---
Changes in v2: None
arch/powerpc/cpu/mpc83xx/start.S | 13 +++++++++---- arch/powerpc/cpu/mpc85xx/start.S | 16 ++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +9 -4
@@ -48,6 +48,11 @@ #define CONFIG_SYS_FLASHBOOT #endif +#if defined(CONFIG_SPL_BUILD) +#define MALLOC_F_LEN CONFIG_SPL_SYS_MALLOC_F_LEN +#else +#define MALLOC_F_LEN CONFIG_SYS_MALLOC_F_LEN +#endif /* * Set up GOT: Global Offset Table *
@@ -274,14 +279,14 @@ in_flash: cmplw r3, r4 bne 1b -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F -#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE -#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM." +#if MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE +#error "MALLOC_F_LEN too large to fit into initial RAM." #endif /* r3 = new stack pointer / pre-reloc malloc area */ - subi r3, r3, CONFIG_SYS_MALLOC_F_LEN + subi r3, r3, MALLOC_F_LEN /* Set pointer to pre-reloc malloc area in GD */ stw r3, GD_MALLOC_BASE(r4)
arch/powerpc/cpu/mpc85xx/start.S +10 -6
@@ -38,6 +38,11 @@ #define NOR_BOOT #endif +#if defined(CONFIG_SPL_BUILD) +#define MALLOC_F_LEN CONFIG_SPL_SYS_MALLOC_F_LEN +#else +#define MALLOC_F_LEN CONFIG_SYS_MALLOC_F_LEN +#endif /* * Set up GOT: Global Offset Table *
@@ -1183,14 +1188,13 @@ _start_cont: lis r3,(CONFIG_SYS_INIT_RAM_ADDR)@h ori r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */ -#ifdef CONFIG_SYS_MALLOC_F_LEN - -#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE -#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM." +#ifdef CONFIG_SYS_MALLOC_F +#if MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE +#error "MALLOC_F_LEN too large to fit into initial RAM." #endif /* Leave 16+ byte for back chain termination and NULL return address */ - subi r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf) + subi r3,r3,((MALLOC_F_LEN+16+15)&~0xf) #endif /* End of RAM */
@@ -1204,7 +1208,7 @@ _start_cont: cmplw r4,r3 bne 1b -#ifdef CONFIG_SYS_MALLOC_F_LEN +#ifdef CONFIG_SYS_MALLOC_F lis r4,(CONFIG_SYS_INIT_RAM_ADDR)@h ori r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
Signature · 1 line
2.7.4
PATCH v2 3/9 powerpc: spl and normal u-boot stage set SYS_MALLOC_F indepently
Hi Andy,
Quoted 4 lines · Andy Yan
Some platforms has very small sram to run spl code, so it may have no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stage.
Quoted 9 lines
Signed-off-by Andy Yan <[email protected]>---
Changes in v2: None
arch/powerpc/cpu/mpc83xx/start.S | 13 +++++++++---- arch/powerpc/cpu/mpc85xx/start.S | 16 ++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-)
I think you can use CONFIG_VAL() in this patch too.
Regards,
Simon
PATCH v2 4/9 microblaze: spl and normal u-boot stage set SYS_MALLOC_F indepently
In reply to Andy YanSome platforms has very small sram to run spl code, so it may have no enough sapce for so much malloc pool before relocation in spl stage as the normal u-boot stage.
---
Changes in v2: None
arch/microblaze/cpu/start.S | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/microblaze/cpu/start.S +8 -3
@@ -11,6 +11,11 @@ #include <asm-offsets.h> #include <config.h> +#if defined(CONFIG_SPL_BUILD) +#define MALLOC_F_LEN CONFIG_SPL_SYS_MALLOC_F_LEN +#else +#define MALLOC_F_LEN CONFIG_SYS_MALLOC_F_LEN +#endif .text .global _start _start:
@@ -32,7 +37,7 @@ _start: addi r1, r1, -4 /* Decrement SP to top of memory */ #else #if defined(CONFIG_SYS_MALLOC_F_LEN) - addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET - CONFIG_SYS_MALLOC_F_LEN + addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET - MALLOC_F_LEN #else addi r1, r0, CONFIG_SYS_INIT_SP_OFFSET #endif
@@ -162,14 +167,14 @@ clear_bss: #ifndef CONFIG_SPL_BUILD or r5, r0, r0 /* flags - empty */ addi r31, r0, _gd -#if defined(CONFIG_SYS_MALLOC_F_LEN) +#if defined(CONFIG_SYS_MALLOC_F) addi r6, r0, CONFIG_SYS_INIT_SP_OFFSET swi r6, r31, GD_MALLOC_BASE #endif brai board_init_f #else addi r31, r0, _gd -#if defined(CONFIG_SYS_MALLOC_F_LEN) +#if defined(CONFIG_SYS_MALLOC_F) addi r6, r0, CONFIG_SPL_STACK_ADDR swi r6, r31, GD_MALLOC_BASE #endif
Signature · 1 line
2.7.4
PATCH v2 5/9 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board
In reply to Andy YanRK3036 only has 4kb sram, the spl code will use 3.4 ~ 3.5 kb, the last 0.5kb are used for SP and GD, so there is no space for malloc. Also, the spl will directly return to bootrom after dram initialized, they never need the space for malloc.
---
Changes in v2:
- set spl pre relocation malloc pool by CONFIG_SPL_SYS_MALLOC_F_LEN
configs/evb-rk3036_defconfig | 1 + configs/kylin-rk3036_defconfig | 1 + 2 files changed, 2 insertions(+)
configs/evb-rk3036_defconfig +1 -0
@@ -4,6 +4,7 @@ CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_EVB_RK3036=y CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEFAULT_DEVICE_TREE="rk3036-sdk" +CONFIG_SPL_SYS_MALLOC_F_LEN=0x0 CONFIG_DEBUG_UART=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_SPL_STACK_R=y
configs/kylin-rk3036_defconfig +1 -0
@@ -4,6 +4,7 @@ CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_KYLIN_RK3036=y CONFIG_SPL_STACK_R_ADDR=0x80000 CONFIG_DEFAULT_DEVICE_TREE="rk3036-sdk" +CONFIG_SPL_SYS_MALLOC_F_LEN=0x0 # CONFIG_DISPLAY_CPUINFO is not set CONFIG_SPL_STACK_R=y # CONFIG_CMD_IMLS is not set
Signature · 1 line
2.7.4
PATCH v2 5/9 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board
Quoted 8 lines · Andy Yan
RK3036 only has 4kb sram, the spl code will use 3.4 ~ 3.5 kb, the last 0.5kb are used for SP and GD, so there is no space for malloc. Also, the spl will directly return to bootrom after dram initialized, they never need the space for malloc.
Signed-off-by Andy Yan <[email protected]>
Quoted 8 lines
---
Changes in v2:
- set spl pre relocation malloc pool byCONFIG_SPL_SYS_MALLOC_F_LENconfigs/evb-rk3036_defconfig | 1 + configs/kylin-rk3036_defconfig | 1 + 2 files changed, 2 insertions(+)
PATCH v2 6/9 rockchip: disable SPL_ARCH_MEMCPY/MEMSET for rk3036
In reply to Andy YanRK3036 has no enough sapce use ARCH_MEMCPY/MEMSET in spl stage
---
Changes in v2: None
configs/evb-rk3036_defconfig | 2 ++ configs/kylin-rk3036_defconfig | 2 ++ 2 files changed, 4 insertions(+)
configs/evb-rk3036_defconfig +2 -0
@@ -1,4 +1,6 @@ CONFIG_ARM=y +# CONFIG_SPL_USE_ARCH_MEMCPY is not set +# CONFIG_SPL_USE_ARCH_MEMSET is not set CONFIG_ARCH_ROCKCHIP=y CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_EVB_RK3036=y
configs/kylin-rk3036_defconfig +2 -0
@@ -1,4 +1,6 @@ CONFIG_ARM=y +# CONFIG_SPL_USE_ARCH_MEMCPY is not set +# CONFIG_SPL_USE_ARCH_MEMSET is not set CONFIG_ARCH_ROCKCHIP=y CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_KYLIN_RK3036=y
Signature · 1 line
2.7.4
PATCH v2 7/9 rockchip: enable SPL_LIBGENERIC for rk3036 based boards
In reply to Andy Yanfunction board_init_f_init_reserve will call memset, which is implemented in lib, and enabled by CONFIG_SPL_LIBGENERIC_SUPPORT in spl stage.
To reduce the code size, also enable SPL_TINY_MEMSET.
---
Changes in v2: None
arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------ configs/evb-rk3036_defconfig | 2 ++ configs/kylin-rk3036_defconfig | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-)
arch/arm/mach-rockchip/rk3036-board-spl.c +0 -6
@@ -53,9 +53,3 @@ void board_init_r(gd_t *id, ulong dest_addr)while (1 ) ; } - -void hang (void ) -{ -while (1 ) - ; -}
configs/evb-rk3036_defconfig +2 -0
@@ -2,6 +2,7 @@ CONFIG_ARM=y # CONFIG_SPL_USE_ARCH_MEMCPY is not set # CONFIG_SPL_USE_ARCH_MEMSET is not set CONFIG_ARCH_ROCKCHIP=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_EVB_RK3036=y CONFIG_SPL_STACK_R_ADDR=0x80000
@@ -38,5 +39,6 @@ CONFIG_DEBUG_UART_BASE=0x20068000 CONFIG_DEBUG_UART_CLOCK=24000000 CONFIG_DEBUG_UART_SHIFT=2 CONFIG_SYSRESET=y +CONFIG_SPL_TINY_MEMSET=y CONFIG_CMD_DHRYSTONE=y CONFIG_ERRNO_STR=y
configs/kylin-rk3036_defconfig +2 -1
@@ -2,6 +2,7 @@ CONFIG_ARM=y # CONFIG_SPL_USE_ARCH_MEMCPY is not set # CONFIG_SPL_USE_ARCH_MEMSET is not set CONFIG_ARCH_ROCKCHIP=y +CONFIG_SPL_LIBGENERIC_SUPPORT=y CONFIG_ROCKCHIP_RK3036=y CONFIG_TARGET_KYLIN_RK3036=y CONFIG_SPL_STACK_R_ADDR=0x80000
@@ -22,7 +23,6 @@ CONFIG_CMD_TIME=y # CONFIG_SPL_DOS_PARTITION is not set # CONFIG_SPL_ISO_PARTITION is not set # CONFIG_SPL_EFI_PARTITION is not set -CONFIG_SPL_PARTITION_UUIDS=y CONFIG_REGMAP=y CONFIG_SYSCON=y CONFIG_CLK=y
@@ -38,5 +38,6 @@ CONFIG_SYSRESET=y CONFIG_USB=y CONFIG_USB_DWC2=y CONFIG_USB_STORAGE=y +CONFIG_SPL_TINY_MEMSET=y CONFIG_CMD_DHRYSTONE=y CONFIG_ERRNO_STR=y
Signature · 1 line
2.7.4
PATCH v2 7/9 rockchip: enable SPL_LIBGENERIC for rk3036 based boards
Quoted 6 lines · Andy Yan
function
board_init_f_init_reservewill call memset, which is implemented in lib, and enabled byCONFIG_SPL_LIBGENERIC_SUPPORTin spl stage.
To reduce the code size, also enableSPL_TINY_MEMSET.Signed-off-by Andy Yan <[email protected]>
Quoted 8 lines
---
Changes in v2: None
arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------ configs/evb-rk3036_defconfig | 2 ++ configs/kylin-rk3036_defconfig | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-)
PATCH v2 8/9 rockchip: use debug() instead of printf when back to bootrom
In reply to Andy Yanprintf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.
---
Changes in v2: None
arch/arm/mach-rockchip/bootrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/bootrom.c +1 -1
@@ -10,7 +10,7 @@void back_to_bootrom (void ) {#if defined(CONFIG_SPL_LIBGENERIC_SUPPORT ) && !defined(CONFIG_TPL_BUILD ) -printf ("Returning to boot ROM..." ); +debug ("Returning to boot ROM..." );#endif _back_to_bootrom_s (); }
Signature · 1 line
2.7.4
PATCH v2 8/9 rockchip: use debug() instead of printf when back to bootrom
Hi Andy,
Quoted 25 lines · Andy Yan
printf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.
Signed-off-by Andy Yan <[email protected]>---
Changes in v2: None
arch/arm/mach-rockchip/bootrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm/mach-rockchip/bootrom.c +1
-2@@ -10,7 +10,7 @@void back_to_bootrom (void ) {#if defined(CONFIG_SPL_LIBGENERIC_SUPPORT ) && !defined(CONFIG_TPL_BUILD ) -printf ("Returning to boot ROM..." ); +debug ("Returning to boot ROM..." );#endif _back_to_bootrom_s (); } --
Quoted 3 lines
2.7.4
This is nice for seeing what went wrong when the return does not work. Could we use puts() instead perhaps?
Regards,
Simon
PATCH v2 9/9 rockchip: add u-boot specific dts for rk3036 sdk
In reply to Andy YanAdd this dts to enable debug uart releated devices before relocation.
---
Changes in v2: None
arch/arm/dts/rk3036-sdk-u-boot.dtsi | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 arch/arm/dts/rk3036-sdk-u-boot.dtsi
arch/arm/dts/rk3036-sdk-u-boot.dtsi new file +11 -0
@@ -0,0 +1,11 @@ +&uart2 { + u-boot,dm-pre-reloc; +}; + +&grf { + u-boot,dm-pre-reloc; +}; + +&pinctrl { + u-boot,dm-pre-reloc; +};
Signature · 1 line
2.7.4