From: Ying Zhang <b40...@freescale.com>
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
Signed-off-by: Ying Zhang <b40...@freescale.com>
---
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
diff --git a/Makefile b/Makefile
index ef154aa..65849d1 100644
--- a/Makefile
+++ b/Makefile
@@ -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
diff --git a/README b/README
index 7add6d4..04f9aa5 100644
--- a/README
+++ b/README
@@ -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,
@@ -3058,6 +3059,56 @@ FIT uImage format:
option to re-enable it. This will affect the output of
the
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
+ 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
+ the TPL payload. By default, this is defined as
+ CONFIG_TPL_MAX_SIZE, or 0 if CONFIG_TPL_MAX_SIZE is
undefined.
+ CONFIG_TPL_PAD_TO must be either 0, meaning to append
the TPL
+ payload without any padding, or >= CONFIG_TPL_MAX_SIZE.
+
+ CONFIG_TPL_TARGET
+ Final target image containing SPL and payload. Some
TPLs
+ use an arch-specific makefile fragment instead, for
+ example if more than one image needs to be produced.