Hi!

Almost an year ago I submitted a few patches for
u-boot-sam460ex code so it can be built by a
current gcc:
https://lists.nongnu.org/archive/html/qemu-devel/2025-01/msg00767.html

Here's another try.  Some of the old issues are
now gone, some remains, and some new emerged.

The below set allows me to build u-boot-sam460ex
code with gcc-15.

Some bugs are rather harsh and has been there for
a long time (like multiple definition of fbi symbol -
the file has been moved to a different dir, but the
prob remains - it is really a bad code).

Some are harsh but new (the reuse of `failed' variable -
any compiler, even ancient gcc4, should've catched it).

And some are due to too old code (supporting only gcc4).

FWIW.

Thanks,

/mjt
From: Michael Tokarev <[email protected]>
Date: Sat, 03 Aug 2024 11:18:58 +0300
Subject: u-boot-sam460ex: build fixes
Forwarded: https://lists.nongnu.org/archive/html/qemu-devel/2025-01/msg00767.html

Fixes or works around numerous build issues.

Most are due to new defaults in gcc (in debian), like
 -Werror=implicit-function-declarations (there are a lot of missing decls)
 -Werror=incompatible-pointer-types (function types mismatches)
 -Werror=int-conversion (free int <=> pointer conversion)

Bug-Debian: https://bugs.debian.org/1075428
Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/roms/u-boot-sam460ex/config.mk b/roms/u-boot-sam460ex/config.mk
--- a/roms/u-boot-sam460ex/config.mk
+++ b/roms/u-boot-sam460ex/config.mk
@@ -193,2 +193,7 @@ CFLAGS += $(call cc-option,-fno-stack-protector)
 
+# this u-boot is an old bad code
+CFLAGS += $(call cc-option,-Wno-error=implicit-function-declaration)
+CFLAGS += $(call cc-option,-Wno-error=incompatible-pointer-types)
+CFLAGS += $(call cc-option,-Wno-error=int-conversion)
+
 # $(CPPFLAGS) sets -g, which causes gcc to pass a suitable -g<format>
From: Michael Tokarev <[email protected]>
Subject: u-boot-sam460ex: fix "failed" puts
Date: Wed, 19 Nov 2025 20:47:44 +0300

There's a global char *failed="failed" variable,
which is used below the code in question like
 puts(failed).
However, the code in question, #ifdef'ed, uses
the variable of the same name but with different
type (u8).  Which results in a failed compilation.
Rename the local variable `failed' to `ret'.

(Actually, there's no need to store the result of
the function call in a variable, since it is only
used once anyway).

Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/roms/u-boot-sam460ex/arch/powerpc/lib/board.c b/roms/u-boot-sam460ex/arch/powerpc/lib/board.c
--- a/roms/u-boot-sam460ex/arch/powerpc/lib/board.c
+++ b/roms/u-boot-sam460ex/arch/powerpc/lib/board.c
@@ -202,5 +202,5 @@ static int init_func_ram (void)
 
 #ifdef CONFIG_SAM460EX
-	u8 failed = 0;
+	u8 ret;
 	char s[32] = { 0 };
 
@@ -208,7 +208,7 @@ static int init_func_ram (void)
 	gd->flags |= atoi(s) << 16;
 
-	failed = i2c_reg_read(CONFIG_SYS_I2C_RTC_ADDR, 0xe);
+	ret = i2c_reg_read(CONFIG_SYS_I2C_RTC_ADDR, 0xe);
 
-	if (failed >= 1) // there was an error - disable ddr2_boost
+	if (ret >= 1) // there was an error - disable ddr2_boost
 	{
 		gd->flags &= ~(GD_FLG_DDR2_BOOST_READ|GD_FLG_DDR2_BOOST_WRITE);
From: Michael Tokarev <[email protected]>
Subject: u-boot-sam460ex: fbi fix
Date: Sat Apr 1 17:34:09 2023 +0300
Forwarded: https://lists.nongnu.org/archive/html/qemu-devel/2025-01/msg00767.html

Fix the missing extern in a variable declaration,
resulting in this variable being repeated each time
this header is included, so the link with modern gcc
fails.

Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/roms/u-boot-sam460ex/drivers/bios_emulator/vesa.h b/roms/u-boot-sam460ex/drivers/bios_emulator/vesa.h
--- a/roms/u-boot-sam460ex/drivers/bios_emulator/vesa.h
+++ b/roms/u-boot-sam460ex/drivers/bios_emulator/vesa.h
@@ -6,5 +6,5 @@ extern void *set_vesa_mode(int mode);
 extern void *old_set_vesa_mode(int mode);
 
-struct FrameBufferInfo
+extern struct FrameBufferInfo
 {
         void *BaseAddress;
From: Michael Tokarev <[email protected]>
Subject: u-boot-sam460ex: remove compiler-gccN.h #include
Date: Wed, 19 Nov 2025 23:30:38 +0300

include/linux/compiler*.h are taken from old linux, and
only supports gcc4.  However, the gcc-version-dependent
definitions in there aren't actually used in the code,
except of uninitialized_var macro - which is defined in
the fallback case to the same value.  So there's no
point in including the gcc-version-specific header,
which fails when building this code with a more recent
version of gcc.

This patch removes just the #include statement
(and the helper definitions), but not compiler-gcc4.h
header itself.  This makes the change small, and allows
compilation of u-boot-sam460ex code by something more
recent than ancient gcc.

Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/roms/u-boot-sam460ex/include/linux/compiler-gcc.h b/roms/u-boot-sam460ex/include/linux/compiler-gcc.h
--- a/roms/u-boot-sam460ex/include/linux/compiler-gcc.h
+++ b/roms/u-boot-sam460ex/include/linux/compiler-gcc.h
@@ -81,7 +81,2 @@
 #define __maybe_unused			__attribute__((unused))
 #define __always_unused			__attribute__((unused))
-
-#define __gcc_header(x) #x
-#define _gcc_header(x) __gcc_header(linux/compiler-gcc##x.h)
-#define gcc_header(x) _gcc_header(x)
-#include gcc_header(__GNUC__)
From: Michael Tokarev <[email protected]>
Subject: u-boot-sam460ex: remove obsolete -mstring gcc option
Date: Sun Oct 22 23:35:45 2023 +0300
Forwarded: https://lists.nongnu.org/archive/html/qemu-devel/2025-01/msg00767.html

Modern gcc complains about it.

Signed-off-by: Michael Tokarev <[email protected]>

diff --git a/roms/u-boot-sam460ex/arch/powerpc/cpu/ppc4xx/config.mk b/roms/u-boot-sam460ex/arch/powerpc/cpu/ppc4xx/config.mk
index 8f47c9b728..cf4414cee6 100644
--- a/roms/u-boot-sam460ex/arch/powerpc/cpu/ppc4xx/config.mk
+++ b/roms/u-boot-sam460ex/arch/powerpc/cpu/ppc4xx/config.mk
@@ -24,3 +24,3 @@
 PLATFORM_RELFLAGS += -fPIC -meabi
-PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -mstring -msoft-float
+PLATFORM_CPPFLAGS += -DCONFIG_4xx -ffixed-r2 -msoft-float
 
Subject: roms/u-boot-sam460ex: support c23 (bool)
From: Michael Tokarev <[email protected]>
Date: Mon, 25 Aug 2025 22:34:21 +0300
Forwarded: no
Bug-Debian: https://bugs.debian.org/1097693

In c23, bool, true and false are keywords,
don't try to (re)define them.  Instead,
include <stdbool.h>.

diff --git a/roms/u-boot-sam460ex/include/xyzModem.h b/roms/u-boot-sam460ex/include/xyzModem.h
--- a/roms/u-boot-sam460ex/include/xyzModem.h
+++ b/roms/u-boot-sam460ex/include/xyzModem.h
@@ -97,13 +97,7 @@ typedef struct {
 #endif
 } connection_info_t;
 
-#ifndef	BOOL_WAS_DEFINED
-#define BOOL_WAS_DEFINED
-typedef unsigned int bool;
-#endif
-
-#define false 0
-#define true 1
+#include <stdbool.h>
 
 #endif
 
diff --git a/roms/u-boot-sam460ex/board/ACube/menu/list.h b/roms/u-boot-sam460ex/board/ACube/menu/list.h
--- a/roms/u-boot-sam460ex/board/ACube/menu/list.h
+++ b/roms/u-boot-sam460ex/board/ACube/menu/list.h
@@ -3,14 +3,3 @@
 
-#ifndef bool_defined
-#define bool_defined
-typedef int bool;
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
+#include <stdbool.h>
 
diff --git a/roms/u-boot-sam460ex/board/ACube/menu/menu.h b/roms/u-boot-sam460ex/board/ACube/menu/menu.h
--- a/roms/u-boot-sam460ex/board/ACube/menu/menu.h
+++ b/roms/u-boot-sam460ex/board/ACube/menu/menu.h
@@ -29,14 +29,3 @@
 
-#ifndef bool_defined
-#define bool_defined
-typedef int bool;
-#endif
-
-#ifndef true
-#define true 1
-#endif
-
-#ifndef false
-#define false 0
-#endif
+#include <stdbool.h>
 

Reply via email to