From: Matthew McClintock <m...@freescale.com>

This patch allows some boards do define CONFIG_BOOTSTRAP to let them
build a MPL or middle program loader to setup the board before booting
to the full u-boot build. The advantage is that we are using the same
build system and linker scripts that would be used in a normal u-boot
build.

This is used on powerpc/85xx parts that only have 256kB of cache
and also need to perform DDR SPD. So, the nand_spl will load the
MPL to L2 SRAM and there DDR will be configured. Afterwards the
MPL uses the CONFIG_BOOTCOMMAND environment variable to boot to
the appropriate media. This also works with SD and SPI via the
on chip rom but instead it goes from on-chip-rom to MPL to full
version of u-boot.

Depends on previous icache/dcache command changes and various
build fixes for add cases that occur when trying to build an
extremely minimal image

Signed-off-by: Matthew McClintock <m...@freescale.com>
---
 Makefile |   38 +++++++++++++++++++++++++++++++++++++-
 mkconfig |    1 +
 2 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 0400930..7a9cae7 100644
--- a/Makefile
+++ b/Makefile
@@ -317,6 +317,16 @@ ifeq ($(CONFIG_NAND_U_BOOT),y)
 ALL += $(obj)u-boot-nand.bin
 endif
 
+ifndef CONFIG_IN_BOOTSTRAP
+ifeq ($(CONFIG_SPIFLASH), y)
+ALL += $(obj)u-boot-spi.bin
+endif
+
+ifeq ($(CONFIG_SDCARD), y)
+ALL += $(obj)u-boot-sd.bin
+endif
+endif
+
 ifeq ($(CONFIG_ONENAND_U_BOOT),y)
 ALL += $(obj)u-boot-onenand.bin
 ONENAND_BIN ?= $(obj)onenand_ipl/onenand-ipl-2k.bin
@@ -404,8 +414,16 @@ $(obj)u-boot.lds: $(LDSCRIPT)
 nand_spl:      $(TIMESTAMP_FILE) $(VERSION_FILE) depend
                $(MAKE) -C nand_spl/board/$(BOARDDIR) all
 
+NAND_SPL_OBJS-y += $(obj)nand_spl/u-boot-spl-16k.bin
+NAND_SPL_OBJS-$(CONFIG_BOOTSTRAP) += $(obj)u-boot-bootstrap.bin
+NAND_SPL_OBJS-y += $(obj)u-boot.bin
+
+ifeq ($(CONFIG_BOOTSTRAP),y)
+$(obj)u-boot-nand.bin: nand_spl $(obj)u-boot-bootstrap.bin $(obj)u-boot.bin
+else
 $(obj)u-boot-nand.bin: nand_spl $(obj)u-boot.bin
-               cat $(obj)nand_spl/u-boot-spl-16k.bin $(obj)u-boot.bin > 
$(obj)u-boot-nand.bin
+endif
+               cat $(NAND_SPL_OBJS-y) > $(obj)u-boot-nand.bin
 
 onenand_ipl:   $(TIMESTAMP_FILE) $(VERSION_FILE) $(obj)include/autoconf.mk
                $(MAKE) -C onenand_ipl/board/$(BOARDDIR) all
@@ -413,6 +431,23 @@ onenand_ipl:       $(TIMESTAMP_FILE) $(VERSION_FILE) 
$(obj)include/autoconf.mk
 $(obj)u-boot-onenand.bin:      onenand_ipl $(obj)u-boot.bin
                cat $(ONENAND_BIN) $(obj)u-boot.bin > $(obj)u-boot-onenand.bin
 
+ifdef CONFIG_BOOTSTRAP
+$(obj)u-boot-spi.bin:          $(obj)u-boot.bin $(obj)u-boot-bootstrap.bin
+               cat $(obj)u-boot-bootstrap.bin $(obj)u-boot.bin > 
$(obj)u-boot-spi.bin
+$(obj)u-boot-sd.bin:           $(obj)u-boot.bin $(obj)u-boot-bootstrap.bin
+               cat $(obj)u-boot-bootstrap.bin $(obj)u-boot.bin > 
$(obj)u-boot-sd.bin
+else
+$(obj)u-boot-spi.bin:          $(obj)u-boot.bin
+               ln -s u-boot.bin u-boot-spi.bin
+$(obj)u-boot-sd.bin:           $(obj)u-boot.bin
+               ln -s u-boot.bin u-boot-sd.bin
+endif
+
+$(obj)u-boot-bootstrap.bin:
+               rm -rf $(BUILD_DIR)bootstrap
+               $(MAKE) $(CONFIG_BOARD_NAME) O=bootstrap/ 
EXTRA_OPTS=IN_BOOTSTRAP
+               cp $(BUILD_DIR)bootstrap/u-boot.bin u-boot-bootstrap.bin
+
 $(VERSION_FILE):
                @( localvers='$(shell $(TOPDIR)/tools/setlocalversion 
$(TOPDIR))' ; \
                   printf '#define PLAIN_VERSION "%s%s"\n' \
@@ -1130,6 +1165,7 @@ clean:
                \( -name 'core' -o -name '*.bak' -o -name '*~' \
                -o -name '*.o'  -o -name '*.a' -o -name '*.exe' \) -print \
                | xargs rm -f
+       @rm -fr $(BUILD_DIR)bootstrap/
 
 clobber:       clean
        @find $(OBJTREE) -type f \( -name '*.depend' \
diff --git a/mkconfig b/mkconfig
index e72ec3d..74294ec 100755
--- a/mkconfig
+++ b/mkconfig
@@ -159,6 +159,7 @@ for i in ${TARGETS} ; do
 done
 
 cat << EOF >> config.h
+#define CONFIG_BOARD_NAME $BOARD_NAME
 #define CONFIG_BOARDDIR board/$BOARDDIR
 #include <config_cmd_defaults.h>
 #include <config_defaults.h>
-- 
1.7.5


_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to