diff mbox

[U-Boot,v3,04/14] mkconfig: add support for SPL CPU

Message ID 1339190167-20320-5-git-send-email-amartin@nvidia.com
State Superseded
Headers show

Commit Message

Allen Martin June 8, 2012, 9:15 p.m. UTC
Add support for specifying a different CPU for main u-boot and SPL
u-boot builds.  This is done by adding an optional SPL CPU after the
main CPU in boards.cfg as follows:

     normal_cpu:spl_cpu

This this case CPU will be set to "normal_cpu" during the main u-boot
build and "spl_cpu" during the SPL build.

Signed-off-by: Allen Martin <amartin@nvidia.com>
---
 boards.cfg     |    5 +++++
 doc/README.SPL |   12 ++++++++++++
 mkconfig       |   13 +++++++++++--
 3 files changed, 28 insertions(+), 2 deletions(-)

Comments

Simon Glass June 9, 2012, 6:20 p.m. UTC | #1
Hi Allen,

On Fri, Jun 8, 2012 at 2:15 PM, Allen Martin <amartin@nvidia.com> wrote:

> Add support for specifying a different CPU for main u-boot and SPL
> u-boot builds.  This is done by adding an optional SPL CPU after the
> main CPU in boards.cfg as follows:
>
>     normal_cpu:spl_cpu
>
> This this case CPU will be set to "normal_cpu" during the main u-boot
> build and "spl_cpu" during the SPL build.
>
> Signed-off-by: Allen Martin <amartin@nvidia.com>
> ---
>  boards.cfg     |    5 +++++
>  doc/README.SPL |   12 ++++++++++++
>  mkconfig       |   13 +++++++++++--
>  3 files changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/boards.cfg b/boards.cfg
> index f7f1190..8958ba2 100644
> --- a/boards.cfg
> +++ b/boards.cfg
> @@ -11,6 +11,11 @@
>  #      Lines starting with '#' are comments.
>  #      Blank lines are ignored.
>  #
> +#      The CPU field takes the form:
> +#              cpu[:spl_cpu]
> +#      If spl_cpu is specified the make variable CPU will be set to this
> +#      during the SPL build.
> +#
>  #      The options field takes the form:
>  #              <board config name>[:comma separated config options]
>  #      Each config option has the form (value defaults to "1"):
> diff --git a/doc/README.SPL b/doc/README.SPL
> index 0276953..e4a5ac3 100644
> --- a/doc/README.SPL
> +++ b/doc/README.SPL
> @@ -66,3 +66,15 @@ CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
>  CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
>  CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
>  CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
> +
> +
> +Normally CPU is assumed to be the same between the SPL and normal
> +u-boot build.  However it is possible to specify a different CPU for
> +the SPL build for cases where the SPL is expected to run on a
> +different CPU model from the main u-boot.  This is done by specifying
> +an SPL CPU in boards.cfg as follows:
> +
> +       normal_cpu:spl_cpu
>

I can't help thinking that this is more of a cpu issue than a board issue.
The way this is done all tegra2 (and later tegra3) boards will need to add
this in for their CPU. If you could solve this in the Makefiles then it
might be easier. Then this feature could be put into Tegra's
config.mkinstead of in every board.

I notice that $(CPU) is only references once in Makefile and once in
config.mk.

You could perhaps define a SPL_CPU variable and use that in spl/Makefile,
and CPU in Makefile. Then you don't need to put an 'if' in your config.mk -
it can just specify both.

This is just an idea - if you are happy with what you have then it is fine
with me.


> +
> +This this case CPU will be set to "normal_cpu" during the main u-boot
> +build and "spl_cpu" during the SPL build.
> diff --git a/mkconfig b/mkconfig
> index 3e9c695..66d3da5 100755
> --- a/mkconfig
> +++ b/mkconfig
> @@ -59,7 +59,8 @@ CONFIG_NAME="${1%_config}"
>  [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
>
>  arch="$2"
> -cpu="$3"
> +cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`
> +spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`
>  if [ "$4" = "-" ] ; then
>        board=${BOARD_NAME}
>  else
> @@ -131,7 +132,15 @@ fi
>  # Create include file for Make
>  #
>  echo "ARCH   = ${arch}"  >  config.mk
> -echo "CPU    = ${cpu}"   >> config.mk
> +if [ ! -z "$spl_cpu" ] ; then
>

if [ -n "$spl_cpu" ]


> +       echo 'ifeq ($(CONFIG_SPL_BUILD),y)' >> config.mk
> +       echo "CPU    = ${spl_cpu}" >> config.mk
> +       echo "else" >> config.mk
> +       echo "CPU    = ${cpu}"   >> config.mk
> +       echo "endif" >> config.mk


Maybe use () around the code so you only need >> config.mk at the end?


>
> +else
> +       echo "CPU    = ${cpu}"   >> config.mk
> +fi
>  echo "BOARD  = ${board}" >> config.mk
>
>  [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk
> --
> 1.7.9.5
>
>
Regards,
Simon
Allen Martin June 11, 2012, 6:40 p.m. UTC | #2
On Sat, Jun 09, 2012 at 11:20:34AM -0700, Simon Glass wrote:
> +
> +Normally CPU is assumed to be the same between the SPL and normal
> +u-boot build.  However it is possible to specify a different CPU for
> +the SPL build for cases where the SPL is expected to run on a
> +different CPU model from the main u-boot.  This is done by specifying
> +an SPL CPU in boards.cfg as follows:
> +
> +       normal_cpu:spl_cpu
> 
> I can't help thinking that this is more of a cpu issue than a board issue. The way this is done all tegra2 (and later tegra3) boards will need to add this in for their CPU. If you could solve this in the Makefiles then it might be easier. Then this feature could be put into Tegra's config.mk<http://config.mk> instead of in every board.
> 
> I notice that $(CPU) is only references once in Makefile and once in config.mk<http://config.mk>.
> 
> You could perhaps define a SPL_CPU variable and use that in spl/Makefile, and CPU in Makefile. Then you don't need to put an 'if' in your config.mk<http://config.mk> - it can just specify both.
> 
> This is just an idea - if you are happy with what you have then it is fine with me.
> 

I would definately prefer not to touch boards.cfg and mkconfig if I
don't have to.  The problem is the mkcnofig generated $(CPU) variable
is read really early by the top level Makefile and a bunch of derived
variables and decisions are made based on that well before any board
or chip specific Makefiles or config.mk files are referenced.  

I'm loathe to change how any of that works for fear of breaking some
other boards/chips.  I'm definately open to suggestions if there's a
better way of doing this that doesn't have to change boards.cfg
format. 

-Allen
diff mbox

Patch

diff --git a/boards.cfg b/boards.cfg
index f7f1190..8958ba2 100644
--- a/boards.cfg
+++ b/boards.cfg
@@ -11,6 +11,11 @@ 
 #	Lines starting with '#' are comments.
 #	Blank lines are ignored.
 #
+#	The CPU field takes the form:
+#		cpu[:spl_cpu]
+#	If spl_cpu is specified the make variable CPU will be set to this
+#	during the SPL build.
+#
 #	The options field takes the form:
 #		<board config name>[:comma separated config options]
 #	Each config option has the form (value defaults to "1"):
diff --git a/doc/README.SPL b/doc/README.SPL
index 0276953..e4a5ac3 100644
--- a/doc/README.SPL
+++ b/doc/README.SPL
@@ -66,3 +66,15 @@  CONFIG_SPL_DMA_SUPPORT (drivers/dma/libdma.o)
 CONFIG_SPL_POST_MEM_SUPPORT (post/drivers/memory.o)
 CONFIG_SPL_NAND_LOAD (drivers/mtd/nand/nand_spl_load.o)
 CONFIG_SPL_SPI_LOAD (drivers/mtd/spi/spi_spl_load.o)
+
+
+Normally CPU is assumed to be the same between the SPL and normal
+u-boot build.  However it is possible to specify a different CPU for
+the SPL build for cases where the SPL is expected to run on a
+different CPU model from the main u-boot.  This is done by specifying
+an SPL CPU in boards.cfg as follows:
+
+	normal_cpu:spl_cpu
+
+This this case CPU will be set to "normal_cpu" during the main u-boot
+build and "spl_cpu" during the SPL build.
diff --git a/mkconfig b/mkconfig
index 3e9c695..66d3da5 100755
--- a/mkconfig
+++ b/mkconfig
@@ -59,7 +59,8 @@  CONFIG_NAME="${1%_config}"
 [ "${BOARD_NAME}" ] || BOARD_NAME="${1%_config}"
 
 arch="$2"
-cpu="$3"
+cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $1}'`
+spl_cpu=`echo $3 | awk 'BEGIN {FS = ":"} ; {print $2}'`
 if [ "$4" = "-" ] ; then
 	board=${BOARD_NAME}
 else
@@ -131,7 +132,15 @@  fi
 # Create include file for Make
 #
 echo "ARCH   = ${arch}"  >  config.mk
-echo "CPU    = ${cpu}"   >> config.mk
+if [ ! -z "$spl_cpu" ] ; then
+	echo 'ifeq ($(CONFIG_SPL_BUILD),y)' >> config.mk
+	echo "CPU    = ${spl_cpu}" >> config.mk
+	echo "else" >> config.mk
+	echo "CPU    = ${cpu}"   >> config.mk
+	echo "endif" >> config.mk
+else
+	echo "CPU    = ${cpu}"   >> config.mk
+fi
 echo "BOARD  = ${board}" >> config.mk
 
 [ "${vendor}" ] && echo "VENDOR = ${vendor}" >> config.mk