[U-Boot] SPL framework re-design

Aneesh V aneesh at ti.com
Tue Jun 21 12:59:38 CEST 2011


Dear Wolfgang,

On Friday 17 June 2011 10:18 PM, Aneesh V wrote:
> 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.

Here is an updated version of my prototype implementation with fixes
for some issues pointed out by Scott. Please let me know your views
about this.

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

diff --git a/Makefile b/Makefile
index 8540e39..0321634 100644
--- a/Makefile
+++ b/Makefile
@@ -316,6 +316,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)
@@ -428,6 +429,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):
@@ -1142,6 +1146,7 @@ clean:
  	@rm -f $(obj)spl/{u-boot-spl-generated.lds,u-boot-spl,u-boot-spl.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)
diff --git a/include/configs/omap4_sdp4430.h 
b/include/configs/omap4_sdp4430.h
index c424951..c9adc3c 100644
--- a/include/configs/omap4_sdp4430.h
+++ b/include/configs/omap4_sdp4430.h
@@ -257,4 +257,5 @@
  /* 1MB into the SDRAM to allow for SPL's bss at the beginning of SDRAM */
  #define CONFIG_SYS_TEXT_BASE		0x80100000

+#define CONFIG_SYS_SPL_MMC_SUPPORT
  #endif /* __CONFIG_H */
diff --git a/spl/Makefile b/spl/Makefile
new file mode 100644
index 0000000..9e3a5b1
--- /dev/null
+++ b/spl/Makefile
@@ -0,0 +1,94 @@
+#
+# (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
+LIBS-$(CONFIG_SYS_SPL_FAT_SUPPORT) += fat/libfat.o
+LIBS-$(CONFIG_SYS_SPL_NAND_SUPPORT) += nand/libnand.o
+LIBS-$(CONFIG_SYS_SPL_ONENAND_SUPPORT) += onenand/libonenand.o
+
+LIBS-y += $(shell if [ -f $(ARCH)/Makefile ]; then echo \
+	"$(ARCH)/lib$(ARCH).o"; fi)
+LIBS-y += $(shell if [ -f $(ARCH)/$(CPU)/Makefile ]; then echo \
+	"$(ARCH)/$(CPU)/lib$(CPU).o"; fi)
+LIBS-y += $(shell if [ -f $(ARCH)/$(CPU)/$(SOC)/Makefile ]; then echo \
+	"$(ARCH)/$(CPU)/$(SOC)/lib$(SOC).o"; fi)
+LIBS-y += $(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