[U-Boot] How to use board specific #defines during building of linker script

Graeme Russ graeme.russ at gmail.com
Thu Feb 17 22:52:14 CET 2011


Hi All,

I'm looking at removing the following, last remaining, line from config.mk
of the eNET board:

LDPPFLAGS += -DFLASH_SIZE=0x40000

This is needed to allow the calculation of the location of the reset vector
so it resided in the last 16 bytes of the boot flash.

Looking at how the compilation of u-boot.lds works, there are three locations
where defines are exposed to the compilation of u-boot.lds

  1) LDPPFLAGS or CPPFLAGS/PLATFORM_CPPFLAGS

  2) /include/u-boot/u-boot.lds.h

  3) config.mk detects a specific set of defined define and if present,
     adds them to CPPFLAGS - For example config.mk lines 169 through 175:

     ifneq ($(CONFIG_SYS_TEXT_BASE),)
     CPPFLAGS += -DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE)
     endif

     ifneq ($(RESET_VECTOR_ADDRESS),)
     CPPFLAGS += -DRESET_VECTOR_ADDRESS=$(RESET_VECTOR_ADDRESS)
     endif


LDPPFLAGS forces the use of a board specific config.mk, so that is out of
the question.

Patching /include/u-boot/u-boot.lds.h seems a bit messy

Which leaves option #3 and adding the following to config.mk

ifneq ($(CONFIG_SYS_FLASH_SIZE),)
CPPFLAGS += -DCONFIG_SYS_FLASH_SIZE=$(CONFIG_SYS_FLASH_SIZE)
endif

and defining CONFIG_SYS_FLASH_SIZE in /include/configs/eNET.h

But why not just include config.h when building u-boot.lds?

For example, change Makefile lines 282 through 288 to:

# 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 \
        -include $(TOPDIR)/include/config.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')

Thoughts?

Regards,

Graeme


More information about the U-Boot mailing list