From af21517eefebe2260fec4b706b132d8cf14d8d51 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 21 Aug 2026 10:09:49 +0200 Subject: [PATCH 1/3] netutils/paho_mqtt: fix package preparation and utilities The bundled patch still contains an MQTTPacket.h hunk for a bool typedef that no longer exists in Paho 1.3.15. Make and CMake both hide the resulting rejection, allowing a partially patched source tree to be compiled. Remove the stale hunk and make patch failures fatal. The Make context target also allows VersionInfo.h generation to race source extraction under parallel builds. Make the generated header depend on the extraction target so the input template is present first. The publisher and subscriber samples live below src/samples but include public headers from src. Add the Paho source include directory to the Make flags, matching the CMake targets, so CONFIG_UTILS_MQTT5 builds both utilities. Finally, define distclean independently of whether the downloaded tree exists when Make parses the file. Remove package-owned archives and sources while preserving a developer Git checkout, and ignore those downloaded paths. Signed-off-by: raiden00pl Assisted-by: OpenAI Codex:gpt-5 --- netutils/paho_mqtt/.gitignore | 2 ++ netutils/paho_mqtt/CMakeLists.txt | 4 ++-- netutils/paho_mqtt/Makefile | 19 +++++++++++-------- netutils/paho_mqtt/paho_mqtt_01.patch | 18 +----------------- 4 files changed, 16 insertions(+), 27 deletions(-) create mode 100644 netutils/paho_mqtt/.gitignore diff --git a/netutils/paho_mqtt/.gitignore b/netutils/paho_mqtt/.gitignore new file mode 100644 index 00000000000..29487dfe990 --- /dev/null +++ b/netutils/paho_mqtt/.gitignore @@ -0,0 +1,2 @@ +/paho_mqtt +/v*.zip diff --git a/netutils/paho_mqtt/CMakeLists.txt b/netutils/paho_mqtt/CMakeLists.txt index 0139fb8e84c..f76d20de4ae 100644 --- a/netutils/paho_mqtt/CMakeLists.txt +++ b/netutils/paho_mqtt/CMakeLists.txt @@ -81,8 +81,8 @@ if(CONFIG_LIB_MQTT5) execute_process( COMMAND sh -c - "patch -p1 --forward --ignore-whitespace < ${CMAKE_CURRENT_LIST_DIR}/paho_mqtt_01.patch || true" - WORKING_DIRECTORY ${PAHO_MQTT_DIR}) + "patch -p1 --forward --ignore-whitespace < ${CMAKE_CURRENT_LIST_DIR}/paho_mqtt_01.patch" + WORKING_DIRECTORY ${PAHO_MQTT_DIR} COMMAND_ERROR_IS_FATAL ANY) message("paho_mqtt_01 patching done") endif() diff --git a/netutils/paho_mqtt/Makefile b/netutils/paho_mqtt/Makefile index 21c9d904f5f..325a68f858b 100644 --- a/netutils/paho_mqtt/Makefile +++ b/netutils/paho_mqtt/Makefile @@ -34,6 +34,8 @@ PAHO_MQTT_UNPACK = paho_mqtt SRCDIR = $(APPDIR)/netutils/paho_mqtt/$(PAHO_MQTT_UNPACK)/src +CFLAGS += $(INCDIR_PREFIX)$(SRCDIR) + ifeq ($(CONFIG_LIB_MQTT5), y) # Check if paho_mqtt directory exists, if not download and extract @@ -49,15 +51,10 @@ $(PAHO_MQTT_UNPACK): $(PAHO_MQTT_ZIP) $(Q) rm -f $(PAHO_MQTT_ZIP) $(Q) if [ -f paho_mqtt_01.patch ]; then \ echo "Applying paho_mqtt_01 patch to $(PAHO_MQTT_UNPACK)"; \ - cd $(PAHO_MQTT_UNPACK) && patch -p1 --forward --ignore-whitespace < ../paho_mqtt_01.patch || true; \ + cd $(PAHO_MQTT_UNPACK) && patch -p1 --forward --ignore-whitespace < ../paho_mqtt_01.patch; \ fi $(Q) touch $(PAHO_MQTT_UNPACK) -context:: $(PAHO_MQTT_UNPACK) - -distclean:: - $(call DELFILE, $(PAHO_MQTT_ZIP)) - $(call DELDIR, $(PAHO_MQTT_UNPACK)) endif ifeq ($(CONFIG_OPENSSL_MBEDTLS_WRAPPER), y) @@ -80,8 +77,8 @@ MQTT5_VERSION = $(SRCDIR)/VersionInfo.h SED_COMMANDS = $(foreach var,$(VARS),-e 's/@$(var)@/$($(var))/g') -$(MQTT5_VERSION): $(SRCDIR)/VersionInfo.h.in - sed $(SED_COMMANDS) $< > $@ +$(MQTT5_VERSION): $(PAHO_MQTT_UNPACK) + sed $(SED_COMMANDS) $(SRCDIR)/VersionInfo.h.in > $@ context:: $(MQTT5_VERSION) @@ -108,4 +105,10 @@ endif endif +ifeq ($(wildcard $(PAHO_MQTT_UNPACK)/.git),) +distclean:: + $(call DELFILE, $(wildcard v*.zip)) + $(call DELDIR, $(PAHO_MQTT_UNPACK)) +endif + include $(APPDIR)/Application.mk diff --git a/netutils/paho_mqtt/paho_mqtt_01.patch b/netutils/paho_mqtt/paho_mqtt_01.patch index 67a1fccdf69..526f69ba450 100644 --- a/netutils/paho_mqtt/paho_mqtt_01.patch +++ b/netutils/paho_mqtt/paho_mqtt_01.patch @@ -6,7 +6,6 @@ Subject: [PATCH] paho_mqtt: Fix mqtt compile warning Signed-off-by: zhangshuai39 --- src/MQTTAsync.c | 2 +- - src/MQTTPacket.h | 2 ++ src/SHA1.c | 2 +- src/Socket.c | 16 +++++++++++++++- src/Socket.h | 1 + @@ -16,7 +15,7 @@ Signed-off-by: zhangshuai39 src/WebSocket.h | 2 +- src/samples/paho_c_pub.c | 29 ++++++++++++++++++----------- src/samples/paho_c_sub.c | 4 +++- - 11 files changed, 45 insertions(+), 18 deletions(-) + 10 files changed, 43 insertions(+), 18 deletions(-) diff --git a/src/MQTTAsync.c b/src/MQTTAsync.c index c548ae3..2487d69 100644 @@ -31,20 +30,6 @@ index c548ae3..2487d69 100644 { thread_id_type thread_id = Paho_thread_getid(); return thread_id == sendThread_id || thread_id == receiveThread_id; -diff --git a/src/MQTTPacket.h b/src/MQTTPacket.h -index fd384ae..c833d0c 100644 ---- a/src/MQTTPacket.h -+++ b/src/MQTTPacket.h -@@ -28,7 +28,9 @@ - #include "LinkedList.h" - #include "Clients.h" - -+#ifndef bool - typedef unsigned int bool; -+#endif - typedef void* (*pf)(int, unsigned char, char*, size_t); - - #include "MQTTProperties.h" diff --git a/src/SHA1.c b/src/SHA1.c index a1b2c3d..e4f5g6h 100644 --- a/src/SHA1.c @@ -311,4 +296,3 @@ index 85875c9..1fe18ce 100644 return EXIT_SUCCESS; -- 2.34.1 - From 5ac3c553e47025964c939a69390accf895c77632 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 21 Aug 2026 10:10:02 +0200 Subject: [PATCH 2/3] netutils/paho_mqtt: separate library worker stack size Add CONFIG_LIB_MQTT5_THREAD_STACKSIZE for threads created internally by Paho and use it in Thread.c. Keep CONFIG_UTILS_MQTT5_STACKSIZE scoped to the two utility application tasks. This permits S2OPC to enable MQTT through LIB_MQTT5 without also building unrelated command-line utilities. Signed-off-by: raiden00pl Assisted-by: OpenAI Codex:gpt-5 --- netutils/paho_mqtt/Kconfig | 7 +++++++ netutils/paho_mqtt/paho_mqtt_01.patch | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/netutils/paho_mqtt/Kconfig b/netutils/paho_mqtt/Kconfig index 5bd8cbf8aa6..454ed869dba 100644 --- a/netutils/paho_mqtt/Kconfig +++ b/netutils/paho_mqtt/Kconfig @@ -9,6 +9,13 @@ config LIB_MQTT5 ---help--- A library for accessing mqtt5 client services through C libraries calls in a simple manner. +config LIB_MQTT5_THREAD_STACKSIZE + int "MQTT library thread stack size" + default 16384 + depends on LIB_MQTT5 + ---help--- + Stack size used by threads created by the Paho MQTT library. + config UTILS_MQTT5 tristate "Enable mqtt5 tool" depends on LIB_MQTT5 diff --git a/netutils/paho_mqtt/paho_mqtt_01.patch b/netutils/paho_mqtt/paho_mqtt_01.patch index 526f69ba450..0702e5a84e6 100644 --- a/netutils/paho_mqtt/paho_mqtt_01.patch +++ b/netutils/paho_mqtt/paho_mqtt_01.patch @@ -122,7 +122,7 @@ index f4d43fb..52f810a 100644 #else pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); -+ pthread_attr_setstacksize(&attr, CONFIG_UTILS_MQTT5_STACKSIZE); ++ pthread_attr_setstacksize(&attr, CONFIG_LIB_MQTT5_THREAD_STACKSIZE); if (pthread_create(&thread, &attr, fn, parameter) != 0) thread = 0; pthread_attr_destroy(&attr); From e37223fb1d00f239f4c2f96c6ac0d77877b7d3b4 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Fri, 21 Aug 2026 10:10:18 +0200 Subject: [PATCH 3/3] netutils/paho_mqtt: configure embedded runtime mode Expose the upstream HIGH_PERFORMANCE mode through CONFIG_LIB_MQTT5_HIGH_PERFORMANCE and enable it by default. This keeps normal embedded builds lightweight while allowing developers to restore Paho heap and call-stack diagnostics when investigating library issues. Signed-off-by: raiden00pl Assisted-by: OpenAI Codex:gpt-5 --- netutils/paho_mqtt/CMakeLists.txt | 5 +++++ netutils/paho_mqtt/Kconfig | 9 +++++++++ netutils/paho_mqtt/Makefile | 5 +++++ 3 files changed, 19 insertions(+) diff --git a/netutils/paho_mqtt/CMakeLists.txt b/netutils/paho_mqtt/CMakeLists.txt index f76d20de4ae..a098c09937e 100644 --- a/netutils/paho_mqtt/CMakeLists.txt +++ b/netutils/paho_mqtt/CMakeLists.txt @@ -117,6 +117,11 @@ if(CONFIG_LIB_MQTT5) target_compile_options(mqtt5 PRIVATE ${MQTT5_FLAGS}) + if(CONFIG_LIB_MQTT5_HIGH_PERFORMANCE) + target_compile_definitions(mqtt5 PRIVATE HIGH_PERFORMANCE=1) + target_compile_options(mqtt5 PRIVATE -Wno-unused-but-set-variable) + endif() + if(CONFIG_UTILS_MQTT5) set(MQTT_PUB_FLAGS diff --git a/netutils/paho_mqtt/Kconfig b/netutils/paho_mqtt/Kconfig index 454ed869dba..48273c08ff2 100644 --- a/netutils/paho_mqtt/Kconfig +++ b/netutils/paho_mqtt/Kconfig @@ -16,6 +16,15 @@ config LIB_MQTT5_THREAD_STACKSIZE ---help--- Stack size used by threads created by the Paho MQTT library. +config LIB_MQTT5_HIGH_PERFORMANCE + bool "Enable Paho high-performance mode" + default y + depends on LIB_MQTT5 + ---help--- + Disable Paho heap-allocation tracking and function call-stack + tracing to reduce runtime and memory overhead. Disable this option + when debugging the Paho MQTT library. + config UTILS_MQTT5 tristate "Enable mqtt5 tool" depends on LIB_MQTT5 diff --git a/netutils/paho_mqtt/Makefile b/netutils/paho_mqtt/Makefile index 325a68f858b..5a9575824ea 100644 --- a/netutils/paho_mqtt/Makefile +++ b/netutils/paho_mqtt/Makefile @@ -38,6 +38,11 @@ CFLAGS += $(INCDIR_PREFIX)$(SRCDIR) ifeq ($(CONFIG_LIB_MQTT5), y) +ifeq ($(CONFIG_LIB_MQTT5_HIGH_PERFORMANCE),y) +CFLAGS += -DHIGH_PERFORMANCE=1 +CFLAGS += -Wno-unused-but-set-variable +endif + # Check if paho_mqtt directory exists, if not download and extract ifeq ($(wildcard $(PAHO_MQTT_UNPACK)/src),) $(PAHO_MQTT_ZIP):