Support for MQTT Broker persist on STM32H5 demo#129
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an STM32H563-specific persistence backend for the wolfMQTT broker, storing broker state in a reserved internal-flash KV region and wiring it into the demo build and broker initialization flow.
Changes:
- Enable broker persistence (and encrypted-at-rest mode) via
user_settings.h, with reduced persisted-session and offline-queue limits sized for the flash KV region. - Reserve the top 32KB of internal flash in the STM32H563 linker script so firmware code cannot be placed in the persistence region.
- Add and build a new STM32H5 internal-flash KV backend (
mqtt_broker_persist_flash.c/.h) and install its hooks beforeMqttBroker_Start().
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/port/stm32h563/user_settings.h | Enables broker persistence/encryption and sets persistence-related broker limits. |
| src/port/stm32h563/target.ld | Shrinks the FLASH region to reserve 32KB for the persistence KV store. |
| src/port/stm32h563/mqtt_broker.c | Initializes and installs persistence hooks before broker start. |
| src/port/stm32h563/mqtt_broker_persist_flash.h | Declares the STM32H5 flash persistence init API and hook setup. |
| src/port/stm32h563/mqtt_broker_persist_flash.c | Implements a log-structured KV store over reserved internal flash with optional encryption key hook. |
| src/port/stm32h563/Makefile | Builds the new backend and links in the generic broker persistence codec. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b37393f to
820586b
Compare
820586b to
c664ba2
Compare
c664ba2 to
f661e14
Compare
danielinux
left a comment
There was a problem hiding this comment.
Please double check the KVF_MAX_BLOB value
| #define KVF_TOMB_MARK 0x00U | ||
|
|
||
| #define KVF_MAX_KEY 256U /* per hooks API contract */ | ||
| #define KVF_MAX_BLOB 1280U /* >= largest GCM-wrapped record */ |
There was a problem hiding this comment.
The wolfMQTT codec's BrokerPersist_PutSubs (verified against wolfMQTT master src/mqtt_broker_persist.c) snapshots ALL of a client's subscriptions into a single record: body = 2 + count*(1+1+2+filter_len). With this port's BROKER_MAX_SUBS=16 (user_settings.h) and the default BROKER_MAX_TOPIC_LEN=128 (filters up to 127 bytes), the worst-case body is 2 + 16*131 = 2098 bytes. The encrypted blob adds WMQB_HDR_LEN(12) + GCM nonce(12) + tag(16) = 40 bytes, giving ~2138 byte
No description provided.