Skip to contentSkip to conversation

make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN

PATCH New Andy Yan 4 participants 47 messages Jul 24, 2017 – Jul 27, 2017

Subsystems (8)
lore
Share & tools
lore

Andy Yan

author
#0 lore raw

v3 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 stage.
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 v3:
- use CONFIG_VAL(), which suggested by Simon
- disable SPL_DM_SERIAL
- use puts instead of printf, which suggested by Simon

Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon

Andy Yan (10):
make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN
mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently
powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently
microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN
indepently
sandbox: use CONFIG_VAL(SYS_MALLOC_F_LEN) to distinguish malloc pool
size before relocation
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 puts 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          |  4 ++--
 arch/arm/mach-rockchip/rk3036-board-spl.c |  6 ------
 arch/microblaze/cpu/start.S               |  8 ++++----
 arch/mips/cpu/start.S                     |  6 +++---
 arch/powerpc/cpu/mpc83xx/start.S          |  8 ++++----
 arch/powerpc/cpu/mpc85xx/start.S          | 11 +++++------
 arch/sandbox/cpu/start.c                  |  2 +-
 cmd/bdinfo.c                              |  4 ++--
 common/Makefile                           |  4 +++-
 common/board_f.c                          |  4 ++--
 common/board_r.c                          |  2 +-
 common/dlmalloc.c                         | 12 ++++++------
 common/init/board_init.c                  |  8 ++++----
 common/spl/spl.c                          |  8 ++++----
 configs/evb-rk3036_defconfig              |  7 ++++++-
 configs/kylin-rk3036_defconfig            |  7 ++++++-
 drivers/core/Kconfig                      |  8 ++++----
 drivers/serial/serial-uclass.c            |  4 ++--
 include/asm-generic/global_data.h         |  2 +-
 lib/asm-offsets.c                         |  2 +-
 lib/efi/efi_app.c                         |  2 +-
 23 files changed, 83 insertions(+), 57 deletions(-)
 create mode 100644 arch/arm/dts/rk3036-sdk-u-boot.dtsi
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v3 1/10 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 stage.
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 v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon

 Kconfig                           | 10 ++++++++++
 cmd/bdinfo.c                      |  4 ++--
 common/Makefile                   |  4 +++-
 common/board_f.c                  |  4 ++--
 common/board_r.c                  |  2 +-
 common/dlmalloc.c                 | 12 ++++++------
 common/init/board_init.c          |  8 ++++----
 common/spl/spl.c                  |  8 ++++----
 drivers/core/Kconfig              |  8 ++++----
 drivers/serial/serial-uclass.c    |  4 ++--
 include/asm-generic/global_data.h |  2 +-
 lib/asm-offsets.c                 |  2 +-
 lib/efi/efi_app.c                 |  2 +-
 13 files changed, 41 insertions(+), 29 deletions(-)
Kconfig +10 -0
index bb80ada..c1451bc 100644
@@ -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
cmd/bdinfo.c +2 -2
index 8971697..81ac78d 100644
@@ -344,9 +344,9 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc,
 #ifdef CONFIG_BOARD_TYPES
 	printf("Board Type  = %ld\n", gd->board_type);
 #endif
-#ifdef CONFIG_SYS_MALLOC_F
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr,
-	       CONFIG_SYS_MALLOC_F_LEN);
+	       CONFIG_VAL(SYS_MALLOC_F_LEN));
 #endif
 	if (gd->fdt_blob)
 		printf("fdt_blob = %p\n", gd->fdt_blob);
common/Makefile +3 -1
index 17a92ea..60681c8 100644
@@ -139,9 +139,11 @@ 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
+ifneq ($(CONFIG_$(SPL_)SYS_MALLOC_F_LEN),0)
 obj-y += malloc_simple.o
 endif
+endif
 obj-y += image.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += image-fdt.o
common/board_f.c +2 -2
index ffa84e3..a2af660 100644
@@ -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) && CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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) && CONFIG_VAL(SYS_MALLOC_F_LEN)
 	int ret;
 
 	bootstage_start(BOOTSTATE_ID_ACCUM_DM_F, "dm_f");
common/board_r.c +1 -1
index ecca1ed..985aa95 100644
@@ -256,7 +256,7 @@ static int initr_malloc(void)
 {
 	ulong malloc_start;
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	debug("Pre-reloc malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
 	      gd->malloc_ptr / 1024);
 #endif
common/dlmalloc.c +6 -6
index fc1e8b3..c37979b 100644
@@ -1254,7 +1254,7 @@ Void_t* mALLOc(bytes) size_t bytes;
 
   INTERNAL_SIZE_T nb;
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	/* 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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	assert(gd->malloc_base);	/* Set up by crt0.S */
-	gd->malloc_limit = CONFIG_SYS_MALLOC_F_LEN;
+	gd->malloc_limit = CONFIG_VAL(SYS_MALLOC_F_LEN);
 	gd->malloc_ptr = 0;
 #endif
 
common/init/board_init.c +4 -4
index bf4255b..4a391be 100644
@@ -46,8 +46,8 @@ __weak void arch_setup_gd(struct global_data *gd_ptr)
 ulong board_init_f_alloc_reserve(ulong top)
 {
 	/* Reserve early malloc arena */
-#if defined(CONFIG_SYS_MALLOC_F)
-	top -= CONFIG_SYS_MALLOC_F_LEN;
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	top -= CONFIG_VAL(SYS_MALLOC_F_LEN);
 #endif
 	/* LAST : reserve GD (rounded up to a multiple of 16 bytes) */
 	top = rounddown(top-sizeof(struct global_data), 16);
@@ -121,11 +121,11 @@ void board_init_f_init_reserve(ulong base)
 	 * Use gd as it is now properly set for all architectures.
 	 */
 
-#if defined(CONFIG_SYS_MALLOC_F)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	/* 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 += CONFIG_VAL(SYS_MALLOC_F_LEN);
 #endif
 }
 
common/spl/spl.c +4 -4
index 7f3fd92..c56cc6f 100644
@@ -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 CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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 = CONFIG_VAL(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 CONFIG_VAL(SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
 	debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
 	      gd->malloc_ptr / 1024);
 #endif
@@ -486,7 +486,7 @@ ulong spl_relocate_stack_gd(void)
 	gd_t *new_gd;
 	ulong ptr = CONFIG_SPL_STACK_R_ADDR;
 
-#ifdef CONFIG_SPL_SYS_MALLOC_SIMPLE
+#if defined(CONFIG_SPL_SYS_MALLOC_SIMPLE) && CONFIG_SPL_SYS_MALLOC_F_LEN
 	if (CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN) {
 		ptr -= CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN;
 		gd->malloc_base = ptr;
drivers/core/Kconfig +4 -4
index fb5c4e8..f8b19a4 100644
@@ -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
index f360534..9cae9fb 100644
@@ -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"
+#if !CONFIG_VAL(SYS_MALLOC_F_LEN)
+#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
index fb90be9..86bf656 100644
@@ -88,7 +88,7 @@ typedef struct global_data {
 #endif
 	unsigned int timebase_h;
 	unsigned int timebase_l;
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	unsigned long malloc_base;	/* base address of early malloc() */
 	unsigned long malloc_limit;	/* limit address */
 	unsigned long malloc_ptr;	/* current address */
lib/asm-offsets.c +1 -1
index 221ebbf..b04f7c6 100644
@@ -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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	DEFINE(GD_MALLOC_BASE, offsetof(struct global_data, malloc_base));
 #endif
 
lib/efi/efi_app.c +1 -1
index 452ab5d..f1afd9c 100644
@@ -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, CONFIG_VAL(SYS_MALLOC_F_LEN),
 					    &ret);
 	if (!gd->malloc_base)
 		return ret;
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 1/10 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN

Quoted 17 lines

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 stage.
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 v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon

Quoted 15 lines
 Kconfig                           | 10 ++++++++++
 cmd/bdinfo.c                      |  4 ++--
 common/Makefile                   |  4 +++-
 common/board_f.c                  |  4 ++--
 common/board_r.c                  |  2 +-
 common/dlmalloc.c                 | 12 ++++++------
 common/init/board_init.c          |  8 ++++----
 common/spl/spl.c                  |  8 ++++----
 drivers/core/Kconfig              |  8 ++++----
 drivers/serial/serial-uclass.c    |  4 ++--
 include/asm-generic/global_data.h |  2 +-
 lib/asm-offsets.c                 |  2 +-
 lib/efi/efi_app.c                 |  2 +-
 13 files changed, 41 insertions(+), 29 deletions(-)
#3 lore raw

PATCH v3 1/10 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN

In reply to Andy Yan
Quoted 18 lines

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 stage.
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 v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon

Quoted 15 lines
 Kconfig                           | 10 ++++++++++
 cmd/bdinfo.c                      |  4 ++--
 common/Makefile                   |  4 +++-
 common/board_f.c                  |  4 ++--
 common/board_r.c                  |  2 +-
 common/dlmalloc.c                 | 12 ++++++------
 common/init/board_init.c          |  8 ++++----
 common/spl/spl.c                  |  8 ++++----
 drivers/core/Kconfig              |  8 ++++----
 drivers/serial/serial-uclass.c    |  4 ++--
 include/asm-generic/global_data.h |  2 +-
 lib/asm-offsets.c                 |  2 +-
 lib/efi/efi_app.c                 |  2 +-
 13 files changed, 41 insertions(+), 29 deletions(-)
#4 lore raw

PATCH v3 1/10 make SPL and normal u-boot stage use independent SYS_MALLOC_F_LEN

In reply to Andy Yan
Quoted 19 lines

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 stage.
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 v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2:
- introduce a new control CONFIG_SPL_SYS_MALLOC_F_LEN, adviced by Simon

Quoted 15 lines
 Kconfig                           | 10 ++++++++++
 cmd/bdinfo.c                      |  4 ++--
 common/Makefile                   |  4 +++-
 common/board_f.c                  |  4 ++--
 common/board_r.c                  |  2 +-
 common/dlmalloc.c                 | 12 ++++++------
 common/init/board_init.c          |  8 ++++----
 common/spl/spl.c                  |  8 ++++----
 drivers/core/Kconfig              |  8 ++++----
 drivers/serial/serial-uclass.c    |  4 ++--
 include/asm-generic/global_data.h |  2 +-
 lib/asm-offsets.c                 |  2 +-
 lib/efi/efi_app.c                 |  2 +-
 13 files changed, 41 insertions(+), 29 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#5 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/mips/cpu/start.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/cpu/start.S +3 -3
index d01ee9f..aa07654 100644
@@ -60,8 +60,8 @@
 		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
-	li	t2, CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	li	t2, CONFIG_VAL(SYS_MALLOC_F_LEN)
 	PTR_SUBU \
 		sp, sp, t2		# reserve space for early malloc
 	and	sp, sp, t0		# force 16 byte alignment
@@ -75,7 +75,7 @@
 	blt	t0, t1, 1b
 	 PTR_ADDIU t0, PTRSIZE
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	PTR_S	sp, GD_MALLOC_BASE(k0)	# gd->malloc_base offset
 #endif
 	.endm
Signature · 1 line
2.7.4
#6 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

Quoted 9 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/mips/cpu/start.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#7 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 23 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/mips/cpu/start.S | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/cpu/start.S +0 -0
index d01ee9f..aa07654 100644

arch/mips/cpu/start.S line 64

Quoted 7 lines
arch/mips/cpu/start.S +2 -2
@@ -60,8 +60,8 @@
 		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
-	li	t2, CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	li	t2, CONFIG_VAL(SYS_MALLOC_F_LEN)

With CONFIG_VAL(...) there should always be a value returned.

Could we drop the #if guard around this, as the PTR_SUBU below will then an identity transform (i.e. it will compute "sp = sp - 0")?

Quoted 13 lines
arch/mips/cpu/start.S +1 -1
 	PTR_SUBU \
 		sp, sp, t2		# reserve space for early malloc
 	and	sp, sp, t0		# force 16 byte alignment
@@ -75,7 +75,7 @@
 	blt	t0, t1, 1b
 	 PTR_ADDIU t0, PTRSIZE
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	PTR_S	sp, GD_MALLOC_BASE(k0)	# gd->malloc_base offset
 #endif
 	.endm
#8 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

2017-07-27 12:44 GMT+02:00 Philipp Tomsich
<[email protected]>:

Quoted 38 lines · Andy Yan
Quoted 24 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/mips/cpu/start.S | 6 +++---

1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/cpu/start.S +0 -0
index d01ee9f..aa07654 100644

arch/mips/cpu/start.S line 64

Quoted 7 lines
arch/mips/cpu/start.S +2 -2
@@ -60,8 +60,8 @@
                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
-       li      t2, CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+       li      t2, CONFIG_VAL(SYS_MALLOC_F_LEN)

With CONFIG_VAL(...) there should always be a value returned.

Quoted 2 lines

Could we drop the #if guard around this, as the PTR_SUBU below will then an identity transform (i.e. it will compute "sp = sp - 0")?

I don't see any advantage in it. This code is compiled with "set .noreorder" so the assembler can't optimize or eliminate the dummy instructions in case of "CONFIG_SYS_MALLOC_F_LEN = 0".Also there is another instruction below which also needs this guard. Thus it would be more consistent if both places use the same #if guard.

Quoted 16 lines
Quoted 15 lines
arch/mips/cpu/start.S +1 -1
        PTR_SUBU \
                sp, sp, t2              # reserve space for early malloc
        and     sp, sp, t0              # force 16 byte alignment
@@ -75,7 +75,7 @@
        blt     t0, t1, 1b
         PTR_ADDIU t0, PTRSIZE
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
        PTR_S   sp, GD_MALLOC_BASE(k0)  # gd->malloc_base offset
 #endif
        .endm
Signature · 1 line
- Daniel
#9 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 10 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/mips/cpu/start.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#10 lore raw

PATCH v3 2/10 mips: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 11 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/mips/cpu/start.S | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#11 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/powerpc/cpu/mpc83xx/start.S |  8 ++++----
 arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +4 -4
index 2fed4a1..1c3c737 100644
@@ -274,14 +274,14 @@ in_flash:
 	cmplw	r3, r4
 	bne	1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(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."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_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, CONFIG_VAL(SYS_MALLOC_F_LEN)
 
 	/* Set pointer to pre-reloc malloc area in GD */
 	stw     r3, GD_MALLOC_BASE(r4)
arch/powerpc/cpu/mpc85xx/start.S +5 -6
index 63fdffd..58cb9fc 100644
@@ -1183,14 +1183,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."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_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,((CONFIG_VAL(SYS_MALLOC_F_LEN)+16+15)&~0xf)
 #endif
 
 	/* End of RAM */
@@ -1204,7 +1203,7 @@ _start_cont:
 	cmplw 	r4,r3
 	bne	1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	lis	r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
 	ori	r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
 
Signature · 1 line
2.7.4
#12 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

Quoted 8 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 9 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/powerpc/cpu/mpc83xx/start.S |  8 ++++----
 arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)
#13 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 52 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/powerpc/cpu/mpc83xx/start.S | 8 ++++---- arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------

2 files changed, 9 insertions(+), 10 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +4 -4
index 2fed4a1..1c3c737 100644
@@ -274,14 +274,14 @@ in_flash:
 	cmplw	r3, r4
 	bne	1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(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."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_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, CONFIG_VAL(SYS_MALLOC_F_LEN)
 
 	/* Set pointer to pre-reloc malloc area in GD */
 	stw     r3, GD_MALLOC_BASE(r4)
arch/powerpc/cpu/mpc85xx/start.S +0 -3
index 63fdffd..58cb9fc 100644
@@ -1183,14 +1183,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

arch/powerpc/cpu/mpc85xx/start.S _start_cont: · line 1193

Quoted 10 lines
arch/powerpc/cpu/mpc85xx/start.S +4 -2
-#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE > CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_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,((CONFIG_VAL(SYS_MALLOC_F_LEN)+16+15)&~0xf)
 #endif

Could we now just drop the outermost "#if CONFIG_VAL(SYS_MALLOC_F_LEN)" guard?

(And as a question to someone with knowledge of the history of this code:) Why are those 16 bytes ("for back chain termination and NULL return address") consumed only when CONFIG_SYS_MALLOC_F_LEN is defined? Shouldn't this be required both with SYS_MALLOC_F_LEN and without?

Quoted 12 lines
arch/powerpc/cpu/mpc85xx/start.S +1 -1
 	/* End of RAM */
@@ -1204,7 +1203,7 @@ _start_cont:
 	cmplw 	r4,r3
 	bne	1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	lis	r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
 	ori	r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
 
#14 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

Hi Phillip,

Quoted 80 lines · Philipp Tomsich
Quoted 70 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/powerpc/cpu/mpc83xx/start.S | 8 ++++---- arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------

2 files changed, 9 insertions(+), 10 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +1 -2
index 2fed4a1..1c3c737 100644
@@ -274,14 +274,14 @@ in_flash:
        cmplw   r3, r4
        bne     1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 
-#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE

arch/powerpc/cpu/mpc83xx/start.S +1 -1
-#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_MALLOC_F_LEN too large to fit into initial RAM." #endif

        /* r3 = new stack pointer / pre-reloc malloc area */
arch/powerpc/cpu/mpc83xx/start.S +1 -1
-       subi    r3, r3, CONFIG_SYS_MALLOC_F_LEN
+       subi    r3, r3, CONFIG_VAL(SYS_MALLOC_F_LEN)
 
        /* Set pointer to pre-reloc malloc area in GD */
        stw     r3, GD_MALLOC_BASE(r4)
arch/powerpc/cpu/mpc85xx/start.S +0 -0
index 63fdffd..58cb9fc 100644
@@ -1183,14 +1183,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 */

arch/powerpc/cpu/mpc85xx/start.S +0 -3
-#ifdef CONFIG_SYS_MALLOC_F_LEN
-
-#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE

arch/powerpc/cpu/mpc85xx/start.S +2 -1
-#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_MALLOC_F_LEN too large to fit into initial RAM." #endif

        /* Leave 16+ byte for back chain termination and NULL return

address */

arch/powerpc/cpu/mpc85xx/start.S +1 -1
-       subi    r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf)
+       subi    r3,r3,((CONFIG_VAL(SYS_MALLOC_F_LEN)+16+15)&~0xf)
Quoted 1 line

#endif

Could we now just drop the outermost "#if CONFIG_VAL(SYS_MALLOC_F_LEN)" guard?

Quoted 5 lines

(And as a question to someone with knowledge of the history of this code:) Why are those 16 bytes ("for back chain termination and NULL return address") consumed only when CONFIG_SYS_MALLOC_F_LEN is defined? Shouldn't this be required both with SYS_MALLOC_F_LEN and without?

The code is a bit tricky here: The actual back chain termination and NULL return address setting is further down:

stw     r0,0(r3)        /* Terminate Back Chain *
stw     r0,+4(r3)       /* NULL return address. */

Now, if we don't have a pre-reloc malloc area, the r3 we computed via

lis r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
ori r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */

will just become our stack pointer.

The global data are starts right after the stack area (CONFIG_SYS_INIT_SP_OFFSET == CONFIG_SYS_GBL_DATA_OFFSET), which is OK at first glance, since the stack "grows downwards", but since the back chain termination and null address setting write beyond the stack pointer (see above), they would write into the GD area (and might be overwritten). But since we subtracted 16 in the above statement, we have room left to store them.

The case where we have a pre-reloc malloc area is similar: Here we subtract the pre-reloc malloc area's size from the computed r3 and also a bit more to keep enough space for the back chain termination and null address:

subi r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf)

Otherwise, the addresses of these would lie in the pre-reloc malloc area, and might be overwritten.

So the statement basically exists to "fix" what the substraction of the pre-reloc malloc area size disturbed. If we don't have pre-reloc malloc, the initial setting of r3 (with the -16 offset) takes care of that already.

Quoted 6 lines
Quoted 6 lines
        /* End of RAM */
arch/powerpc/cpu/mpc85xx/start.S +0 -0
@@ -1204,7 +1203,7 @@ _start_cont:
        cmplw   r4,r3
        bne     1b
 
Quoted 6 lines

arch/powerpc/cpu/mpc85xx/start.S _start_cont: · line 1209

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/start.S +1 -1
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
        lis     r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
        ori     r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
 

Best regards,

Mario

#15 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

Mario,

Quoted 116 lines · Mario Six

Hi Phillip,

Quoted 80 lines · Philipp Tomsich
Quoted 70 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/powerpc/cpu/mpc83xx/start.S | 8 ++++---- arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------

2 files changed, 9 insertions(+), 10 deletions(-)
arch/powerpc/cpu/mpc83xx/start.S +1 -2
index 2fed4a1..1c3c737 100644
@@ -274,14 +274,14 @@ in_flash:
       cmplw   r3, r4
       bne     1b
 
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 
-#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE

arch/powerpc/cpu/mpc83xx/start.S +1 -1
-#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_MALLOC_F_LEN too large to fit into initial RAM." #endif

       /* r3 = new stack pointer / pre-reloc malloc area */
arch/powerpc/cpu/mpc83xx/start.S +1 -1
-       subi    r3, r3, CONFIG_SYS_MALLOC_F_LEN
+       subi    r3, r3, CONFIG_VAL(SYS_MALLOC_F_LEN)
 
       /* Set pointer to pre-reloc malloc area in GD */
       stw     r3, GD_MALLOC_BASE(r4)
arch/powerpc/cpu/mpc85xx/start.S +0 -0
index 63fdffd..58cb9fc 100644
@@ -1183,14 +1183,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 */

arch/powerpc/cpu/mpc85xx/start.S +0 -3
-#ifdef CONFIG_SYS_MALLOC_F_LEN
-
-#if CONFIG_SYS_MALLOC_F_LEN + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE

arch/powerpc/cpu/mpc85xx/start.S +2 -1
-#error "CONFIG_SYS_MALLOC_F_LEN too large to fit into initial RAM."
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+#if CONFIG_VAL(SYS_MALLOC_F_LEN) + GENERATED_GBL_DATA_SIZE >

CONFIG_SYS_INIT_RAM_SIZE
+#error "SYS_MALLOC_F_LEN too large to fit into initial RAM." #endif

       /* Leave 16+ byte for back chain termination and NULL return

address */

arch/powerpc/cpu/mpc85xx/start.S +1 -1
-       subi    r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf)
+       subi    r3,r3,((CONFIG_VAL(SYS_MALLOC_F_LEN)+16+15)&~0xf)
Quoted 1 line

#endif

Could we now just drop the outermost "#if CONFIG_VAL(SYS_MALLOC_F_LEN)" guard?

Quoted 5 lines

(And as a question to someone with knowledge of the history of this code:) Why are those 16 bytes ("for back chain termination and NULL return address") consumed only when CONFIG_SYS_MALLOC_F_LEN is defined? Shouldn't this be required both with SYS_MALLOC_F_LEN and without?

The code is a bit tricky here: The actual back chain termination and NULL return address setting is further down:

stw     r0,0(r3)        /* Terminate Back Chain *
stw     r0,+4(r3)       /* NULL return address. */

Now, if we don't have a pre-reloc malloc area, the r3 we computed via

lis r3,(CONFIG_SYS_INIT_RAM_ADDR)@h
ori r3,r3,((CONFIG_SYS_INIT_SP_OFFSET-16)&~0xf)@l /* Align to 16 */

will just become our stack pointer.

The global data are starts right after the stack area (CONFIG_SYS_INIT_SP_OFFSET == CONFIG_SYS_GBL_DATA_OFFSET), which is OK at first glance, since the stack "grows downwards", but since the back chain termination and null address setting write beyond the stack pointer (see above), they would write into the GD area (and might be overwritten). But since we subtracted 16 in the above statement, we have room left to store them.

The case where we have a pre-reloc malloc area is similar: Here we subtract the pre-reloc malloc area's size from the computed r3 and also a bit more to keep enough space for the back chain termination and null address:

Quoted 8 lines

subi r3,r3,((CONFIG_SYS_MALLOC_F_LEN+16+15)&~0xf)

Otherwise, the addresses of these would lie in the pre-reloc malloc area, and might be overwritten.

So the statement basically exists to "fix" what the substraction of the pre-reloc malloc area size disturbed. If we don't have pre-reloc malloc, the initial setting of r3 (with the -16 offset) takes care of that already.

Thanks for reviewing.

So how do you want to handle this: should I just merge this as-is (as it’s in a series that will go through the rockchip tree) or should we try to simplify this code in the same go?

Quoted 17 lines
Quoted 7 lines
Quoted 7 lines

       /* End of RAM */
arch/powerpc/cpu/mpc85xx/start.S +0 -0
@@ -1204,7 +1203,7 @@ _start_cont:
       cmplw   r4,r3
       bne     1b
 
Quoted 6 lines

arch/powerpc/cpu/mpc85xx/start.S _start_cont: · line 1209

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/start.S +1 -1
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
       lis     r4,(CONFIG_SYS_INIT_RAM_ADDR)@h
       ori     r4,r4,(CONFIG_SYS_GBL_DATA_OFFSET)@l
 

Best regards,

Mario

#16 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 9 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 9 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/powerpc/cpu/mpc83xx/start.S |  8 ++++----
 arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)
#17 lore raw

PATCH v3 3/10 powerpc: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 10 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 9 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/powerpc/cpu/mpc83xx/start.S |  8 ++++----
 arch/powerpc/cpu/mpc85xx/start.S | 11 +++++------
 2 files changed, 9 insertions(+), 10 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#18 lore raw

PATCH v3 4/10 microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/microblaze/cpu/start.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
arch/microblaze/cpu/start.S +4 -4
index 79dc0cf..baf4f51 100644
@@ -31,8 +31,8 @@ _start:
 	mts	rshr, r1
 	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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	addi	r1, r0, CONFIG_SYS_INIT_SP_OFFSET - CONFIG_VAL(SYS_MALLOC_F_LEN)
 #else
 	addi	r1, r0, CONFIG_SYS_INIT_SP_OFFSET
 #endif
@@ -162,14 +162,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 CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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 CONFIG_VAL(SYS_MALLOC_F_LEN)
 	addi	r6, r0, CONFIG_SPL_STACK_ADDR
 	swi	r6, r31, GD_MALLOC_BASE
 #endif
Signature · 1 line
2.7.4
#19 lore raw

PATCH v3 4/10 microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

Quoted 8 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/microblaze/cpu/start.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#20 lore raw

PATCH v3 4/10 microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 2 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

[nit] typo: "space"

Quoted 20 lines

relocation in spl stage as the normal u-boot stage. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

arch/microblaze/cpu/start.S | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
arch/microblaze/cpu/start.S +0 -0
index 79dc0cf..baf4f51 100644

arch/microblaze/cpu/start.S _start: · line 38

Quoted 10 lines
arch/microblaze/cpu/start.S +2 -2
@@ -31,8 +31,8 @@ _start:
 	mts	rshr, r1
 	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
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
+	addi	r1, r0, CONFIG_SYS_INIT_SP_OFFSET - CONFIG_VAL(SYS_MALLOC_F_LEN)
 #else
 	addi	r1, r0, CONFIG_SYS_INIT_SP_OFFSET
 #endif

This #if-guard should now be unnecessary (i.e. "CONFIG_SYS_INIT_SP_OFFSET - CONFIG_VAL(SYS_MALLOC_F_LEN)" will evaluate to "CONFIG_SYS_INIT_SP_OFFSET", if CONFIG_VAL(SYS_MALLOC_F_LEN) is 0.

Quoted 18 lines
arch/microblaze/cpu/start.S +2 -2
@@ -162,14 +162,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 CONFIG_VAL(SYS_MALLOC_F_LEN)
 	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 CONFIG_VAL(SYS_MALLOC_F_LEN)
 	addi	r6, r0, CONFIG_SPL_STACK_ADDR
 	swi	r6, r31, GD_MALLOC_BASE
 #endif
#21 lore raw

PATCH v3 4/10 microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 9 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/microblaze/cpu/start.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
#22 lore raw

PATCH v3 4/10 microblaze: spl and normal u-boot stage set SYS_MALLOC_F_LEN indepently

In reply to Andy Yan
Quoted 10 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. Use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit this condition.

---

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/microblaze/cpu/start.S | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#23 lore raw

PATCH v3 5/10 sandbox: use CONFIG_VAL(SYS_MALLOC_F_LEN) to distinguish malloc pool size before relocation

In reply to Andy Yan

From: Andy Yan <[email protected]>

SPL and normal u-boot stage use different malloc pool size configuration before relocation, so use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit different boot stage.

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/sandbox/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sandbox/cpu/start.c +1 -1
index f605d4d..00742fd 100644
@@ -310,7 +310,7 @@ int main(int argc, char *argv[])
 
 	memset(&data, '\0', sizeof(data));
 	gd = &data;
-#ifdef CONFIG_SYS_MALLOC_F_LEN
+#if CONFIG_VAL(SYS_MALLOC_F_LEN)
 	gd->malloc_base = CONFIG_MALLOC_F_ADDR;
 #endif
 	setup_ram_buf(state);
Signature · 1 line
2.7.4
#24 lore raw

PATCH v3 5/10 sandbox: use CONFIG_VAL(SYS_MALLOC_F_LEN) to distinguish malloc pool size before relocation

Quoted 8 lines

From: Andy Yan <[email protected]>

SPL and normal u-boot stage use different malloc pool size configuration before relocation, so use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit different boot stage.

Quoted 8 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/sandbox/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#25 lore raw

PATCH v3 5/10 sandbox: use CONFIG_VAL(SYS_MALLOC_F_LEN) to distinguish malloc pool size before relocation

In reply to Andy Yan
Quoted 8 lines

From: Andy Yan <[email protected]>

SPL and normal u-boot stage use different malloc pool size configuration before relocation, so use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit different boot stage.

Quoted 9 lines

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Changes in v2: None

 arch/sandbox/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#26 lore raw

PATCH v3 5/10 sandbox: use CONFIG_VAL(SYS_MALLOC_F_LEN) to distinguish malloc pool size before relocation

In reply to Andy Yan
Quoted 11 lines

From: Andy Yan <[email protected]>

SPL and normal u-boot stage use different malloc pool size configuration before relocation, so use CONFIG_VAL(SYS_MALLOC_F_LEN) to fit different boot stage.

Changes in v3:
- use CONFIG_VAL(), which suggested by Simon

Quoted 7 lines

Changes in v2: None

 arch/sandbox/cpu/start.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-rockchip, thanks!

author
#27 lore raw

PATCH v3 6/10 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board

In reply to 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.

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 1 +
 configs/kylin-rk3036_defconfig | 1 +
 2 files changed, 2 insertions(+)
configs/evb-rk3036_defconfig +1 -0
index 321ef71..78e2095 100644
@@ -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
index 715e4b2..fd20eff 100644
@@ -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
#28 lore raw

PATCH v3 6/10 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board

Quoted 8 lines

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.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 1 +
 configs/kylin-rk3036_defconfig | 1 +
 2 files changed, 2 insertions(+)
#29 lore raw

PATCH v3 6/10 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board

In reply to Andy Yan
Quoted 9 lines

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.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 1 +
 configs/kylin-rk3036_defconfig | 1 +
 2 files changed, 2 insertions(+)
#30 lore raw

PATCH v3 6/10 rockchip: set malloc pool size to 0 before relocation in spl state on rk3036 based board

In reply to Andy Yan
Quoted 10 lines

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.

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 1 +
 configs/kylin-rk3036_defconfig | 1 +
 2 files changed, 2 insertions(+)

Applied to u-boot-rockchip, thanks!

author
#31 lore raw

PATCH v3 7/10 rockchip: disable SPL_ARCH_MEMCPY/MEMSET for rk3036

In reply to Andy Yan

RK3036 has no enough sapce use ARCH_MEMCPY/MEMSET in spl stage

---

Changes in v3: None
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
index 78e2095..8e7a65b 100644
@@ -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
index fd20eff..266ac94 100644
@@ -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
#33 lore raw

PATCH v3 7/10 rockchip: disable SPL_ARCH_MEMCPY/MEMSET for rk3036

In reply to Andy Yan
Quoted 5 lines

RK3036 has no enough sapce use ARCH_MEMCPY/MEMSET in spl stage

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 2 ++
 configs/kylin-rk3036_defconfig | 2 ++
 2 files changed, 4 insertions(+)
#34 lore raw

PATCH v3 7/10 rockchip: disable SPL_ARCH_MEMCPY/MEMSET for rk3036

In reply to Andy Yan
Quoted 6 lines

RK3036 has no enough sapce use ARCH_MEMCPY/MEMSET in spl stage

Quoted 9 lines

---

Changes in v3: None
Changes in v2: None

 configs/evb-rk3036_defconfig   | 2 ++
 configs/kylin-rk3036_defconfig | 2 ++
 2 files changed, 4 insertions(+)

Applied to u-boot-rockchip, thanks!

author
#35 lore raw

PATCH v3 8/10 rockchip: enable SPL_LIBGENERIC for rk3036 based boards

In reply to Andy Yan

function 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.
As rk3036 will return to bootrom immediately after dram initialization, there is no need to run DM, so disable SPL_DM_SERIAL.

---

Changes in v3:
- disable SPL_DM_SERIAL

Changes in v2: None

 arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------
 configs/evb-rk3036_defconfig              | 4 +++-
 configs/kylin-rk3036_defconfig            | 4 +++-
 3 files changed, 6 insertions(+), 8 deletions(-)
arch/arm/mach-rockchip/rk3036-board-spl.c +0 -6
index 7b8d0ee..9458201 100644
@@ -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 +3 -1
index 8e7a65b..dd03816 100644
@@ -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
@@ -33,10 +34,11 @@ CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3036=y
-# CONFIG_SPL_SERIAL_PRESENT is not set
+# CONFIG_SPL_DM_SERIAL is not set
 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 +3 -1
index 266ac94..cd3074a 100644
@@ -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
@@ -34,9 +34,11 @@ CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_ROCKCHIP_RK3036=y
 CONFIG_DM_REGULATOR_FIXED=y
+# CONFIG_SPL_DM_SERIAL is not set
 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
#36 lore raw

PATCH v3 8/10 rockchip: enable SPL_LIBGENERIC for rk3036 based boards

Quoted 15 lines

function 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.
As rk3036 will return to bootrom immediately after dram initialization, there is no need to run DM, so disable SPL_DM_SERIAL.

---

Changes in v3:
- disable SPL_DM_SERIAL

Quoted 7 lines

Changes in v2: None

 arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------
 configs/evb-rk3036_defconfig              | 4 +++-
 configs/kylin-rk3036_defconfig            | 4 +++-
 3 files changed, 6 insertions(+), 8 deletions(-)
#37 lore raw

PATCH v3 8/10 rockchip: enable SPL_LIBGENERIC for rk3036 based boards

In reply to Andy Yan
Quoted 16 lines

function 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.
As rk3036 will return to bootrom immediately after dram initialization, there is no need to run DM, so disable SPL_DM_SERIAL.

---

Changes in v3:
- disable SPL_DM_SERIAL

Quoted 7 lines

Changes in v2: None

 arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------
 configs/evb-rk3036_defconfig              | 4 +++-
 configs/kylin-rk3036_defconfig            | 4 +++-
 3 files changed, 6 insertions(+), 8 deletions(-)
#38 lore raw

PATCH v3 8/10 rockchip: enable SPL_LIBGENERIC for rk3036 based boards

In reply to Andy Yan
Quoted 17 lines

function 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.
As rk3036 will return to bootrom immediately after dram initialization, there is no need to run DM, so disable SPL_DM_SERIAL.

---

Changes in v3:
- disable SPL_DM_SERIAL

Quoted 7 lines

Changes in v2: None

 arch/arm/mach-rockchip/rk3036-board-spl.c | 6 ------
 configs/evb-rk3036_defconfig              | 4 +++-
 configs/kylin-rk3036_defconfig            | 4 +++-
 3 files changed, 6 insertions(+), 8 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#39 lore raw

PATCH v3 9/10 rockchip: use puts instead of printf when back to bootrom

In reply to Andy Yan

printf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.

---

Changes in v3:
- use puts instead of printf, which suggested by Simon

Changes in v2: None

 arch/arm/mach-rockchip/bootrom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/mach-rockchip/bootrom.c +2 -2
index da36f92..4ca9962 100644
@@ -9,8 +9,8 @@
 
 void back_to_bootrom(void)
 {
-#if defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && !defined(CONFIG_TPL_BUILD)
-	printf("Returning to boot ROM...");
+#if defined(CONFIG_SPL_LIBCOMMON_SUPPORT) && !defined(CONFIG_TPL_BUILD)
+	puts("Returning to boot ROM...");
 #endif
 	_back_to_bootrom_s();
 }
Signature · 1 line
2.7.4
#40 lore raw

PATCH v3 9/10 rockchip: use puts instead of printf when back to bootrom

Quoted 6 lines

printf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.

---

Quoted 8 lines

Changes in v3:
- use puts instead of printf, which suggested by Simon

Changes in v2: None

 arch/arm/mach-rockchip/bootrom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#41 lore raw

PATCH v3 9/10 rockchip: use puts instead of printf when back to bootrom

In reply to Andy Yan
Quoted 7 lines

printf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.

---

Quoted 8 lines

Changes in v3:
- use puts instead of printf, which suggested by Simon

Changes in v2: None

 arch/arm/mach-rockchip/bootrom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
#42 lore raw

PATCH v3 9/10 rockchip: use puts instead of printf when back to bootrom

In reply to Andy Yan
Quoted 8 lines

printf will increase the code size more than 1kb, but platform like rk3036 has no enough space for it.

---

Quoted 8 lines

Changes in v3:
- use puts instead of printf, which suggested by Simon

Changes in v2: None

 arch/arm/mach-rockchip/bootrom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied to u-boot-rockchip, thanks!

author
#43 lore raw

PATCH v3 10/10 rockchip: add u-boot specific dts for rk3036 sdk

In reply to Andy Yan

Add this dts to enable debug uart releated devices before relocation.

---

Changes in v3: None
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
new file mode 100644
index 0000000..6f15f4a
@@ -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
#44 lore raw

PATCH v3 10/10 rockchip: add u-boot specific dts for rk3036 sdk

Quoted 5 lines

Add this dts to enable debug uart releated devices before relocation.

Quoted 9 lines

---

Changes in v3: None
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
#45 lore raw

PATCH v3 10/10 rockchip: add u-boot specific dts for rk3036 sdk

In reply to Andy Yan
Quoted 6 lines

Add this dts to enable debug uart releated devices before relocation.

Quoted 9 lines

---

Changes in v3: None
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
#46 lore raw

PATCH v3 10/10 rockchip: add u-boot specific dts for rk3036 sdk

In reply to Andy Yan
Quoted 7 lines

Add this dts to enable debug uart releated devices before relocation.

Quoted 9 lines

---

Changes in v3: None
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

Applied to u-boot-rockchip, thanks!