Skip to contentSkip to conversation

package/swupdate: workaround runtime update failure

PATCH In review Giulio Benetti 2 participants 4 messages Nov 23, 2023 – Nov 29, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/swupdate: workaround runtime update failure

From: Giulio Benetti <[email protected]>

If SWUpdate is built using -Os optimization it will fail to update using Mongoose webserver randomly and always while using option installed-directly in .swu file generation. So let's workaround the bug by building with -O3.

Reported upstream:
https://groups.google.com/g/swupdate/c/oHMihNw8ZHA

---
 package/swupdate/swupdate.mk | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
package/swupdate/swupdate.mk +10 -1
index ea4a5a62e5..7801be07ce 100644
@@ -217,10 +217,19 @@ endif
 SWUPDATE_KCONFIG_FILE = $(call qstrip,$(BR2_PACKAGE_SWUPDATE_CONFIG))
 SWUPDATE_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
 
+SWUPDATE_CFLAGS = $(TARGET_CFLAGS)
+
+# Workaround update failure showing up with -Os
+# Reported here:
+# https://groups.google.com/g/swupdate/c/oHMihNw8ZHA
+ifeq ($(BR2_OPTIMIZE_S),y)
+SWUPDATE_CFLAGS += -O3
+endif
+
 SWUPDATE_MAKE_OPTS = \
 	SWU_VER="$(SWUPDATE_VERSION) (Buildroot $(BR2_VERSION_FULL))" \
 	CROSS_COMPILE="$(TARGET_CROSS)" \
-	CONFIG_EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+	CONFIG_EXTRA_CFLAGS="$(SWUPDATE_CFLAGS)" \
 	CONFIG_EXTRA_LDFLAGS="$(TARGET_LDFLAGS)"
 
 define SWUPDATE_KCONFIG_FIXUP_CMDS
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

package/swupdate/swupdate.mk endif · line 227

Quoted 8 lines · On Thu, 23 Nov 2023 18:39:57 +0100 Giulio Benetti…
package/swupdate/swupdate.mk +8 -0
+SWUPDATE_CFLAGS = $(TARGET_CFLAGS)
+
+# Workaround update failure showing up with -Os
+# Reported here:
+# https://groups.google.com/g/swupdate/c/oHMihNw8ZHA
+ifeq ($(BR2_OPTIMIZE_S),y)
+SWUPDATE_CFLAGS += -O3
+endif

This looks really horrible to me. Is there a compiler bug? Or a bug in the swupdate code base, such as some undefined behavior that causes an incorrect behavior when built -Os, but not -O3 ?

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Thomas,

Quoted 13 lines · Thomas Petazzoni

package/swupdate/swupdate.mk endif · line 227

Quoted 8 lines · On Thu, 23 Nov 2023 18:39:57 +0100 Giulio Benetti…
package/swupdate/swupdate.mk +8 -0
+SWUPDATE_CFLAGS = $(TARGET_CFLAGS)
+
+# Workaround update failure showing up with -Os
+# Reported here:
+# https://groups.google.com/g/swupdate/c/oHMihNw8ZHA
+ifeq ($(BR2_OPTIMIZE_S),y)
+SWUPDATE_CFLAGS += -O3
+endif

This looks really horrible to me.

You're right,

Quoted 3 lines

Is there a compiler bug? Or a bug in
the swupdate code base, such as some undefined behavior that causes an incorrect behavior when built -Os, but not -O3 ?

An undefined behavior showing up when built with -Os, but I'm currently trying to work it out and also to give a test case to SWUpdate Maintainer using qemu-arm.

So I think it's better I get to the root cause, I fix it and later provide a local patch to fix the problem.

I've already set the patch as Rejected on Patchwork, sorry for the noise.

Best regards

Signature · 2 lines
Giulio Benetti
CEO&CTO@Benetti Engineering sas
Quoted 1 line

Thomas

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Hello Giulio,

Quoted 10 lines · On Sat, 25 Nov 2023 01:24:45 +0100 Giulio Benetti…
Quoted 3 lines

Is there a compiler bug? Or a bug in
the swupdate code base, such as some undefined behavior that causes an incorrect behavior when built -Os, but not -O3 ?

An undefined behavior showing up when built with -Os, but I'm currently trying to work it out and also to give a test case to SWUpdate Maintainer using qemu-arm.

So I think it's better I get to the root cause, I fix it and later provide a local patch to fix the problem.

Sounds good, thanks for the effort.

Quoted 2 lines

I've already set the patch as Rejected on Patchwork, sorry for the noise.

No worries at all!

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot