diff mbox

[U-Boot,09/24,V2] arch/powerpc/*/config.mk: make CONFIG_SYS_LDSCRIPT settings work

Message ID 1290700844-31427-10-git-send-email-wd@denx.de
State Accepted
Commit fa11dbe56da5283a56f6ec044a1049645dd2e036
Headers show

Commit Message

Wolfgang Denk Nov. 25, 2010, 4 p.m. UTC
As we try to get rid of board specific config.mk files we must
provide a way for board specific settings of the LDSCRIPT variable
(path to the linker script) where needed.

We now implement the following hierarchy:

- Highest priority has a "#define CONFIG_SYS_LDCONFIG" in the board
  config file.
- If CONFIG_SYS_LDCONFIG is not set, and the system is booting from
  NAND (CONFIG_NAND_U_BOOT is set), then a board specific linker
  script board/$(BOARDDIR)/u-boot-nand.lds gets use.
- If we are not booting from NAND, we test if a processor specific
  linker script arch/powerpc/cpu/$(CPU)/u-boot.lds exists; if so we
  use that.
- As default, arch/powerpc/config.mk gets used.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Kim Phillips <kim.phillips@freescale.com>
Cc: Kumar Gala <kumar.gala@freescale.com>
Cc: Andy Fleming <afleming@gmail.com>
---
 arch/powerpc/config.mk             |   13 ++++++++++++-
 arch/powerpc/cpu/mpc512x/config.mk |    7 ++-----
 arch/powerpc/cpu/mpc5xx/config.mk  |   10 ----------
 arch/powerpc/cpu/mpc5xxx/config.mk |    5 +----
 arch/powerpc/cpu/mpc8220/config.mk |    5 +----
 arch/powerpc/cpu/mpc824x/config.mk |    5 +----
 arch/powerpc/cpu/mpc8260/config.mk |    5 +----
 arch/powerpc/cpu/mpc83xx/config.mk |    3 ---
 arch/powerpc/cpu/mpc85xx/config.mk |    3 ---
 arch/powerpc/cpu/mpc86xx/config.mk |    7 -------
 arch/powerpc/cpu/mpc8xx/config.mk  |    2 +-
 arch/powerpc/cpu/ppc4xx/config.mk  |    5 +----
 12 files changed, 20 insertions(+), 50 deletions(-)

Comments

Haiying Wang Nov. 25, 2010, 4:20 p.m. UTC | #1
On Thu, 2010-11-25 at 09:00 -0700, Wolfgang Denk wrote:
> As we try to get rid of board specific config.mk files we must
> provide a way for board specific settings of the LDSCRIPT variable
> (path to the linker script) where needed.
> 
> We now implement the following hierarchy:
> 
> - Highest priority has a "#define CONFIG_SYS_LDCONFIG" in the board
>   config file.
> - If CONFIG_SYS_LDCONFIG is not set, and the system is booting from
>   NAND (CONFIG_NAND_U_BOOT is set), then a board specific linker
>   script board/$(BOARDDIR)/u-boot-nand.lds gets use.

u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least, it is in
$(SRCTREE)/$(CPUDIR)/

> - If we are not booting from NAND, we test if a processor specific
>   linker script arch/powerpc/cpu/$(CPU)/u-boot.lds exists; if so we
>   use that.
should we use $(CPUDIR) instead of arch/powerpc/cpu/$(CPU)?

Haiying
Wolfgang Denk Nov. 25, 2010, 5:19 p.m. UTC | #2
Dear Haiying Wang,

In message <1290702018.2007.4.camel@haiying-laptop> you wrote:
>
> > - If CONFIG_SYS_LDCONFIG is not set, and the system is booting from
> >   NAND (CONFIG_NAND_U_BOOT is set), then a board specific linker
> >   script board/$(BOARDDIR)/u-boot-nand.lds gets use.
> 
> u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least, it is in
> $(SRCTREE)/$(CPUDIR)/

This is not correct - situation before applying my patches:

-> find * -name u-boot-nand.lds
arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
board/amcc/acadia/u-boot-nand.lds
board/amcc/bamboo/u-boot-nand.lds
board/amcc/canyonlands/u-boot-nand.lds
board/amcc/kilauea/u-boot-nand.lds
board/amcc/sequoia/u-boot-nand.lds
board/esd/pmc440/u-boot-nand.lds
board/samsung/smdk6400/u-boot-nand.lds

> > - If we are not booting from NAND, we test if a processor specific
> >   linker script arch/powerpc/cpu/$(CPU)/u-boot.lds exists; if so we
> >   use that.
> should we use $(CPUDIR) instead of arch/powerpc/cpu/$(CPU)?

I'm not sure if CPUDIR is defined at that time.  Did you try it out?

Best regards,

Wolfgang Denk
Wolfgang Denk Nov. 25, 2010, 5:47 p.m. UTC | #3
Dear Haiying Wang,

In message <1290702018.2007.4.camel@haiying-laptop> you wrote:
> On Thu, 2010-11-25 at 09:00 -0700, Wolfgang Denk wrote:
> > As we try to get rid of board specific config.mk files we must
> > provide a way for board specific settings of the LDSCRIPT variable
> > (path to the linker script) where needed.
> > 
> > We now implement the following hierarchy:
> > 
> > - Highest priority has a "#define CONFIG_SYS_LDCONFIG" in the board
> >   config file.
> > - If CONFIG_SYS_LDCONFIG is not set, and the system is booting from
> >   NAND (CONFIG_NAND_U_BOOT is set), then a board specific linker
> >   script board/$(BOARDDIR)/u-boot-nand.lds gets use.
> 
> u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least, it is in
> $(SRCTREE)/$(CPUDIR)/

What is incorrect is the description - it does not match the latest
code: we don't test  CONFIG_NAND_U_BOOT but CONFIG_NAND_SPL.

I will fix this when applying.

Best regards,

Wolfgang Denk
Haiying Wang Nov. 25, 2010, 6:16 p.m. UTC | #4
On Thu, 2010-11-25 at 10:19 -0700, Wolfgang Denk wrote:
> Dear Haiying Wang,
> 
> In message <1290702018.2007.4.camel@haiying-laptop> you wrote:
> >
> > > - If CONFIG_SYS_LDCONFIG is not set, and the system is booting
> from
> > >   NAND (CONFIG_NAND_U_BOOT is set), then a board specific linker
> > >   script board/$(BOARDDIR)/u-boot-nand.lds gets use.
> >
> > u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least, it is
> in
> > $(SRCTREE)/$(CPUDIR)/
> 
> This is not correct - situation before applying my patches:

> -> find * -name u-boot-nand.lds
> arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
so your patch for arch/powerpc/config.mk will not get u-boot-nand.lds
for mpc85xx boards, only for the boards below. Then 85xx boards still
need to get the lds from board/$(BOARDIR)/config.mk. Is that what you
want?

> board/amcc/acadia/u-boot-nand.lds
> board/amcc/bamboo/u-boot-nand.lds
> board/amcc/canyonlands/u-boot-nand.lds
> board/amcc/kilauea/u-boot-nand.lds
> board/amcc/sequoia/u-boot-nand.lds
> board/esd/pmc440/u-boot-nand.lds
> board/samsung/smdk6400/u-boot-nand.lds
> 
> > > - If we are not booting from NAND, we test if a processor specific
> > >   linker script arch/powerpc/cpu/$(CPU)/u-boot.lds exists; if so
> we
> > >   use that.
> > should we use $(CPUDIR) instead of arch/powerpc/cpu/$(CPU)?
> 
> I'm not sure if CPUDIR is defined at that time.  Did you try it out?

CPUDIR is defined in config.mk, I tried it for 85xx/p1 boards and it
worked.

Haiying
Wolfgang Denk Nov. 25, 2010, 6:28 p.m. UTC | #5
Dear Haiying Wang,

In message <1290708988.2007.13.camel@haiying-laptop> you wrote:
>
> > > u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least, it is
> > in
> > > $(SRCTREE)/$(CPUDIR)/
> > 
> > This is not correct - situation before applying my patches:
> 
> > -> find * -name u-boot-nand.lds
> > arch/powerpc/cpu/mpc85xx/u-boot-nand.lds

Oops, sorry. I missed that one, even though I was looking for it :-(

> so your patch for arch/powerpc/config.mk will not get u-boot-nand.lds
> for mpc85xx boards, only for the boards below. Then 85xx boards still
> need to get the lds from board/$(BOARDIR)/config.mk. Is that what you
> want?

No, not really.  But actually I was just cleaning up probems where ran
into them, not trying to perform a more general cleanup [*].

The situation is that the relevant 85xx boards appeare to have their
own config.mk files which explicitly set LDSCRIPT to the value they
need (which is indeed different from the default that gets set up ib
arch/powerpc/config.mk:

arch/powerpc/config.mk:  LDSCRIPT := $(SRCTREE)/$(CONFIG_BOARDDIR)/u-boot-nand.lds

board/freescale/mpc8536ds/config.mk:   LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
board/freescale/mpc8569mds/config.mk:  LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
board/freescale/p1_p2_rdb/config.mk:   LDSCRIPT := $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds

So it seems my patches do not have any impact on the building of 85xx
systems.  Or am I missing something?

> CPUDIR is defined in config.mk, I tried it for 85xx/p1 boards and it
> worked.

OK, I'll remember this for the next optimization.

[*] There is more that can be done for ontimization: actually many of
    the PPC u-boot.lds files are (except for white space, indentation
    and tiny irrelevant details) identical. I intend to use a single,
    common linker script for all these cases, which will allow to
    remove dozens of more or less identical files.

    But I want to have a stable code base first.

Best regards,

Wolfgang Denk
Haiying Wang Nov. 25, 2010, 6:59 p.m. UTC | #6
On Thu, 2010-11-25 at 11:28 -0700, Wolfgang Denk wrote:
> Dear Haiying Wang,
> 
> In message <1290708988.2007.13.camel@haiying-laptop> you wrote:
> >
> > > > u-boot-nand.lds is not in board/$(BOARDDIR) for 85xx at least,
> it is
> > > in
> > > > $(SRCTREE)/$(CPUDIR)/
> > >
> > > This is not correct - situation before applying my patches:
> >
> > > -> find * -name u-boot-nand.lds
> > > arch/powerpc/cpu/mpc85xx/u-boot-nand.lds
> 
> Oops, sorry. I missed that one, even though I was looking for it :-(
> 
> > so your patch for arch/powerpc/config.mk will not get
> u-boot-nand.lds
> > for mpc85xx boards, only for the boards below. Then 85xx boards
> still
> > need to get the lds from board/$(BOARDIR)/config.mk. Is that what
> you
> > want?
> 
> No, not really.  But actually I was just cleaning up probems where ran
> into them, not trying to perform a more general cleanup [*].
> 
> The situation is that the relevant 85xx boards appeare to have their
> own config.mk files which explicitly set LDSCRIPT to the value they
> need (which is indeed different from the default that gets set up ib
> arch/powerpc/config.mk:
> 
> arch/powerpc/config.mk:  LDSCRIPT :=
> $(SRCTREE)/$(CONFIG_BOARDDIR)/u-boot-nand.lds
> 
> board/freescale/mpc8536ds/config.mk:   LDSCRIPT :=
> $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
> board/freescale/mpc8569mds/config.mk:  LDSCRIPT :=
> $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
> board/freescale/p1_p2_rdb/config.mk:   LDSCRIPT :=
> $(TOPDIR)/$(CPUDIR)/u-boot-nand.lds
> 
> So it seems my patches do not have any impact on the building of 85xx
> systems.  Or am I missing something?
> 
No, your patch doesn't have impact on them. I just wonder if you wanted
to apply your patch for 85xx board.:)

Haiying
diff mbox

Patch

diff --git a/arch/powerpc/config.mk b/arch/powerpc/config.mk
index 06a3b10..5bc849c 100644
--- a/arch/powerpc/config.mk
+++ b/arch/powerpc/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2000-2002
+# (C) Copyright 2000-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -29,6 +29,17 @@  PLATFORM_RELFLAGS += -mrelocatable
 PLATFORM_CPPFLAGS += -DCONFIG_PPC -D__powerpc__
 PLATFORM_LDFLAGS  += -n
 
+ifdef CONFIG_SYS_LDSCRIPT
+# need to strip off double quotes
+LDSCRIPT := $(subst ",,$(CONFIG_SYS_LDSCRIPT))
+else ifdef CONFIG_NAND_SPL
+LDSCRIPT := $(SRCTREE)/$(CONFIG_BOARDDIR)/u-boot-nand.lds
+else
+ifneq ($(wildcard $(SRCTREE)/arch/powerpc/cpu/$(CPU)/u-boot.lds),)
+LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/$(CPU)/u-boot.lds
+endif
+endif
+
 #
 # When cross-compiling on NetBSD, we have to define __PPC__ or else we
 # will pick up a va_list declaration that is incompatible with the
diff --git a/arch/powerpc/cpu/mpc512x/config.mk b/arch/powerpc/cpu/mpc512x/config.mk
index b29edb1..baf55cc 100644
--- a/arch/powerpc/cpu/mpc512x/config.mk
+++ b/arch/powerpc/cpu/mpc512x/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2007-2009 DENX Software Engineering
+# (C) Copyright 2007-2010 DENX Software Engineering
 #
 # See file CREDITS for list of people who contributed to this
 # project.
@@ -19,11 +19,8 @@ 
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
 #
+
 PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC512X -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float -mcpu=603e
-
-# Use default linker script.
-# A board port can override this setting in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc512x/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc5xx/config.mk b/arch/powerpc/cpu/mpc5xx/config.mk
index 5f9285d..1c7df00 100644
--- a/arch/powerpc/cpu/mpc5xx/config.mk
+++ b/arch/powerpc/cpu/mpc5xx/config.mk
@@ -21,16 +21,6 @@ 
 # MA 02111-1307 USA
 #
 
-#
-# File:			config.mk
-#
-# Discription:		compiler flags and make definitions
-#
-
-
 PLATFORM_RELFLAGS +=	-fPIC -meabi
 
 PLATFORM_CPPFLAGS +=	-DCONFIG_5xx -ffixed-r2 -mpowerpc -msoft-float
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc5xx/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc5xxx/config.mk b/arch/powerpc/cpu/mpc5xxx/config.mk
index 7ef8a47..832909f 100644
--- a/arch/powerpc/cpu/mpc5xxx/config.mk
+++ b/arch/powerpc/cpu/mpc5xxx/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,6 +25,3 @@  PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC5xxx -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc5xxx/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc8220/config.mk b/arch/powerpc/cpu/mpc8220/config.mk
index e706883..9142b91 100644
--- a/arch/powerpc/cpu/mpc8220/config.mk
+++ b/arch/powerpc/cpu/mpc8220/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2003
+# (C) Copyright 2003-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,6 +25,3 @@  PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC8220 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc8220/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc824x/config.mk b/arch/powerpc/cpu/mpc824x/config.mk
index 27c2873..65a1771 100644
--- a/arch/powerpc/cpu/mpc824x/config.mk
+++ b/arch/powerpc/cpu/mpc824x/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -24,6 +24,3 @@ 
 PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC824X -ffixed-r2 -mstring -mcpu=603e -msoft-float
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc824x/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc8260/config.mk b/arch/powerpc/cpu/mpc8260/config.mk
index a9bb688..5e4645a 100644
--- a/arch/powerpc/cpu/mpc8260/config.mk
+++ b/arch/powerpc/cpu/mpc8260/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -25,6 +25,3 @@  PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_8260 -DCONFIG_CPM2 -ffixed-r2 \
 		     -mstring -mcpu=603e -mmultiple
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc8260/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc83xx/config.mk b/arch/powerpc/cpu/mpc83xx/config.mk
index 8a3a8c1..0dced88 100644
--- a/arch/powerpc/cpu/mpc83xx/config.mk
+++ b/arch/powerpc/cpu/mpc83xx/config.mk
@@ -24,6 +24,3 @@  PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -DCONFIG_MPC83xx -DCONFIG_E300 \
 			-ffixed-r2 -msoft-float
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc83xx/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc85xx/config.mk b/arch/powerpc/cpu/mpc85xx/config.mk
index ce4376b..3f3d096 100644
--- a/arch/powerpc/cpu/mpc85xx/config.mk
+++ b/arch/powerpc/cpu/mpc85xx/config.mk
@@ -34,6 +34,3 @@  PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
 # http://gcc.gnu.org/ml/gcc-patches/2008-04/msg00311.html
 PLATFORM_CPPFLAGS +=$(call cc-option,-mspe=yes)
 PLATFORM_CPPFLAGS +=$(call cc-option,-mno-spe)
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc85xx/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc86xx/config.mk b/arch/powerpc/cpu/mpc86xx/config.mk
index bce0fb3..ca2f837 100644
--- a/arch/powerpc/cpu/mpc86xx/config.mk
+++ b/arch/powerpc/cpu/mpc86xx/config.mk
@@ -25,10 +25,3 @@  PLATFORM_RELFLAGS += -fPIC -meabi
 
 PLATFORM_CPPFLAGS += -ffixed-r2 -mstring
 PLATFORM_CPPFLAGS += -maltivec -mabi=altivec -msoft-float
-
-# Enable gc-sections to enable generation of smaller images.
-PLATFORM_LDFLAGS += --gc-sections
-PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/mpc86xx/u-boot.lds
diff --git a/arch/powerpc/cpu/mpc8xx/config.mk b/arch/powerpc/cpu/mpc8xx/config.mk
index 5540d65..f5e08a5 100644
--- a/arch/powerpc/cpu/mpc8xx/config.mk
+++ b/arch/powerpc/cpu/mpc8xx/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
diff --git a/arch/powerpc/cpu/ppc4xx/config.mk b/arch/powerpc/cpu/ppc4xx/config.mk
index 5bda710..d862bb4 100644
--- a/arch/powerpc/cpu/ppc4xx/config.mk
+++ b/arch/powerpc/cpu/ppc4xx/config.mk
@@ -1,5 +1,5 @@ 
 #
-# (C) Copyright 2000
+# (C) Copyright 2000-2010
 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
 #
 # See file CREDITS for list of people who contributed to this
@@ -32,6 +32,3 @@  PLATFORM_CPPFLAGS += -Wa,-m440 -mcpu=440
 else
 PLATFORM_CPPFLAGS += -Wa,-m405 -mcpu=405
 endif
-
-# Use default linker script.  Board port can override in board/*/config.mk
-LDSCRIPT := $(SRCTREE)/arch/powerpc/cpu/ppc4xx/u-boot.lds