[PATCH 2/8] ARM: renesas: Simplify board Makefiles

Quentin Schulz quentin.schulz at cherry.de
Wed Jan 15 11:22:54 CET 2025


Hi Marek,

On 1/12/25 11:34 PM, Marek Vasut wrote:
> Introduce board/renesas/common/Makefile and remove the multiple
> duplicate copies of obj := ../common/*.o from board Makefiles.
> Let the build system include the common Makefile using the
> HAVE_VENDOR_COMMON_LIB and build the common objects that are
> shared by all the boards that way. No functional change intended.
> 

Thanks for highlighting this HAVE_VENDOR_COMMON_LIB mechanism, I'm now 
planning on migrating the Theobroma boards to that :) (I would need 
https://lore.kernel.org/u-boot/20250112223252.179123-1-marek.vasut+renesas@mailbox.org/ 
though :) ).

> Some of the remaining board files which include board specific
> settings have been updated to use obj-y += to avoid rewriting
> the board obj-y target and avoid dropping object files from the
> build.
> 
> Board Makefiles cannot be empty, else they do not generate built-in.o,
> move the CONFIG_XPL_BUILD ifdeffery from Makefiles into .c files to
> make sure there is always a built-in.o generated from the remaining
> minimal Makefiles. This will be further cleaned up in follow up patches.
> 

Unrelated, but I misread the commit log and was wondering whether this 
patch series would work without the additional patch from 
https://lore.kernel.org/u-boot/20250112223252.179123-1-marek.vasut+renesas@mailbox.org/ 
so wanted to build an Rcar defconfig to verify but I'm unable to build 
r8a779f0_spider_defconfig from master:

/usr/bin/aarch64-linux-gnu-ld: 
/usr/lib/gcc/aarch64-linux-gnu/14/libgcc.a(lse-init.o): in function 
`init_have_lse_atomics':
/builddir/build/BUILD/cross-gcc-14.2.1-build/gcc-14.2.1-20240912/aarch64-linux-gnu/aarch64-linux-gnu/libgcc/../../../gcc-14.2.1-20240912/libgcc/config/aarch64/lse-init.c:46:(.text.startup+0xc): 
undefined reference to `__getauxval'
/usr/bin/aarch64-linux-gnu-ld: 
/usr/lib/gcc/aarch64-linux-gnu/14/libgcc.a(__aarch64_have_sme.o): in 
function `sme_accessible':
/builddir/build/BUILD/cross-gcc-14.2.1-build/gcc-14.2.1-20240912/aarch64-linux-gnu/aarch64-linux-gnu/libgcc/../../../gcc-14.2.1-20240912/libgcc/config/aarch64/__aarch64_have_sme.c:49:(.text.startup+0xc): 
undefined reference to `__getauxval'
/usr/bin/aarch64-linux-gnu-ld: 
/usr/lib/gcc/aarch64-linux-gnu/14/libgcc.a(__arm_tpidr2_restore.o): in 
function `__arm_tpidr2_restore':
/builddir/build/BUILD/cross-gcc-14.2.1-build/gcc-14.2.1-20240912/aarch64-linux-gnu/aarch64-linux-gnu/libgcc/../../../gcc-14.2.1-20240912/libgcc/config/aarch64/__arm_tpidr2_restore.S:88:(.text+0x90): 
undefined reference to `abort'
/usr/bin/aarch64-linux-gnu-ld: 
/usr/lib/gcc/aarch64-linux-gnu/14/libgcc.a(__arm_tpidr2_save.o): in 
function `__libgcc_arm_tpidr2_save':
/builddir/build/BUILD/cross-gcc-14.2.1-build/gcc-14.2.1-20240912/aarch64-linux-gnu/aarch64-linux-gnu/libgcc/../../../gcc-14.2.1-20240912/libgcc/config/aarch64/__arm_tpidr2_save.S:95:(.text+0x9c): 
undefined reference to `abort'
collect2: fatal error: ld terminated with signal 11 [Segmentation 
fault], core dumped
compilation terminated.
make: *** [Makefile:1812: u-boot] Error 1
make: *** Deleting file 'u-boot'

so cannot check myself.

I'm running Fedora 41.

$ aarch64-linux-gnu-gcc --version
aarch64-linux-gnu-gcc (GCC) 14.2.1 20240912 (Red Hat Cross 14.2.1-1)

> Signed-off-by: Marek Vasut <marek.vasut+renesas at mailbox.org>
> ---
> Cc: Adam Ford <aford173 at gmail.com>
> Cc: Biju Das <biju.das.jz at bp.renesas.com>
> Cc: Lad Prabhakar <prabhakar.mahadev-lad.rj at bp.renesas.com>
> Cc: Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
> Cc: Paul Barker <paul.barker.ct at bp.renesas.com>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Tom Rini <trini at konsulko.com>
> Cc: u-boot at lists.denx.de
> ---
>   board/renesas/common/Makefile         | 45 +++++++++++++++++++++++++++
>   board/renesas/common/gen3-common.c    |  3 --
>   board/renesas/condor/Makefile         | 13 --------
>   board/renesas/draak/Makefile          |  6 +---
>   board/renesas/draak/draak.c           |  4 +++
>   board/renesas/eagle/Makefile          | 13 --------
>   board/renesas/ebisu/Makefile          | 13 --------
>   board/renesas/falcon/Makefile         | 13 --------
>   board/renesas/grayhawk/Makefile       |  9 ------
>   board/renesas/salvator-x/Makefile     |  6 +---
>   board/renesas/salvator-x/salvator-x.c |  4 +++
>   board/renesas/spider/Makefile         |  9 ------
>   board/renesas/ulcb/Makefile           |  6 +---
>   board/renesas/ulcb/cpld.c             |  4 +++
>   board/renesas/ulcb/ulcb.c             |  4 +++
>   board/renesas/v3hsk/Makefile          |  5 ---
>   board/renesas/v3hsk/cpld.c            |  4 +++
>   board/renesas/v3msk/Makefile          |  5 ---
>   board/renesas/v3msk/cpld.c            |  4 +++
>   board/renesas/whitehawk/Makefile      | 13 --------
>   20 files changed, 72 insertions(+), 111 deletions(-)
>   create mode 100644 board/renesas/common/Makefile
>   delete mode 100644 board/renesas/condor/Makefile
>   delete mode 100644 board/renesas/eagle/Makefile
>   delete mode 100644 board/renesas/ebisu/Makefile
>   delete mode 100644 board/renesas/falcon/Makefile
>   delete mode 100644 board/renesas/grayhawk/Makefile
>   delete mode 100644 board/renesas/spider/Makefile
>   delete mode 100644 board/renesas/whitehawk/Makefile
> 
> diff --git a/board/renesas/common/Makefile b/board/renesas/common/Makefile
> new file mode 100644
> index 00000000000..2072338ea05
> --- /dev/null
> +++ b/board/renesas/common/Makefile
> @@ -0,0 +1,45 @@
> +#
> +# board/renesas/whitehawk/Makefile
> +#
> +# Copyright (C) 2024 Marek Vasut <marek.vasut+renesas at mailbox.org>
> +#
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +
> +# R-Car SoCs
> +ifndef CONFIG_RZG2L
> +

This is a bit out of context, can you explain why this suddenly is here?

> +# 32 bit SoCs
> +ifdef CONFIG_RCAR_GEN2
> +endif
> +

Not sure we need this noop?

Also this probably should rather be CONFIG_RCAR_32 instead?

> +# 64 bit SoCs
> +ifdef CONFIG_RCAR_64
> +ifndef CONFIG_XPL_BUILD
> +obj-y	+= common.o
> +endif
> +
> +ifdef CONFIG_RCAR_GEN3
> +ifdef CONFIG_XPL_BUILD
> +obj-y	+= gen3-spl.o
> +else
> +obj-y	+= gen3-common.o
> +ifdef CONFIG_R8A77970
> +obj-y	+= v3-common.o
> +endif
> +ifdef CONFIG_R8A77980
> +obj-y	+= v3-common.o
> +endif
> +endif
> +endif
> +
> +ifdef CONFIG_RCAR_GEN4
> +ifdef CONFIG_XPL_BUILD
> +obj-y	+= gen4-spl.o
> +else
> +obj-y	+= gen4-common.o
> +endif
> +endif
> +endif
> +
> +endif
> diff --git a/board/renesas/common/gen3-common.c b/board/renesas/common/gen3-common.c
> index 549bec9e137..840ea6d7820 100644
> --- a/board/renesas/common/gen3-common.c
> +++ b/board/renesas/common/gen3-common.c
> @@ -17,8 +17,6 @@
>   #include <asm/arch/renesas.h>
>   #include <linux/libfdt.h>
>   
> -#ifdef CONFIG_RCAR_64
> -
>   DECLARE_GLOBAL_DATA_PTR;
>   
>   /* If the firmware passed a device tree use it for e.g. U-Boot DRAM setup. */
> @@ -182,4 +180,3 @@ int ft_board_setup(void *blob, struct bd_info *bd)
>   	return 0;
>   }
>   #endif
> -#endif
> diff --git a/board/renesas/condor/Makefile b/board/renesas/condor/Makefile
> deleted file mode 100644
> index 3b1756b44cd..00000000000
> --- a/board/renesas/condor/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#
> -# board/renesas/condor/Makefile
> -#
> -# Copyright (C) 2019 Renesas Electronics Corporation
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/gen3-common.o ../common/common.o
> -endif
> diff --git a/board/renesas/draak/Makefile b/board/renesas/draak/Makefile
> index 6ce05bcd649..945cc2134e8 100644
> --- a/board/renesas/draak/Makefile
> +++ b/board/renesas/draak/Makefile
> @@ -6,8 +6,4 @@
>   # SPDX-License-Identifier: GPL-2.0+
>   #
>   
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= draak.o ../common/gen3-common.o ../common/common.o
> -endif
> +obj-y	+= draak.o
> diff --git a/board/renesas/draak/draak.c b/board/renesas/draak/draak.c
> index a51bf65674f..b742b8d6220 100644
> --- a/board/renesas/draak/draak.c
> +++ b/board/renesas/draak/draak.c
> @@ -6,6 +6,8 @@
>    * Copyright (C) 2017 Marek Vasut <marek.vasut+renesas at gmail.com>
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <cpu_func.h>
>   #include <hang.h>
>   #include <init.h>
> @@ -65,3 +67,5 @@ int board_init(void)
>   
>   	return 0;
>   }
> +
> +#endif
> diff --git a/board/renesas/eagle/Makefile b/board/renesas/eagle/Makefile
> deleted file mode 100644
> index a5c18d81eef..00000000000
> --- a/board/renesas/eagle/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#
> -# board/renesas/eagle/Makefile
> -#
> -# Copyright (C) 2015 Renesas Electronics Corporation
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/v3-common.o ../common/gen3-common.o ../common/common.o
> -endif
> diff --git a/board/renesas/ebisu/Makefile b/board/renesas/ebisu/Makefile
> deleted file mode 100644
> index 72130b76234..00000000000
> --- a/board/renesas/ebisu/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#
> -# board/renesas/ebisu/Makefile
> -#
> -# Copyright (C) 2018 Renesas Electronics Corporation
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/gen3-common.o ../common/common.o
> -endif
> diff --git a/board/renesas/falcon/Makefile b/board/renesas/falcon/Makefile
> deleted file mode 100644
> index 949953f6981..00000000000
> --- a/board/renesas/falcon/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#
> -# board/renesas/falcon/Makefile
> -#
> -# Copyright (C) 2020 Renesas Electronics Corp.
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/gen4-common.o ../common/common.o
> -endif
> diff --git a/board/renesas/grayhawk/Makefile b/board/renesas/grayhawk/Makefile
> deleted file mode 100644
> index a70bd3739f1..00000000000
> --- a/board/renesas/grayhawk/Makefile
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -#
> -# board/renesas/grayhawk/Makefile
> -#
> -# Copyright (C) 2023 Renesas Electronics Corp.
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -obj-y	:= ../common/gen4-common.o ../common/common.o
> diff --git a/board/renesas/salvator-x/Makefile b/board/renesas/salvator-x/Makefile
> index fe53366829c..daea3e6838f 100644
> --- a/board/renesas/salvator-x/Makefile
> +++ b/board/renesas/salvator-x/Makefile
> @@ -6,8 +6,4 @@
>   # SPDX-License-Identifier: GPL-2.0+
>   #
>   
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= salvator-x.o ../common/gen3-common.o ../common/common.o
> -endif
> +obj-y	+= salvator-x.o
> diff --git a/board/renesas/salvator-x/salvator-x.c b/board/renesas/salvator-x/salvator-x.c
> index 2c8860bcee4..b6fb106ca5d 100644
> --- a/board/renesas/salvator-x/salvator-x.c
> +++ b/board/renesas/salvator-x/salvator-x.c
> @@ -7,6 +7,8 @@
>    * Copyright (C) 2015 Nobuhiro Iwamatsu <iwamatsu at nigauri.org>
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <cpu_func.h>
>   #include <image.h>
>   #include <init.h>
> @@ -93,3 +95,5 @@ int board_fit_config_name_match(const char *name)
>   	return -1;
>   }
>   #endif
> +
> +#endif
> diff --git a/board/renesas/spider/Makefile b/board/renesas/spider/Makefile
> deleted file mode 100644
> index e0f403d5fcc..00000000000
> --- a/board/renesas/spider/Makefile
> +++ /dev/null
> @@ -1,9 +0,0 @@
> -#
> -# board/renesas/spider/Makefile
> -#
> -# Copyright (C) 2020 Renesas Electronics Corp.
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -obj-y	:= ../common/gen4-common.o ../common/common.o
> diff --git a/board/renesas/ulcb/Makefile b/board/renesas/ulcb/Makefile
> index 6b2aa8c29f6..4f608613c15 100644
> --- a/board/renesas/ulcb/Makefile
> +++ b/board/renesas/ulcb/Makefile
> @@ -6,8 +6,4 @@
>   # SPDX-License-Identifier: GPL-2.0+
>   #
>   
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ulcb.o cpld.o ../common/gen3-common.o ../common/common.o
> -endif
> +obj-y	+= ulcb.o cpld.o
> diff --git a/board/renesas/ulcb/cpld.c b/board/renesas/ulcb/cpld.c
> index e72e45e3fb4..6a708d86cc8 100644
> --- a/board/renesas/ulcb/cpld.c
> +++ b/board/renesas/ulcb/cpld.c
> @@ -6,6 +6,8 @@
>    * Copyright (C) 2017 Cogent Embedded, Inc.
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <command.h>
>   #include <asm/gpio.h>
>   #include <asm/io.h>
> @@ -189,3 +191,5 @@ U_BOOT_DRIVER(sysreset_renesas_ulcb) = {
>   	.of_match	= renesas_ulcb_sysreset_ids,
>   	.priv_auto	= sizeof(struct renesas_ulcb_sysreset_priv),
>   };
> +
> +#endif
> diff --git a/board/renesas/ulcb/ulcb.c b/board/renesas/ulcb/ulcb.c
> index 64f01b123cb..e1445adbb69 100644
> --- a/board/renesas/ulcb/ulcb.c
> +++ b/board/renesas/ulcb/ulcb.c
> @@ -6,6 +6,8 @@
>    * Copyright (C) 2017 Renesas Electronics Corporation
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <image.h>
>   #include <init.h>
>   #include <malloc.h>
> @@ -84,3 +86,5 @@ int board_fit_config_name_match(const char *name)
>   	return -1;
>   }
>   #endif
> +
> +#endif
> diff --git a/board/renesas/v3hsk/Makefile b/board/renesas/v3hsk/Makefile
> index 936047cb3d5..0091bc9cd5b 100644
> --- a/board/renesas/v3hsk/Makefile
> +++ b/board/renesas/v3hsk/Makefile
> @@ -7,9 +7,4 @@
>   # SPDX-License-Identifier: GPL-2.0+
>   #
>   
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/v3-common.o ../common/gen3-common.o ../common/common.o
>   obj-$(CONFIG_SYSRESET)	+= cpld.o
> -endif
> diff --git a/board/renesas/v3hsk/cpld.c b/board/renesas/v3hsk/cpld.c
> index 1272aec7302..b82622f9c54 100644
> --- a/board/renesas/v3hsk/cpld.c
> +++ b/board/renesas/v3hsk/cpld.c
> @@ -7,6 +7,8 @@
>    *
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <dm.h>
>   #include <errno.h>
>   #include <i2c.h>
> @@ -177,3 +179,5 @@ U_BOOT_DRIVER(sysreset_renesas_v3hsk) = {
>   	.probe		= renesas_v3hsk_sysreset_probe,
>   	.of_match	= renesas_v3hsk_sysreset_ids,
>   };
> +
> +#endif
> diff --git a/board/renesas/v3msk/Makefile b/board/renesas/v3msk/Makefile
> index 21eaddb6c28..fe8bf1ed1ae 100644
> --- a/board/renesas/v3msk/Makefile
> +++ b/board/renesas/v3msk/Makefile
> @@ -7,9 +7,4 @@
>   # SPDX-License-Identifier: GPL-2.0+
>   #
>   
> -ifdef CONFIG_XPL_BUILD
> -obj-y	:= ../common/gen3-spl.o
> -else
> -obj-y	:= ../common/v3-common.o ../common/gen3-common.o ../common/common.o
>   obj-$(CONFIG_SYSRESET)	+= cpld.o
> -endif
> diff --git a/board/renesas/v3msk/cpld.c b/board/renesas/v3msk/cpld.c
> index 260755ac746..93f3bf391cd 100644
> --- a/board/renesas/v3msk/cpld.c
> +++ b/board/renesas/v3msk/cpld.c
> @@ -7,6 +7,8 @@
>    *
>    */
>   
> +#if !IS_ENABLED(CONFIG_XPL_BUILD)
> +
>   #include <asm/gpio.h>
>   #include <asm/io.h>
>   #include <dm.h>
> @@ -365,3 +367,5 @@ U_BOOT_DRIVER(sysreset_renesas_v3msk) = {
>   	.of_match	= renesas_v3msk_sysreset_ids,
>   	.priv_auto	= sizeof(struct renesas_v3msk_sysreset_priv),
>   };
> +
> +#endif
> diff --git a/board/renesas/whitehawk/Makefile b/board/renesas/whitehawk/Makefile
> deleted file mode 100644
> index f10eb82d221..00000000000
> --- a/board/renesas/whitehawk/Makefile
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -#
> -# board/renesas/whitehawk/Makefile
> -#
> -# Copyright (C) 2021 Renesas Electronics Corp.
> -#
> -# SPDX-License-Identifier: GPL-2.0+
> -#
> -
> -ifdef CONFIG_SPL_BUILD
> -obj-y	:= ../common/gen4-spl.o
> -else
> -obj-y	:= ../common/gen4-common.o ../common/common.o
> -endif

This honestly was a bit difficult to review and felt like more than one 
change was made at once.

The #if !IS_ENABLED(CONFIG_XPL_BUILD) changes could have been made in a 
separate commit I believe.

In any case, makes sense to me:

Reviewed-by: Quentin Schulz <quentin.schulz at cherry.de>

Would have liked a link to 
https://lore.kernel.org/u-boot/20250112223252.179123-1-marek.vasut+renesas@mailbox.org/ 
to explain why the Makefile cannot be empty in the commit log, but fine 
like it is.

Thanks!
Quentin


More information about the U-Boot mailing list