[U-Boot] [PATCH] igep00x0: Falcon mode

Ladislav Michl ladis at linux-mips.org
Fri Jan 15 14:12:54 CET 2016


On Thu, Jan 14, 2016 at 12:10:25PM -0500, Tom Rini wrote:
> On Thu, Jan 14, 2016 at 01:44:20AM +0100, Ladislav Michl wrote:
> 
> > Implement spl_start_uboot to let Falcon mode work. Also as board comes
> > either with 256 or 512MB of memory, fixup fdt before jumping to kernel.
> > ATAG support for doing the same is left as an excercise for readers
> > loving legacy stuff.
> > 
> > Signed-off-by: Ladislav Michl <ladis at linux-mips.org>
> 
> So, I want to hear more about how you're using Falcon mode here.
> Usually memory size is corrected as part of the spl export step.  Or are
> you using the raw fdt coming from the kernel build?

Yes, I'm using raw ftd from kernel build. Other posibility is doing some
scripting with spl export step and then storing fdt into UBI volume. That
would bring in also advantage of taking bootargs into account. However I
have prepared whole UBI image with all UBI volumes and then I'm using
something like that:
flash_erase /dev/mtd0 0 0
writeloader -i MLO -o /dev/mtd0
ubiformat /dev/mtd1 -f root.ubi

So, system is booted with initramfs using SD card and NAND is reflashed with
new content - ftd manipulation would be done from Linux then.

Other possibility is to find a way, how to transfer large file into NAND
UBI aware way (without destroying erase counters) and do the same using
U-Boot scripting. I didn't look into this way (yet). Proposed patch is
the easiest way to fix that isue (I need to do it on thousands of boards,
so it has to be automated).

Also note, that if you are going to use falcon mode from FAT on SD card
you simply cannot move that SD card between boards, as you do not know
amount of memory installed.

Of course, I do not refuse to do anything better to solve this problem :)

As a side note, this solution brings in some more code (libfdt) into SPL,
so I'm playing with -flto and -fwole-program a bit. Just in case anyone
wants continue (for ARM only and incomplete):

diff --git a/Kbuild b/Kbuild
index e2e3b29..349ecce 100644
--- a/Kbuild
+++ b/Kbuild
@@ -30,6 +30,9 @@ define filechk_offsets
 	 echo "#endif" )
 endef
 
+CFLAGS_REMOVE_asm-offsets.o = -flto
+CFLAGS_REMOVE_generic-asm-offsets.o = -flto
+
 #####
 # 1) Generate generic-asm-offsets.h
 
diff --git a/Makefile b/Makefile
index aa19cc6..64062a2 100644
--- a/Makefile
+++ b/Makefile
@@ -331,12 +331,7 @@ include scripts/Kbuild.include
 # Make variables (CC, etc...)
 
 AS		= $(CROSS_COMPILE)as
-# Always use GNU ld
-ifneq ($(shell $(CROSS_COMPILE)ld.bfd -v 2> /dev/null),)
-LD		= $(CROSS_COMPILE)ld.bfd
-else
-LD		= $(CROSS_COMPILE)ld
-endif
+LD		= $(CROSS_COMPILE)gcc
 CC		= $(CROSS_COMPILE)gcc
 CPP		= $(CC) -E
 AR		= $(CROSS_COMPILE)ar
@@ -786,7 +781,7 @@ endif
 
 LDFLAGS_u-boot += $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SYS_TEXT_BASE),)
-LDFLAGS_u-boot += -Ttext $(CONFIG_SYS_TEXT_BASE)
+LDFLAGS_u-boot += -Wl,-Ttext,$(CONFIG_SYS_TEXT_BASE)
 endif
 
 # Normally we fill empty space with 0xff
@@ -1178,9 +1173,9 @@ u-boot.elf: u-boot.bin
 # May be overridden by arch/$(ARCH)/config.mk
 quiet_cmd_u-boot__ ?= LD      $@
       cmd_u-boot__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_u-boot) -o $@ \
-      -T u-boot.lds $(u-boot-init)                             \
-      --start-group $(u-boot-main) --end-group                 \
-      $(PLATFORM_LIBS) -Map u-boot.map
+      -Wl,-T,u-boot.lds $(u-boot-init)                             \
+      -Wl,--start-group $(u-boot-main) -Wl,--end-group                 \
+      $(PLATFORM_LIBS) -Wl,-Map,u-boot.map
 
 quiet_cmd_smap = GEN     common/system_map.o
 cmd_smap = \
diff --git a/arch/arm/config.mk b/arch/arm/config.mk
index 0550225..09fe270 100644
--- a/arch/arm/config.mk
+++ b/arch/arm/config.mk
@@ -13,7 +13,7 @@ CONFIG_STANDALONE_LOAD_ADDR = 0xc100000
 endif
 endif
 
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections \
 		     -fno-common -ffixed-r9
 PLATFORM_RELFLAGS += $(call cc-option, -msoft-float) \
@@ -79,7 +79,7 @@ PLATFORM_LIBS := arch/arm/lib/eabi_compat.o \
 endif
 
 # needed for relocation
-LDFLAGS_u-boot += -pie
+LDFLAGS_u-boot += -Wl,-pie
 
 #
 # FIXME: binutils versions < 2.22 have a bug in the assembler where
diff --git a/config.mk b/config.mk
index b77d589..7c4892c 100644
--- a/config.mk
+++ b/config.mk
@@ -74,10 +74,10 @@ endif
 RELFLAGS := $(PLATFORM_RELFLAGS)
 
 PLATFORM_CPPFLAGS += $(RELFLAGS)
-PLATFORM_CPPFLAGS += -pipe
+PLATFORM_CPPFLAGS += -pipe -flto
 
-LDFLAGS += $(PLATFORM_LDFLAGS)
-LDFLAGS_FINAL += -Bstatic
+LDFLAGS += $(PLATFORM_LDFLAGS) -Wl,--build-id=none -nostdlib -flto
+LDFLAGS_FINAL += -Wl,-Bstatic -Wl,-allow-multiple-definition -fwhole-program
 
 export PLATFORM_CPPFLAGS
 export RELFLAGS
diff --git a/examples/standalone/Makefile b/examples/standalone/Makefile
index 5a6ae00..578cac2 100644
--- a/examples/standalone/Makefile
+++ b/examples/standalone/Makefile
@@ -60,7 +60,8 @@ $(LIB):	$(LIBOBJS) FORCE
 	$(call if_changed,link_lib)
 
 quiet_cmd_link_elf = LD      $@
-      cmd_link_elf = $(LD) $(LDFLAGS) -g -Ttext $(CONFIG_STANDALONE_LOAD_ADDR) \
+      cmd_link_elf = $(LD) $(LDFLAGS) -g \
+		     -Wl,-Ttext,$(CONFIG_STANDALONE_LOAD_ADDR) \
 		     -o $@ -e $(SYM_PREFIX)$(@F) $< $(LIB) $(PLATFORM_LIBGCC)
 
 $(ELF): $(obj)/%: $(obj)/%.o $(LIB) FORCE
diff --git a/scripts/Makefile.spl b/scripts/Makefile.spl
index 96f414a..ceac958 100644
--- a/scripts/Makefile.spl
+++ b/scripts/Makefile.spl
@@ -40,7 +40,7 @@ include $(srctree)/arch/$(ARCH)/Makefile
 
 # Enable garbage collection of un-used sections for SPL
 KBUILD_CFLAGS += -ffunction-sections -fdata-sections
-LDFLAGS_FINAL += --gc-sections
+LDFLAGS_FINAL += -Wl,--gc-sections
 
 # FIX ME
 cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
@@ -216,9 +216,9 @@ OBJCOPYFLAGS_$(SPL_BIN).bin = $(SPL_OBJCFLAGS) -O binary
 $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN) FORCE
 	$(call if_changed,objcopy)
 
-LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
+LDFLAGS_$(SPL_BIN) += -Wl,-T,u-boot-spl.lds $(LDFLAGS_FINAL)
 ifneq ($(CONFIG_SPL_TEXT_BASE),)
-LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_SPL_TEXT_BASE)
+LDFLAGS_$(SPL_BIN) += -Wl,-Ttext,$(CONFIG_SPL_TEXT_BASE)
 endif
 
 ifdef CONFIG_ARCH_SOCFPGA
@@ -236,9 +236,9 @@ endif
 
 quiet_cmd_u-boot-spl = LD      $@
       cmd_u-boot-spl = (cd $(obj) && $(LD) $(LDFLAGS) $(LDFLAGS_$(@F)) \
-		       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
-		       $(patsubst $(obj)/%,%,$(u-boot-spl-main)) --end-group \
-		       $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
+		       $(patsubst $(obj)/%,%,$(u-boot-spl-init)) -Wl,--start-group \
+		       $(patsubst $(obj)/%,%,$(u-boot-spl-main)) -Wl,--end-group \
+		       $(PLATFORM_LIBS) -Wl,-Map,$(SPL_BIN).map -o $(SPL_BIN))
 
 $(obj)/$(SPL_BIN): $(u-boot-spl-init) $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
 	$(call if_changed,u-boot-spl)
	ladis


More information about the U-Boot mailing list