[U-Boot] SPL framework re-design

Aneesh V aneesh at ti.com
Fri Jun 17 18:48:57 CEST 2011


Dear Wolfgang,

Here is a crude implementation of the top-down approach you had been
suggesting (or my interpretation of it). This is not complete yet and
serves only as a material for further discussions on this topic.

This work borrows from the work of Daniel Schwierzeck
staged here:
https://github.com/danielschwierzeck/u-boot-spl/commits/spl

However the approach is quite different from that of Daniel's.

Appreciate everybody's feedback about this approach.

---
  Makefile                        |    7 +++
  include/configs/omap4_sdp4430.h |    1 +
  spl/Makefile                    |   95 
+++++++++++++++++++++++++++++++++++++++
  spl/mmc/Makefile                |   55 ++++++++++++++++++++++
  4 files changed, 158 insertions(+), 0 deletions(-)
  create mode 100644 spl/Makefile
  create mode 100644 spl/mmc/Makefile

diff --git a/Makefile b/Makefile
index dcf5d93..4a2cb58 100644
--- a/Makefile
+++ b/Makefile
@@ -311,6 +311,7 @@ BOARD_SIZE_CHECK =
  endif

  # Always append ALL so that arch config.mk's can add custom ones
+ALL += spl
  ALL += $(obj)u-boot.srec $(obj)u-boot.bin $(obj)System.map

  ifeq ($(CONFIG_NAND_U_BOOT),y)
@@ -326,6 +327,7 @@ ifeq ($(CONFIG_MMC_U_BOOT),y)
  ALL += $(obj)mmc_spl/u-boot-mmc-spl.bin
  endif

+
  all:		$(ALL)

  $(obj)u-boot.hex:	$(obj)u-boot
@@ -420,6 +422,9 @@ $(obj)u-boot-onenand.bin:	onenand_ipl $(obj)u-boot.bin
  mmc_spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
  		$(MAKE) -C mmc_spl/board/$(BOARDDIR) all

+spl:	$(TIMESTAMP_FILE) $(VERSION_FILE) depend
+	$(MAKE) -C spl/ all
+
  $(obj)mmc_spl/u-boot-mmc-spl.bin:	mmc_spl

  $(VERSION_FILE):
@@ -1133,6 +1138,7 @@ clean:
  	@rm -f $(obj)nand_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,System.map}
  	@rm -f $(obj)onenand_ipl/onenand-{ipl,ipl.bin,ipl.map}
  	@rm -f 
$(obj)mmc_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin}
+	@rm -f 
$(obj)spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin}
  	@rm -f $(ONENAND_BIN)
  	@rm -f $(obj)onenand_ipl/u-boot.lds
  	@rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
@@ -1158,6 +1164,7 @@ clobber:	clean
  	@[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l 
-print | xargs rm -f
  	@[ ! -d $(obj)onenand_ipl ] || find $(obj)onenand_ipl -name "*" -type 
l -print | xargs rm -f
  	@[ ! -d $(obj)mmc_spl ] || find $(obj)mmc_spl -name "*" -type l 
-print | xargs rm -f
+	@[ ! -d $(obj)spl ] || find $(obj)mmc_spl -name "*" -type l -print | 
xargs rm -f

  ifeq ($(OBJTREE),$(SRCTREE))
  mrproper \
diff --git a/include/configs/omap4_sdp4430.h 
b/include/configs/omap4_sdp4430.h
index 68ffa87..3122d1c 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -243,4 +243,5 @@
  #define CONFIG_SYS_PL310_BASE	0x48242000
  #endif

+#define CONFIG_SYS_SPL_MMC_SUPPORT
  #endif /* __CONFIG_H */
diff --git a/spl/Makefile b/spl/Makefile
new file mode 100644
index 0000000..8dc6e88
--- /dev/null
+++ b/spl/Makefile
@@ -0,0 +1,95 @@
+#
+# (C) Copyright 2011 Daniel Schwierzeck, daniel.schwierzeck at googlemail.com.
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for 
details.
+#
+
+include $(TOPDIR)/config.mk
+LIBS-$(CONFIG_SYS_SPL_MMC_SUPPORT) = mmc/libmmc.o
+# The following commented for the time-being, but will be enabled in
+# real implementation
+LIBS-$(CONFIG_SYS_SPL_FAT_SUPPORT) += fat/libfat.o
+LIBS-$(CONFIG_SYS_SPL_NAND_SUPPORT) += mmc/libnand.o
+LIBS-$(CONFIG_SYS_SPL_ONENAND_SUPPORT) += mmc/libonenand.o
+LIBS += $(shell if [ -f $(ARCH)/Makefile ]; then echo \
+	"$(ARCH)/lib$(ARCH).o"; fi)
+LIBS += $(shell if [ -f $(ARCH)/$(CPU)/Makefile ]; then echo \
+	"$(ARCH)/$(CPU)/lib$(CPU).o"; fi)
+LIBS += $(shell if [ -f $(ARCH)/$(CPU)/$(SOC)/Makefile ]; then echo \
+	"$(ARCH)/$(CPU)/$(SOC)/lib$(SOC).o"; fi)
+LIBS += $(shell if [ -f $(ARCH)/$(CPU)/$(SOC)/$(BOARD)/Makefile ]; then 
echo \
+	"$(ARCH)/$(CPU)/$(SOC)/$(BOARD)/lib$(BOARD).o"; fi)
+
+LIBS-y := $(addprefix $(obj),$(sort $(LIBS-y)))
+
+__LIBS := $(subst $(obj),,$(LIBS-y))
+
+ifndef SPL_LDSCRIPT
+	ifdef CONFIG_SYS_SPL_LDSCRIPT
+		# need to strip off double quotes
+		SPL_LDSCRIPT := $(subst ",,$(CONFIG_SYS_SPL_LDSCRIPT))
+	endif
+endif
+
+ifndef SPL_LDSCRIPT
+	ifeq ($(wildcard $(SPL_LDSCRIPT)),)
+		SPL_LDSCRIPT := 
$(TOPDIR)/spl/$(ARCH)/$(CPU)/$(SOC)/$(BOARDDIR)/u-boot-spl.lds
+	endif
+	ifeq ($(wildcard $(SPL_LDSCRIPT)),)
+		SPL_LDSCRIPT := $(TOPDIR)/spl/$(ARCH)/$(CPU)/$(SOC)/u-boot-spl.lds
+	endif
+	ifeq ($(wildcard $(SPL_LDSCRIPT)),)
+		SPL_LDSCRIPT := $(TOPDIR)/spl/$(ARCH)/$(CPU)/u-boot-spl.lds
+	endif
+	ifeq ($(wildcard $(SPL_LDSCRIPT)),)
+$(error could not find linker script)
+	endif
+endif
+LNDIR		:= $(OBJTREE)/spl
+
+# Special flags for CPP when processing the linker script.
+# Pass the version down so we can handle backwards compatibility
+# on the fly.
+LDPPFLAGS += \
+	-include $(TOPDIR)/include/u-boot/u-boot.lds.h \
+	$(shell $(LD) --version | \
+	  sed -ne 's/GNU ld version 
\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
+
+ALL	= $(obj)u-boot-spl.bin
+
+all:	$(ALL)
+
+$(obj)u-boot-spl.bin:	$(obj)u-boot-spl
+	$(OBJCOPY) $(OBJCFLAGS) -O binary $< $@
+
+GEN_UBOOT = \
+	UNDEF_SYM=`$(OBJDUMP) -x $(LIBS-y) | \
+	sed  -n -e 's/.*\($(SYM_PREFIX)__u_boot_cmd_.*\)/-u\1/p'|sort|uniq`;\
+	cd $(LNDIR) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) $$UNDEF_SYM \
+		--start-group $(__LIBS) --end-group \
+		-Map u-boot-spl.map -o u-boot-spl
+
+$(obj)u-boot-spl: 	depend $(LIBS-y) $(SPL_LDSCRIPT) $(obj)u-boot-spl.lds
+	$(GEN_UBOOT)
+
+$(OBJS):	depend
+		$(MAKE) -C $(CPUDIR) $(if $(REMOTE_BUILD),$@,$(notdir $@))
+
+$(LIBS-y):	depend
+		$(MAKE) -C $(dir $(subst $(obj),,$@)) all
+
+$(SPL_LDSCRIPT): depend
+	$(MAKE) -C $(dir $@) $(notdir $@)
+
+$(obj)u-boot-spl.lds: $(SPL_LDSCRIPT)
+	$(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - < $< > $@
+
+depend:	$(obj).depend
+.PHONY: depend
+
+clean:
+	# TODO: implement clean to support in-tree builds
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
diff --git a/spl/mmc/Makefile b/spl/mmc/Makefile
new file mode 100644
index 0000000..b4f7efd
--- /dev/null
+++ b/spl/mmc/Makefile
@@ -0,0 +1,55 @@
+#
+# (C) Copyright 2000-2003
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libmmc.o
+
+$(obj)mmc.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/drivers/mmc/mmc.c $@
+
+$(obj)omap_hsmmc.c:
+	@rm -f $@
+	@ln -s $(TOPDIR)/drivers/mmc/omap_hsmmc.c $@
+
+
+COBJS			:= mmc.o
+COBJS			+= omap_hsmmc.o
+
+SRCS	:= $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
-- 
1.7.0.4



More information about the U-Boot mailing list