qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* A few more patches for u-boot-sam460ex (based on 10.2.0-rc1)
@ 2025-11-19 20:42 Michael Tokarev
  2025-11-22 12:14 ` BALATON Zoltan
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Tokarev @ 2025-11-19 20:42 UTC (permalink / raw)
  To: QEMU Development, BALATON Zoltan

[-- Attachment #1: Type: text/plain, Size: 737 bytes --]

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

[-- Attachment #2: u-boot-sam460ex-build.patch --]
[-- Type: text/x-patch, Size: 1110 bytes --]

From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>

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>

[-- Attachment #3: u-boot-sam460ex-failed.patch --]
[-- Type: text/x-patch, Size: 1319 bytes --]

From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>

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);

[-- Attachment #4: u-boot-sam460ex-fbi.patch --]
[-- Type: text/x-patch, Size: 816 bytes --]

From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>

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;

[-- Attachment #5: u-boot-sam460ex-gcc.patch --]
[-- Type: text/x-patch, Size: 1328 bytes --]

From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>

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__)

[-- Attachment #6: u-boot-sam460ex-mstring.patch --]
[-- Type: text/x-patch, Size: 767 bytes --]

From: Michael Tokarev <mjt@tls.msk.ru>
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 <mjt@tls.msk.ru>

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
 

[-- Attachment #7: u-boot-sam460ex-stdc23.patch --]
[-- Type: text/x-patch, Size: 1511 bytes --]

Subject: roms/u-boot-sam460ex: support c23 (bool)
From: Michael Tokarev <mjt@tls.msk.ru>
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>
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: A few more patches for u-boot-sam460ex (based on 10.2.0-rc1)
  2025-11-19 20:42 A few more patches for u-boot-sam460ex (based on 10.2.0-rc1) Michael Tokarev
@ 2025-11-22 12:14 ` BALATON Zoltan
  0 siblings, 0 replies; 2+ messages in thread
From: BALATON Zoltan @ 2025-11-22 12:14 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: QEMU Development

Hello,

On Wed, 19 Nov 2025, Michael Tokarev wrote:
> 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.

Thanks but maybe try upstream at https://acube-systems.biz/ as they are 
still maintaining this U-Boot version and I don't want to diverge too much 
from it so it's easier to update it when a new version comes from 
upstream. (There's already a version newer than the one we have in QEMU 
but that did not work with the emulation for some reason and I did not 
have time to find out why so went with the last version that works as that 
already has the USB fixes we needed and newer version does not have 
anything we need yet but maybe in the future we'll want to update 
further.)

> 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).

The code may be bad and also based on an old U-Boot version that did not 
have support for newer compilers but apparently it works on real boards 
which we try to emulate so I'd like to keep the firmware close to that one 
including bugs so it works the same as the real machine.

For things fixed in newer U-Boot versions it may be better to cherry-pick 
from there and for things that broke because of -Werror settings in Debian 
different from gcc defaults it makes sense to carry patches for that in 
Debian or merge upstream and not just in QEMU.

Regards,
BALATON Zoltan


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-22 12:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-19 20:42 A few more patches for u-boot-sam460ex (based on 10.2.0-rc1) Michael Tokarev
2025-11-22 12:14 ` BALATON Zoltan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).