[U-Boot] SPL framework re-design

Daniel Schwierzeck
2011-06-25T16:11:41Z

Dear Wolfgang,

On 06/25/2011 02:10 PM, Wolfgang Denk wrote:
> Dear Aneesh V,
>
> In message<4E00799A.5040302@ti.com> you wrote:
>>
>>> 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
>
> This patch seems strangely white-space corrupted.
>
>> 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
>
> The mmc_spl/ is suppoed to be moved into spl/, isn't it?
>
>> $(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}
>
> Dito here for onenand_ipl/ ?
>
>> @rm -f
>> $(obj)mmc_spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin}
>
> ...also line-wrapped.
>
>> + @rm -f
>> $(obj)spl/{u-boot.lds,u-boot-spl,u-boot-spl.map,u-boot-spl.bin,u-boot-mmc-spl.bin}
>
> Make this:
>
> @rm -f $(obj)spl/u-boot{.lds,-spl,-spl.map,-spl.bin,-mmc-spl.bin}
>
> instead.
>
>> @rm -f $(ONENAND_BIN)
>> @rm -f $(obj)onenand_ipl/u-boot.lds
>
> Goes away?
>
>> --- /dev/null
>> +++ b/spl/Makefile
>> @@ -0,0 +1,94 @@
>> +#
>> +# (C) Copyright 2011 Daniel Schwierzeck, daniel.schwierzeck at googlemail.com.
>
> Really???

That is only because Aneesh used my experimental Makefile that I
published for discussion and to show one possible solution for
the top-down design.

>
>> +# 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
>
> As Mike mentioned, we can eventually directly include the OBJSs here
> and omit the building of libraries?

What about files which need to recompiled with a different configuration?
For example I have a use case (MIPS based) that reuses parts of the CPU
and board lowlevel init code. This SPL runs in a SoC internal SRAM,
initializes the memory controller, needs no relocation, have a different
stack offset and copies the real U-Boot from SPI flash to RAM.
At least I have to recompile start.S without relocate_code() and
a different stack pointer initialization.

>
>> +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)
>
> We should probably use /$(BOARDDIR)? here instead of /$(BOARD)/ to
> allow for vendor directories (where "BOARDDIR = $(VENDOR)/$(BOARD)").
>
>> +ALL = $(obj)u-boot-spl.bin
>> +
>> +all: $(ALL)
>
> Do we need ALL then at all?

actually not. The original spl/Makefile is only a strongly simplified
version of the top-level Makefile.

>
> ...
>> 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.
>
> Really???
>
>> +$(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 $@
>
> Hm... can we try to do without the symlinks?

that is possible with if you play a little with the src and obj
variables in config.mk

Best regards,
Daniel