[U-Boot,3/4] nand_spl/spiboot/sdboot: Add ability to have smaller middle loader

Message ID 1307043300-11253-3-git-send-email-msm@freescale.com
State Rejected, archived
Delegated to: Andy Fleming
Headers show

Commit Message

Matthew McClintock June 2, 2011, 7:34 p.m.
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

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 <msm@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
+ifeq ($(CONFIG_SPIFLASH), y)
+ALL += $(obj)u-boot-spi.bin
+ifeq ($(CONFIG_SDCARD), y)
+ALL += $(obj)u-boot-sd.bin
 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
+$(obj)u-boot-nand.bin:	nand_spl $(obj)u-boot-bootstrap.bin $(obj)u-boot.bin
 $(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
+		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
+$(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
+$(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
+		rm -rf $(BUILD_DIR)bootstrap
+		cp $(BUILD_DIR)bootstrap/u-boot.bin u-boot-bootstrap.bin
 		@( 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
 cat << EOF >> config.h
 #include <config_cmd_defaults.h>
 #include <config_defaults.h>