Skip to contentSkip to conversation

powerpc/p1022ds: nand: introduce the TPL based on the SPL

PATCH New ying.zhang at freescale.com 3 participants 8 messages Jun 9, 2013 – Jun 18, 2013

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

From: Ying Zhang <[email protected]>

Due to the nand SPL on the board P1022DS has a size limit, it can not be more than 4K. So, the SPL cannot initialize the DDR with the SPD code. This patch introduces TPL to enable a loader stub that runs in the L2 SRAM, after being loaded by the code from the SPL. It initializes the DDR with the SPD.

The TPL's size is sizeable, the maximum size must not exceed the size of L2 SRAM. It initializes the DDR through SPD code, and copys final uboot image to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset 256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80 +++++++++
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101 ++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93 +++++++++++
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168 ++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75 +++++++--
 tpl/Makefile                                       |  161 +++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
Makefile +24 -1
index ef154aa..65849d1 100644
@@ -118,10 +118,11 @@ endif # ifneq ($(BUILD_DIR),)
 
 OBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
 SPLTREE		:= $(OBJTREE)/spl
+TPLTREE		:= $(OBJTREE)/tpl
 SRCTREE		:= $(CURDIR)
 TOPDIR		:= $(SRCTREE)
 LNDIR		:= $(OBJTREE)
-export	TOPDIR SRCTREE OBJTREE SPLTREE
+export	TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
 
 MKCONFIG	:= $(SRCTREE)/mkconfig
 export MKCONFIG
@@ -412,9 +413,14 @@ ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map
 ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin
 ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin
 ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
+ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
 ifneq ($(CONFIG_SPL_TARGET),)
 ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))
+else
+ifneq ($(CONFIG_TPL_TARGET),)
+ALL-$(CONFIG_TPL) += $(obj)$(subst ",,$(CONFIG_TPL_TARGET))
+endif
 endif
 
 # enable combined SPL/u-boot/dtb rules for tegra
@@ -498,6 +504,18 @@ $(obj)u-boot-with-spl.bin: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
 		rm $(obj)spl/u-boot-spl-pad.bin
 
+$(obj)u-boot-with-tpl.bin: $(obj)spl/u-boot-spl.bin $(obj)tpl/u-boot-tpl.bin \
+		$(obj)u-boot.bin
+		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SPL_PAD_TO) \
+			-I binary -O binary \
+			$(obj)spl/u-boot-spl.bin $(obj)spl/u-boot-spl-pad.bin
+		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_TPL_PAD_TO) \
+			-I binary -O binary \
+			$(obj)tpl/u-boot-tpl.bin $(obj)tpl/u-boot-tpl-pad.bin
+		cat $(obj)spl/u-boot-spl-pad.bin $(obj)tpl/u-boot-tpl-pad.bin \
+			$(obj)u-boot.bin > $@
+		rm $(obj)spl/u-boot-spl-pad.bin $(obj)tpl/u-boot-tpl-pad.bin
+
 $(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 		$(MAKE) -C $(SRCTREE)/arch/arm/imx-common \
 			$(OBJTREE)/u-boot-with-spl.imx
@@ -622,6 +640,9 @@ $(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot.bin
 $(obj)spl/u-boot-spl.bin:	$(SUBDIR_TOOLS) depend
 		$(MAKE) -C spl all
 
+$(obj)tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS)	depend
+		$(MAKE) -C tpl all
+
 updater:
 		$(MAKE) -C tools/updater all
 
@@ -870,6 +891,8 @@ clobber:	tidy
 	@rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
 	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
 	@rm -f $(obj)spl/u-boot-spl.lds
+	@rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}
+	@rm -f $(obj)tpl/u-boot-tpl.lds
 	@rm -f $(obj)MLO MLO.byteswap
 	@rm -f $(obj)SPL
 	@rm -f $(obj)tools/xway-swap-bytes
README +53 -2

68 lines not on this page · raw message

arch/powerpc/config.mk +2 -0
index e32d2bf..aebb0aa 100644
@@ -48,5 +48,7 @@ endif
 
 # Only test once
 ifneq ($(CONFIG_SPL_BUILD),y)
+ifneq ($(CONFIG_TPL_BUILD),y)
 ALL-y += checkgcc4
 endif
+endif
arch/powerpc/cpu/mpc85xx/spl_minimal.c +16 -0
index c6b9cd0..a2d9417 100644
@@ -30,8 +30,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void cpu_init_f(void)
 {
+#if defined(CONFIG_SYS_NAND_BR_PRELIM) && defined(CONFIG_SYS_NAND_OR_PRELIM)
+	set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
+	set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
+#endif
+#if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM)
+	set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
+	set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
+#endif
+
 #ifdef CONFIG_SYS_INIT_L2_ADDR
 	ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
+	char *l2srbar;
+	int i;
 
 	out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR);
 
@@ -42,6 +53,11 @@ void cpu_init_f(void)
 	/* set L2E=1 & L2SRAM=001 */
 	out_be32(&l2cache->l2ctl,
 		(MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE));
+
+	/* Initialize L2 SRAM to zero */
+	l2srbar = (char *)CONFIG_SYS_INIT_L2_ADDR;
+	for (i = 0; i < CONFIG_SYS_L2_SIZE; i++)
+		l2srbar[i] = 0;
 #endif
 }
 
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +80 -0

80 lines not on this page · raw message

arch/powerpc/cpu/mpc8xxx/ddr/lc_common_dimm_params.c +2 -2
index 56128a7..e46100a 100644
@@ -218,13 +218,13 @@ compute_lowest_common_dimm_parameters(const dimm_params_t *dimm_params,
 		if (dimm_params[i].n_ranks) {
 			if (dimm_params[i].registered_dimm) {
 				temp1 = 1;
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 				printf("Detected RDIMM %s\n",
 					dimm_params[i].mpart);
 #endif
 			} else {
 				temp2 = 1;
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 				printf("Detected UDIMM %s\n",
 					dimm_params[i].mpart);
 #endif
arch/powerpc/lib/Makefile +2 -0
index 59c723b..c61eb06 100644
@@ -59,10 +59,12 @@ SOBJS-y	+= reloc.o
 
 COBJS-$(CONFIG_BAT_RW) += bat_rw.o
 ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_TPL_BUILD
 ifndef CONFIG_SYS_GENERIC_BOARD
 COBJS-y	+= board.o
 endif
 endif
+endif
 COBJS-y	+= bootm.o
 COBJS-y	+= cache.o
 COBJS-y	+= extable.o
board/freescale/p1022ds/Makefile +3 -0
index 9746063..58f224e 100644
@@ -27,6 +27,9 @@ else
 ifdef CONFIG_SPL_BUILD
 COBJS-y += spl.o
 endif
+ifdef CONFIG_TPL_BUILD
+COBJS-y += tpl.o
+endif
 COBJS-y	+= $(BOARD).o
 COBJS-y	+= ddr.o
 COBJS-y	+= law.o
board/freescale/p1022ds/spl_minimal.c +3 -53

82 lines not on this page · raw message

board/freescale/p1022ds/tlb.c +2 -2
index 9b14c37..aed8b86 100644
@@ -41,7 +41,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
 		      MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
 		      0, 1, BOOKE_PAGESZ_1M, 1),
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 	/* W**G* - Flash/promjet, localbus */
 	/* This will be changed to *I*G* after relocation to RAM. */
 	SET_TLB_ENTRY(1, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_BASE_PHYS,
@@ -75,7 +75,7 @@ struct fsl_e_tlb_entry tlb_table[] = {
 		      0, 7, BOOKE_PAGESZ_4K, 1),
 
 #if defined(CONFIG_SYS_RAMBOOT) || \
-	(defined(CONFIG_SPL) && !defined(CONFIG_SPL_COMMON_INIT_DDR))
+	(defined(CONFIG_SPL) && !defined(CONFIG_COMMON_INIT_DDR))
 	/* **** - eSDHC/eSPI/NAND boot */
 	SET_TLB_ENTRY(1, CONFIG_SYS_DDR_SDRAM_BASE, CONFIG_SYS_DDR_SDRAM_BASE,
 			MAS3_SX|MAS3_SW|MAS3_SR, 0,
board/freescale/p1022ds/tpl.c new file +101 -0

101 lines not on this page · raw message

common/Makefile +9 -0
index 3581603..7976adb 100644
@@ -27,6 +27,7 @@ LIB	= $(obj)libcommon.o
 
 # core
 ifndef CONFIG_SPL_BUILD
+ifndef CONFIG_TPL_BUILD
 COBJS-y += main.o
 COBJS-y += command.o
 COBJS-y += exports.o
@@ -204,6 +205,7 @@ COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 COBJS-$(CONFIG_CMD_DFU) += cmd_dfu.o
 COBJS-$(CONFIG_CMD_GPT) += cmd_gpt.o
 endif
+endif
 
 ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
@@ -223,6 +225,13 @@ else
 COBJS-y += env_nowhere.o
 endif
 endif
+
+ifdef CONFIG_TPL_BUILD
+COBJS-$(CONFIG_TPL_ENV_SUPPORT) += env_attr.o
+COBJS-$(CONFIG_TPL_ENV_SUPPORT) += env_flags.o
+COBJS-$(CONFIG_TPL_ENV_SUPPORT) += env_callback.o
+endif
+
 # core command
 COBJS-y += cmd_nvedit.o
 #environment
common/cmd_nvedit.c +4 -4
index 2478c95..d91a2ef 100644
@@ -87,7 +87,7 @@ int get_env_id(void)
 	return env_id;
 }
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 /*
  * Command interface: print one or all environment variables
  *
@@ -356,7 +356,7 @@ ulong getenv_hex(const char *varname, ulong default_val)
 	return value;
 }
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
 	if (argc < 2)
@@ -700,7 +700,7 @@ ulong getenv_ulong(const char *name, int base, ulong default_val)
 	return str ? simple_strtoul(str, NULL, base) : default_val;
 }
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 #if defined(CONFIG_CMD_SAVEENV) && !defined(CONFIG_ENV_IS_NOWHERE)
 static int do_env_save(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
@@ -741,7 +741,7 @@ int envmatch(uchar *s1, int i2)
 	return -1;
 }
 
-#ifndef CONFIG_SPL_BUILD
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD)
 static int do_env_default(cmd_tbl_t *cmdtp, int __flag,
 			  int argc, char * const argv[])
 {
config.mk +32 -0
index ddf350e..484daf5 100644
@@ -41,8 +41,12 @@ ifneq ($(OBJTREE),$(SRCTREE))
 ifeq ($(CONFIG_SPL_BUILD),y)
 obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
 else
+ifeq ($(CONFIG_TPL_BUILD),y)
+obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
+else
 obj := $(if $(dir),$(OBJTREE)/$(dir)/,$(OBJTREE)/)
 endif
+endif
 src := $(if $(dir),$(SRCTREE)/$(dir)/,$(SRCTREE)/)
 
 $(shell mkdir -p $(obj))
@@ -53,8 +57,14 @@ obj := $(if $(dir),$(SPLTREE)/$(dir)/,$(SPLTREE)/)
 
 $(shell mkdir -p $(obj))
 else
+ifeq ($(CONFIG_TPL_BUILD),y)
+obj := $(if $(dir),$(TPLTREE)/$(dir)/,$(TPLTREE)/)
+
+$(shell mkdir -p $(obj))
+else
 obj :=
 endif
+endif
 src :=
 endif
 
@@ -210,6 +220,11 @@ CPPFLAGS += -ffunction-sections -fdata-sections
 LDFLAGS_FINAL += --gc-sections
 endif
 
+ifeq ($(CONFIG_TPL_BUILD),y)
+CPPFLAGS += -ffunction-sections -fdata-sections
+LDFLAGS_FINAL += --gc-sections
+endif
+
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
 endif
@@ -218,10 +233,18 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 CPPFLAGS += -DCONFIG_SPL_TEXT_BASE=$(CONFIG_SPL_TEXT_BASE)
 endif
 
+ifneq ($(CONFIG_TPL_TEXT_BASE),)
+CPPFLAGS += -DCONFIG_TPL_TEXT_BASE=$(CONFIG_TPL_TEXT_BASE)
+endif
+
 ifneq ($(CONFIG_SPL_PAD_TO),)
 CPPFLAGS += -DCONFIG_SPL_PAD_TO=$(CONFIG_SPL_PAD_TO)
 endif
 
+ifneq ($(CONFIG_TPL_PAD_TO),)
+CPPFLAGS += -DCONFIG_TPL_PAD_TO=$(CONFIG_TPL_PAD_TO)
+endif
+
 ifneq ($(CONFIG_UBOOT_PAD_TO),)
 CPPFLAGS += -DCONFIG_UBOOT_PAD_TO=$(CONFIG_UBOOT_PAD_TO)
 endif
@@ -230,6 +253,10 @@ ifeq ($(CONFIG_SPL_BUILD),y)
 CPPFLAGS += -DCONFIG_SPL_BUILD
 endif
 
+ifeq ($(CONFIG_TPL_BUILD),y)
+CPPFLAGS += -DCONFIG_TPL_BUILD
+endif
+
 # Does this architecture support generic board init?
 ifeq ($(__HAVE_ARCH_GENERIC_BOARD),)
 ifneq ($(CONFIG_SYS_GENERIC_BOARD),)
@@ -294,6 +321,11 @@ ifneq ($(CONFIG_SPL_TEXT_BASE),)
 LDFLAGS_u-boot-spl += -Ttext $(CONFIG_SPL_TEXT_BASE)
 endif
 
+LDFLAGS_u-boot-tpl += -T $(obj)u-boot-tpl.lds $(LDFLAGS_FINAL)
+ifneq ($(CONFIG_TPL_TEXT_BASE),)
+LDFLAGS_u-boot-tpl += -Ttext $(CONFIG_TPL_TEXT_BASE)
+endif
+
 # Linus' kernel sanity checking tool
 CHECKFLAGS     := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
                   -Wbitwise -Wno-return-void -D__CHECK_ENDIAN__ $(CF)
doc/README.TPL new file +93 -0

93 lines not on this page · raw message

drivers/mtd/nand/Makefile +8 -0
index 8821704..35e979e 100644
@@ -42,6 +42,8 @@ COBJS-$(CONFIG_SPL_NAND_BASE) += nand_base.o
 
 else # not spl
 
+ifndef CONFIG_TPL_BUILD
+
 NORMAL_DRIVERS=y
 
 COBJS-y += nand.o
@@ -51,6 +53,7 @@ COBJS-y += nand_util.o
 COBJS-y += nand_ecc.o
 COBJS-y += nand_base.o
 
+endif # not tpl
 endif # not spl
 
 ifdef NORMAL_DRIVERS
@@ -82,8 +85,13 @@ COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 
 else  # minimal SPL drivers
 
+ifdef CONFIG_SPL_BUILD
 COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_spl.o
 COBJS-$(CONFIG_NAND_MXC) += mxc_nand_spl.o
+endif
+ifdef CONFIG_TPL_BUILD
+COBJS-$(CONFIG_NAND_FSL_ELBC) += fsl_elbc_tpl.o
+endif
 
 endif # drivers
 endif # nand
drivers/mtd/nand/fsl_elbc_tpl.c new file +168 -0

168 lines not on this page · raw message

drivers/serial/serial.c +1 -1
index daa8003..81aca81 100644
@@ -371,7 +371,7 @@ static struct serial_device *get_current(void)
 
 	/* We must have a console device */
 	if (!dev) {
-#ifdef CONFIG_SPL_BUILD
+#if defined(CONFIG_SPL_BUILD) || defined(CONFIG_TPL_BUILD)
 		puts("Cannot find console\n");
 		hang();
 #else
include/bootstage.h +2 -1
index ef07a87..1e8c492 100644
@@ -220,7 +220,8 @@ enum bootstage_id {
  */
 ulong timer_get_boot_us(void);
 
-#if !defined(CONFIG_SPL_BUILD) && !defined(USE_HOSTCC)
+#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_TPL_BUILD) && \
+	!defined(USE_HOSTCC)
 /*
  * Board code can implement show_boot_progress() if needed.
  *
include/configs/P1022DS.h +58 -17

132 lines not on this page · raw message

tpl/Makefile new file +161 -0

161 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 215 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Due to the nand SPL on the board P1022DS has a size limit, it can not be
more than 4K. So, the SPL cannot initialize the DDR with the SPD code. This patch introduces TPL to enable a loader stub that runs in the L2 SRAM,
after being loaded by the code from the SPL. It initializes the DDR with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the size of L2
SRAM. It initializes the DDR through SPD code, and copys final uboot image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80 +++++++++
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101  
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93 +++++++++++
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168  
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75 +++++++--
 tpl/Makefile                                       |  161  
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
Makefile +2 -1
index ef154aa..65849d1 100644
@@ -118,10 +118,11 @@ endif # ifneq ($(BUILD_DIR),)
 
 OBJTREE		:= $(if $(BUILD_DIR),$(BUILD_DIR),$(CURDIR))
 SPLTREE		:= $(OBJTREE)/spl
+TPLTREE		:= $(OBJTREE)/tpl
 SRCTREE		:= $(CURDIR)
 TOPDIR		:= $(SRCTREE)
 LNDIR		:= $(OBJTREE)
-export	TOPDIR SRCTREE OBJTREE SPLTREE
+export	TOPDIR SRCTREE OBJTREE SPLTREE TPLTREE
 
 MKCONFIG	:= $(SRCTREE)/mkconfig
 export MKCONFIG
@@ -412,9 +413,14 @@ ALL-y += $(obj)u-boot.srec $(obj)u-boot.bin  

$(obj)System.map
ALL-$(CONFIG_NAND_U_BOOT) += $(obj)u-boot-nand.bin ALL-$(CONFIG_ONENAND_U_BOOT) += $(obj)u-boot-onenand.bin ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin

Makefile +5 -0
+ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
 ifneq ($(CONFIG_SPL_TARGET),)
 ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))
+else
+ifneq ($(CONFIG_TPL_TARGET),)
+ALL-$(CONFIG_TPL) += $(obj)$(subst ",,$(CONFIG_TPL_TARGET))
+endif
 endif
 
 # enable combined SPL/u-boot/dtb rules for tegra
@@ -498,6 +504,18 @@ $(obj)u-boot-with-spl.bin:  

$(obj)spl/u-boot-spl.bin $(obj)u-boot.bin

Makefile +1 -0
 		cat $(obj)spl/u-boot-spl-pad.bin $(obj)u-boot.bin > $@
 		rm $(obj)spl/u-boot-spl-pad.bin
 
+$(obj)u-boot-with-tpl.bin: $(obj)spl/u-boot-spl.bin  

$(obj)tpl/u-boot-tpl.bin \

Makefile +4 -0
+		$(obj)u-boot.bin
+		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_SPL_PAD_TO) \
+			-I binary -O binary \
+			$(obj)spl/u-boot-spl.bin  

$(obj)spl/u-boot-spl-pad.bin

Makefile +3 -0
+		$(OBJCOPY) ${OBJCFLAGS} --pad-to=$(CONFIG_TPL_PAD_TO) \
+			-I binary -O binary \
+			$(obj)tpl/u-boot-tpl.bin  

$(obj)tpl/u-boot-tpl-pad.bin

Makefile +1 -0
+		cat $(obj)spl/u-boot-spl-pad.bin  

$(obj)tpl/u-boot-tpl-pad.bin \

Makefile +2 -0
+			$(obj)u-boot.bin > $@
+		rm $(obj)spl/u-boot-spl-pad.bin  

$(obj)tpl/u-boot-tpl-pad.bin

Makefile +1 -0
+
 $(obj)u-boot-with-spl.imx: $(obj)spl/u-boot-spl.bin $(obj)u-boot.bin
 		$(MAKE) -C $(SRCTREE)/arch/arm/imx-common \
 			$(OBJTREE)/u-boot-with-spl.imx
@@ -622,6 +640,9 @@ $(obj)u-boot-nand.bin:	nand_spl  

$(obj)u-boot.bin
$(obj)spl/u-boot-spl.bin: $(SUBDIR_TOOLS) depend

Makefile +5 -0
 		$(MAKE) -C spl all
 
+$(obj)tpl/u-boot-tpl.bin:	$(SUBDIR_TOOLS)	depend
+		$(MAKE) -C tpl all
+
 updater:
 		$(MAKE) -C tools/updater all
@@ -870,6 +891,8 @@ clobber:	tidy
 	@rm -f  
 $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
 	@rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
 	@rm -f $(obj)spl/u-boot-spl.lds
+	@rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}
+	@rm -f $(obj)tpl/u-boot-tpl.lds
 	@rm -f $(obj)MLO MLO.byteswap
 	@rm -f $(obj)SPL
Makefile +0 -0
 	@rm -f $(obj)tools/xway-swap-bytes
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,  
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of  

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size  

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before  

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is  

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append  

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some  

TPLs

README FIT uImage format: · line 3110

Quoted 2 lines
README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's generalize it into multiple U-Boot phases, each of which has its own autoconf.mk. The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared under different ifdefs.

Quoted 27 lines
arch/powerpc/cpu/mpc85xx/spl_minimal.c +11 -0
index c6b9cd0..a2d9417 100644
@@ -30,8 +30,19 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void cpu_init_f(void)
 {
+#if defined(CONFIG_SYS_NAND_BR_PRELIM) &&  
 defined(CONFIG_SYS_NAND_OR_PRELIM)
+	set_lbc_br(0, CONFIG_SYS_NAND_BR_PRELIM);
+	set_lbc_or(0, CONFIG_SYS_NAND_OR_PRELIM);
+#endif
+#if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM)
+	set_lbc_or(2, CONFIG_SYS_OR2_PRELIM);
+	set_lbc_br(2, CONFIG_SYS_BR2_PRELIM);
+#endif
+
 #ifdef CONFIG_SYS_INIT_L2_ADDR
 	ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
+	char *l2srbar;
+	int i;
 
 	out_be32(&l2cache->l2srbar0, CONFIG_SYS_INIT_L2_ADDR);

arch/powerpc/cpu/mpc85xx/spl_minimal.c void cpu_init_f(void) · line 60

Quoted 8 lines
arch/powerpc/cpu/mpc85xx/spl_minimal.c +5 -0
@@ -42,6 +53,11 @@ void cpu_init_f(void)
 	/* set L2E=1 & L2SRAM=001 */
 	out_be32(&l2cache->l2ctl,
 		(MPC85xx_L2CTL_L2E | MPC85xx_L2CTL_L2SRAM_ENTIRE));
+
+	/* Initialize L2 SRAM to zero */
+	l2srbar = (char *)CONFIG_SYS_INIT_L2_ADDR;
+	for (i = 0; i < CONFIG_SYS_L2_SIZE; i++)
+		l2srbar[i] = 0;

Please do not commingle TPL infrastructure with 85xx or p1022ds implementation details. They should be separate patches.

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +0 -0
new file mode 100644
index 0000000..344c325

What is different about this compared to every other 85xx linker script that justifies a separate copy?

Quoted 25 lines
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +4 -0
+Estimating stack usage
+----------------------
+
+With gcc 4.6 (and later) and the use of GNU cflow it is possible to  

estimate

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +2 -1
+stack usage at various points in run sequence of TPL.  The  
-fstack-usage option
+to gcc will produce '.su' files (such as  

arch/arm/cpu/armv7/syslib.su) that
+will give stack usage information and cflow can construct program flow.

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +5 -0
+
+Must have gcc 4.6 or later, which supports -fstack-usage
+
+1) Build normally
+2) Perform the following shell command to generate a list of C files  

used in
+TPL:
+$ find tpl -name '*.su' | sed -e 's:^tpl/::' -e 's:[.]su$:.c:' > used-tpl.list
+3) Execute cflow:
+$ cflow --main=board_init_r cat used-tpl.list 2>&1 | $PAGER

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +3 -0
+
+cflow will spit out a number of warnings as it does not parse
+the config files and picks functions based on #ifdef.  Parsing the  
Quoted 4 lines

'.i'
+files instead introduces another set of headaches. These warnings are
+not usually important to understanding the flow, however.

Really, you even duplicated this stuff for TPL?

drivers/mtd/nand/fsl_elbc_tpl.c

Quoted 6 lines
drivers/mtd/nand/fsl_elbc_tpl.c new file +0 -0
new file mode 100644
index 0000000..09868c4

...and here you duplicated an entire driver!

NACK

-Scott

#2 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, June 13, 2013 6:29 AM
To: Zhang Ying-B40530
Cc: u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061; Zhang Ying-B40530
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 136 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Due to the nand SPL on the board P1022DS has a size limit, it can not be
more than 4K. So, the SPL cannot initialize the DDR with the SPD code. This patch introduces TPL to enable a loader stub that runs in the L2 SRAM,
after being loaded by the code from the SPL. It initializes the DDR with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the size of L2
SRAM. It initializes the DDR through SPD code, and copys final uboot image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80 +++++++++
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101  
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93 +++++++++++
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168  
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75 +++++++--
 tpl/Makefile                                       |  161  
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,  
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of  

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size  

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before  

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is  

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append  

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some  

TPLs

README FIT uImage format: · line 3110

Quoted 2 lines
README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's generalize it into multiple U-Boot phases, each of which has its own autoconf.mk. The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared under different ifdefs.
[Zhang Ying]
I know the concept of a separate autoconf.mk for multiple U-Boot phases. If these symbols are only used in the C files, should do as you say. But most of these symbols were used in the Makefile to contain the Library. The patch "separate autoconf.mk" has not be merged, in this case, they can only declared separately.

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +0 -0
new file mode 100644
index 0000000..344c325

What is different about this compared to every other 85xx linker script that justifies a separate copy?
[Zhang Ying]
It was a little different from the u-boot-spl.lds:
There is no .resetvec in u-boot-tpl.lds and the start address of .text is different.
if share, need to change the file name. It will be used by SPL and TPL. I don't know whether someone will put forward different opinions.

drivers/mtd/nand/fsl_elbc_tpl.c

Quoted 6 lines
drivers/mtd/nand/fsl_elbc_tpl.c new file +0 -0
new file mode 100644
index 0000000..09868c4

...and here you duplicated an entire driver!
[Zhang Ying]
There are two purposes to do so:
1. As mentioned above that u-boot-tpl.lds, if share, need to change the file name.
2. Make the functionality "nand_load" to non-static, because it will be called by the external function to get the environment from the nand flash.
Why use this? Because the common nand drivers need malloc the large memory that large than the size of L2 SRAM(256K). There was unable to use common nand drivers in the TPL.

#3 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 163 lines · On 06/13/2013 02:27:44 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, June 13, 2013 6:29 AM
To: Zhang Ying-B40530
Cc: u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061; Zhang Ying-B40530
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 3 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Due to the nand SPL on the board P1022DS has a size limit, it can

not

Quoted 2 lines

be
more than 4K. So, the SPL cannot initialize the DDR with the SPD

code.

Quoted 1 line

This patch introduces TPL to enable a loader stub that runs in the

L2

Quoted 6 lines

SRAM,
after being loaded by the code from the SPL. It initializes the DDR with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the

size

Quoted 25 lines

of L2
SRAM. It initializes the DDR through SPD code, and copys final uboot image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80 +++++++++
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
Quoted 8 lines
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93  

+++++++++++

Quoted 91 lines
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75 +++++++--
 tpl/Makefile                                       |  161
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some

TPLs

README FIT uImage format: · line 3110

Quoted 2 lines
README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now
that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's generalize it into multiple U-Boot phases, each of which has its own autoconf.mk. The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared under

Quoted 8 lines

different ifdefs.
[Zhang Ying]
I know the concept of a separate autoconf.mk for multiple U-Boot phases.
If these symbols are only used in the C files, should do as you say. But most of these symbols were used in the Makefile to contain the Library. The patch "separate autoconf.mk" has not be merged, in this case, they can only declared separately.

Treat the autoconf.mk patch as a dependency. Don't try to hack around its absence.

Quoted 9 lines

arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds

Quoted 6 lines
arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds new file +0 -0
new file mode 100644
index 0000000..344c325

What is different about this compared to every other 85xx linker script

Quoted 8 lines

that justifies a separate copy?
[Zhang Ying]
It was a little different from the u-boot-spl.lds:
There is no .resetvec in u-boot-tpl.lds and the start address of .text is different.
if share, need to change the file name. It will be used by SPL and TPL.
I don't know whether someone will put forward different opinions.

The name doesn't need to change. Consider TPL as being a "second SPL" and then the name works fine. :-)

Resetvec can be handled via an ifdef.

Quoted 4 lines
Quoted 4 lines
drivers/mtd/nand/fsl_elbc_tpl.c new file +0 -0
new file mode 100644
index 0000000..09868c4
Quoted 8 lines

drivers/mtd/nand/fsl_elbc_tpl.c

Quoted 2 lines
drivers/mtd/nand/fsl_elbc_tpl.c new file +0 -0

...and here you duplicated an entire driver!
[Zhang Ying]
There are two purposes to do so:
1. As mentioned above that u-boot-tpl.lds, if share, need to change the file name.

File naming is not a good reason to duplicate a big chunk of code.

Quoted 6 lines

2. Make the functionality "nand_load" to non-static, because it will be called by the external function to get the environment from the nand flash.
Why use this? Because the common nand drivers need malloc the large memory that large than the size of L2 SRAM(256K). There was unable to use common nand drivers in the TPL.

Does making nand_load non-static in the main SPL cause size constrants to be violated? If so, the staticness can be determined via an ifdef (use ifdef to define something like MAYBE_STATIC -- don't ifdef the prototype itself).

-Scott

#4 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

-----Original Message-----
From: Wood Scott-B07421
Sent: Friday, June 14, 2013 5:50 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 163 lines · On 06/13/2013 02:27:44 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, June 13, 2013 6:29 AM
To: Zhang Ying-B40530
Cc: u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061; Zhang Ying-B40530
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 3 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Due to the nand SPL on the board P1022DS has a size limit, it can

not

Quoted 2 lines

be
more than 4K. So, the SPL cannot initialize the DDR with the SPD

code.

Quoted 1 line

This patch introduces TPL to enable a loader stub that runs in the

L2

Quoted 6 lines

SRAM,
after being loaded by the code from the SPL. It initializes the DDR with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the

size

Quoted 25 lines

of L2
SRAM. It initializes the DDR through SPD code, and copys final uboot image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80 +++++++++
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
Quoted 8 lines
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93  

+++++++++++

Quoted 91 lines
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75 +++++++--
 tpl/Makefile                                       |  161
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some

TPLs

README FIT uImage format: · line 3110

Quoted 2 lines
README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now
that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's generalize it into multiple U-Boot phases, each of which has its own autoconf.mk. The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared under

Quoted 8 lines

different ifdefs.
[Zhang Ying]
I know the concept of a separate autoconf.mk for multiple U-Boot phases.
If these symbols are only used in the C files, should do as you say. But most of these symbols were used in the Makefile to contain the Library. The patch "separate autoconf.mk" has not be merged, in this case, they can only declared separately.

Treat the autoconf.mk patch as a dependency. Don't try to hack around its absence.
[Zhang Ying]
According to what you said, the same set of symbols will be declared under different ifdefs.
That's the trouble, "The same set of symbols declared under different ifdefs" will not be effective in the "Makefile", in the current case.

#5 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 191 lines · On 06/14/2013 05:08:49 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Friday, June 14, 2013 5:50 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 14 lines · On 06/13/2013 02:27:44 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, June 13, 2013 6:29 AM
To: Zhang Ying-B40530
Cc: u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061; Zhang Ying-B40530
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 2 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Quoted 9 lines
Quoted 1 line

Due to the nand SPL on the board P1022DS has a size limit, it can

not

Quoted 2 lines

be
more than 4K. So, the SPL cannot initialize the DDR with the SPD

code.

Quoted 1 line

This patch introduces TPL to enable a loader stub that runs in the

L2

Quoted 2 lines

SRAM,
after being loaded by the code from the SPL. It initializes the

DDR

Quoted 7 lines
Quoted 4 lines

with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the

size

Quoted 2 lines

of L2
SRAM. It initializes the DDR through SPD code, and copys final

uboot

Quoted 13 lines
Quoted 13 lines

image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

Quoted 7 lines
Quoted 7 lines
---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80  

+++++++++

Quoted 11 lines
Quoted 11 lines
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93
Quoted 7 lines

+++++++++++

Quoted 6 lines
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75  

+++++++--

Quoted 84 lines
Quoted 84 lines
 tpl/Makefile                                       |  161
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some
Quoted 8 lines

README FIT uImage format: · line 3110

Quoted 3 lines

TPLs

README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now
that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's

generalize

Quoted 1 line

it into multiple U-Boot phases, each of which has its own

autoconf.mk.

Quoted 2 lines

The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared

under

Quoted 8 lines

different ifdefs.
[Zhang Ying]
I know the concept of a separate autoconf.mk for multiple U-Boot phases.
If these symbols are only used in the C files, should do as you say. But most of these symbols were used in the Makefile to contain the Library. The patch "separate autoconf.mk" has not be merged, in this case, they can only declared separately.

Quoted 7 lines

Treat the autoconf.mk patch as a dependency. Don't try to hack around its absence.
[Zhang Ying]
According to what you said, the same set of symbols will be declared under different ifdefs.
That's the trouble, "The same set of symbols declared under different ifdefs" will not be effective in the "Makefile", in the current case.

It *will* be effective in the makefile if there is a separate autoconf.mk for each phase. My point is that a separate autoconf.mk for each phase is a requirement for TPL to be done in a sane way.

-Scott

#6 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

-----Original Message-----
From: Wood Scott-B07421
Sent: Saturday, June 15, 2013 12:37 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 191 lines · On 06/14/2013 05:08:49 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Friday, June 14, 2013 5:50 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 14 lines · On 06/13/2013 02:27:44 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Thursday, June 13, 2013 6:29 AM
To: Zhang Ying-B40530
Cc: u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061; Zhang Ying-B40530
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 2 lines · ying.zhang at freescale.com

From: Ying Zhang <[email protected]>

Quoted 9 lines
Quoted 1 line

Due to the nand SPL on the board P1022DS has a size limit, it can

not

Quoted 2 lines

be
more than 4K. So, the SPL cannot initialize the DDR with the SPD

code.

Quoted 1 line

This patch introduces TPL to enable a loader stub that runs in the

L2

Quoted 2 lines

SRAM,
after being loaded by the code from the SPL. It initializes the

DDR

Quoted 7 lines
Quoted 4 lines

with
the SPD.

The TPL's size is sizeable, the maximum size must not exceed the

size

Quoted 2 lines

of L2
SRAM. It initializes the DDR through SPD code, and copys final

uboot

Quoted 13 lines
Quoted 13 lines

image
to DDR. So there are three stage uboot images:
* spl_boot, 4KB size, pad to 128K byte.
* tpl_boot, 88K size, pad to 128K size. The env variables are copied to L2 SRAM, so that ddr SPD code can get the interleaving mode setting in env. It loads final uboot image from offset
256KB.
* final uboot image, size is variable depends on the functions enabled.

This patch is on top of the patch:
powerpc/p1022ds: boot from SD Card with SPL

Quoted 7 lines
Quoted 7 lines
---
 Makefile                                           |   25 +++-
 README                                             |   55 ++++++-
 arch/powerpc/config.mk                             |    2 +
 arch/powerpc/cpu/mpc85xx/spl_minimal.c             |   16 ++
 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds            |   80  

+++++++++

Quoted 11 lines
Quoted 11 lines
 .../cpu/mpc8xxx/ddr/lc_common_dimm_params.c        |    4 +-
 arch/powerpc/lib/Makefile                          |    2 +
 board/freescale/p1022ds/Makefile                   |    3 +
 board/freescale/p1022ds/spl_minimal.c              |   56 +------
 board/freescale/p1022ds/tlb.c                      |    4 +-
 board/freescale/p1022ds/tpl.c                      |  101
++++++++++++
 common/Makefile                                    |    9 +
 common/cmd_nvedit.c                                |    8 +-
 config.mk                                          |   32 ++++
 doc/README.TPL                                     |   93
Quoted 7 lines

+++++++++++

Quoted 6 lines
 drivers/mtd/nand/Makefile                          |    8 +
 drivers/mtd/nand/fsl_elbc_tpl.c                    |  168
++++++++++++++++++++
 drivers/serial/serial.c                            |    2 +-
 include/bootstage.h                                |    3 +-
 include/configs/P1022DS.h                          |   75  

+++++++--

Quoted 84 lines
Quoted 84 lines
 tpl/Makefile                                       |  161
+++++++++++++++++++
 21 files changed, 824 insertions(+), 83 deletions(-)
 create mode 100644 arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
 create mode 100644 board/freescale/p1022ds/tpl.c
 create mode 100644 doc/README.TPL
 create mode 100644 drivers/mtd/nand/fsl_elbc_tpl.c
 create mode 100644 tpl/Makefile
README +3 -2
index 7add6d4..04f9aa5 100644
@@ -2985,9 +2985,10 @@ FIT uImage format:
 		Set for the SPL on PPC mpc8xxx targets, support for
 		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in SPL binary.
 
-		CONFIG_SPL_COMMON_INIT_DDR
+		CONFIG_COMMON_INIT_DDR
 		Set for common ddr init with serial presence detect in
-		SPL binary.
+		SPL binary or TPL binary.
+
 		CONFIG_SYS_NAND_5_ADDR_CYCLE,
 CONFIG_SYS_NAND_PAGE_COUNT,
 		CONFIG_SYS_NAND_PAGE_SIZE, CONFIG_SYS_NAND_OOBSIZE,

CONFIG_SYS_NAND_BLOCK_SIZE,
CONFIG_SYS_NAND_BAD_BLOCK_POS,

README +0 -0
@@ -3058,6 +3059,56 @@ FIT uImage format:
 		option to re-enable it. This will affect the output of

the

README +11 -0
 		bootm command when booting a FIT image.
 
+- TPL framework
+		CONFIG_TPL
+		Enable building of TPL globally.
+
+		CONFIG_TPL_LDSCRIPT
+		LDSCRIPT for linking the TPL binary.
+
+		CONFIG_TPL_MAX_SIZE
+		Maximum size of the TPL image (text, data, rodata, and
+		linker lists sections), BSS excluded.
+		When defined, the linker checks that the actual size

does

README +29 -0
+		not exceed it.
+
+		CONFIG_SPL_TEXT_BASE
+		TEXT_BASE for linking the TPL binary.
+
+		CONFIG_TPL_LIBCOMMON_SUPPORT
+		Support for common/libcommon.o in TPL binary
+
+		CONFIG_TPL_LIBDISK_SUPPORT
+		Support for disk/libdisk.o in TPL binary
+
+		CONFIG_TPL_I2C_SUPPORT
+		Support for drivers/i2c/libi2c.o in TPL binary
+
+		CONFIG_TPL_MPC8XXX_INIT_DDR_SUPPORT
+		Set for the TPL on PPC mpc8xxx targets, support for
+		arch/powerpc/cpu/mpc8xxx/ddr/libddr.o in TPL binary.
+
+		CONFIG_TPL_SERIAL_SUPPORT
+		Support for drivers/serial/libserial.o in TPL binary
+
+		CONFIG_TPL_LIBGENERIC_SUPPORT
+		Support for lib/libgeneric.o in TPL binary
+
+		CONFIG_TPL_ENV_SUPPORT
+		Support for the environment operating in TPL binary
+
+		CONFIG_TPL_PAD_TO
+		Image offset to which the TPL should be padded before

appending

README +2 -0
+		the TPL payload. By default, this is defined as
+		CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is

undefined.

README +1 -0
+		CONFIG_TPL_PAD_TO must be either 0, meaning to append

the TPL

README +4 -0
+		payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+		CONFIG_TPL_TARGET
+		Final target image containing SPL and payload.  Some
Quoted 8 lines

README FIT uImage format: · line 3110

Quoted 3 lines

TPLs

README +2 -0
+		use an arch-specific makefile fragment instead, for
+		example if more than one image needs to be produced.

Let's please not just duplicate all the SPL stuff with s/SPL/TPL/. Now
that the concept of a separate autoconf.mk is apparently less controversial than when I suggested it a while back, let's

generalize

Quoted 1 line

it into multiple U-Boot phases, each of which has its own

autoconf.mk.

Quoted 2 lines

The same set of symbols would be used to build any phase (ideally including the main phase) -- the symbols would just be declared

under

Quoted 8 lines

different ifdefs.
[Zhang Ying]
I know the concept of a separate autoconf.mk for multiple U-Boot phases.
If these symbols are only used in the C files, should do as you say. But most of these symbols were used in the Makefile to contain the Library. The patch "separate autoconf.mk" has not be merged, in this case, they can only declared separately.

Quoted 7 lines

Treat the autoconf.mk patch as a dependency. Don't try to hack around its absence.
[Zhang Ying]
According to what you said, the same set of symbols will be declared under different ifdefs.
That's the trouble, "The same set of symbols declared under different ifdefs" will not be effective in the "Makefile", in the current case.

It *will* be effective in the makefile if there is a separate autoconf.mk for each phase. My point is that a separate autoconf.mk for each phase is a requirement for TPL to be done in a sane way. [Zhang Ying]
So, could you tell me where I do wrong? Please let me know the specific. Thanks.

#7 lore raw

PATCH 1/1 powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 34 lines · On 06/17/2013 02:56:45 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Saturday, June 15, 2013 12:37 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 11 lines · On 06/14/2013 05:08:49 AM, Zhang Ying-B40530 wrote:

-----Original Message-----
From: Wood Scott-B07421
Sent: Friday, June 14, 2013 5:50 AM
To: Zhang Ying-B40530
Cc: Wood Scott-B07421; u-boot at lists.denx.de; afleming at gmail.com; Xie Xiaobo-R63061
Subject: Re: [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL

Quoted 1 line

Treat the autoconf.mk patch as a dependency. Don't try to hack

around

Quoted 5 lines

its absence.
[Zhang Ying]
According to what you said, the same set of symbols will be declared under different ifdefs.
That's the trouble, "The same set of symbols declared under

different

Quoted 1 line

ifdefs" will not be effective in the "Makefile", in the current

case.

Quoted 7 lines

It *will* be effective in the makefile if there is a separate autoconf.mk for each phase. My point is that a separate autoconf.mk for each phase is a requirement for TPL to be done in a sane way. [Zhang Ying]
So, could you tell me where I do wrong? Please let me know the specific.
Thanks.

Do not create a whole bunch of CONFIG_TPL_... definitions. Base your patches on top of the patch that creates a separate autoconf.mk.

-Scott