From: Scott Wood <scottwood@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL
Date: Wed, 12 Jun 2013 17:28:33 -0500 [thread overview]
Message-ID: <1371076113.18413.55@snotra> (raw)
In-Reply-To: <1370757283-20276-1-git-send-email-ying.zhang@freescale.com> (from ying.zhang@freescale.com on Sun Jun 9 00:54:43 2013)
On 06/09/2013 12:54:43 AM, ying.zhang at freescale.com wrote:
> From: Ying Zhang <b40530@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 <b40530@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.
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.
> diff --git a/arch/powerpc/cpu/mpc85xx/spl_minimal.c
> b/arch/powerpc/cpu/mpc85xx/spl_minimal.c
> index c6b9cd0..a2d9417 100644
> --- a/arch/powerpc/cpu/mpc85xx/spl_minimal.c
> +++ b/arch/powerpc/cpu/mpc85xx/spl_minimal.c
> @@ -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;
Please do not commingle TPL infrastructure with 85xx or p1022ds
implementation details. They should be separate patches.
> diff --git a/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
> b/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
> new file mode 100644
> index 0000000..344c325
> --- /dev/null
> +++ b/arch/powerpc/cpu/mpc85xx/u-boot-tpl.lds
What is different about this compared to every other 85xx linker script
that justifies a separate copy?
> +Estimating stack usage
> +----------------------
> +
> +With gcc 4.6 (and later) and the use of GNU cflow it is possible to
> estimate
> +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.
> +
> +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
> +
> +cflow will spit out a number of warnings as it does not parse
> +the config files and picks functions based on #ifdef. Parsing the
> '.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?
> diff --git a/drivers/mtd/nand/fsl_elbc_tpl.c
> b/drivers/mtd/nand/fsl_elbc_tpl.c
> new file mode 100644
> index 0000000..09868c4
> --- /dev/null
> +++ b/drivers/mtd/nand/fsl_elbc_tpl.c
...and here you duplicated an entire driver!
NACK
-Scott
next prev parent reply other threads:[~2013-06-12 22:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-09 5:54 [U-Boot] [PATCH] powerpc/p1022ds: nand: introduce the TPL based on the SPL ying.zhang at freescale.com
2013-06-12 22:28 ` Scott Wood [this message]
2013-06-13 7:27 ` Zhang Ying-B40530
2013-06-13 21:49 ` Scott Wood
2013-06-14 10:08 ` Zhang Ying-B40530
2013-06-14 16:37 ` Scott Wood
2013-06-17 7:56 ` Zhang Ying-B40530
2013-06-18 0:11 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371076113.18413.55@snotra \
--to=scottwood@freescale.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.