Skip to content

Fixes for STM32H5 demo. Fixes MQTT broker and improrves testing/docs. Expands CI test#73

Open
dgarske wants to merge 4 commits intowolfSSL:masterfrom
dgarske:stm32h5_demo2
Open

Fixes for STM32H5 demo. Fixes MQTT broker and improrves testing/docs. Expands CI test#73
dgarske wants to merge 4 commits intowolfSSL:masterfrom
dgarske:stm32h5_demo2

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Mar 6, 2026

No description provided.

@dgarske dgarske self-assigned this Mar 6, 2026
Copilot AI review requested due to automatic review settings March 6, 2026 18:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the STM32H563 demo to better support the wolfMQTT broker on bare-metal (wolfIP TLS + UART logging), expands documentation for broker usage, and adds a fuller CI job that boots the firmware in m33mu and integration-tests multiple services.

Changes:

  • Configure wolfMQTT broker to use wolfIP-provided TLS context and route broker logs to UART via a custom PRINTF.
  • Add wolfmqtt_log() UART printf-style logger for WBLOG/broker logging.
  • Expand STM32H563 CI to build and integration-test echo/HTTPS/TLS-echo/MQTT/SSH in emulation.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/port/stm32h563/user_settings.h Enables broker custom net/TLS integration and custom UART logging macros; raises broker log level.
src/port/stm32h563/main.c Adds wolfmqtt_log() implementation using vsnprintf + UART output.
src/port/stm32h563/README.md Updates build/flash instructions and adds detailed MQTT broker usage/testing docs.
.github/workflows/stm32h563-m33mu.yml Adds a “full” CI job that emulates the firmware and performs network service checks incl. MQTT.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@dgarske dgarske assigned danielinux and unassigned dgarske Mar 7, 2026
@dgarske dgarske requested a review from danielinux March 7, 2026 00:59
@dgarske dgarske assigned dgarske and unassigned danielinux Mar 7, 2026
# ---------------------------------------------------------------------------
# 5) MQTT Broker
# ---------------------------------------------------------------------------
banner "5. MQTT Broker (Port 8883) - TLS 1.3"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use wolfMQTT

}
trap cleanup EXIT

sudo modprobe tun
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this breaks the test

runs-on: ubuntu-latest
timeout-minutes: 30
container:
image: ghcr.io/danielinux/m33mu-ci:1.5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.6 is the working version

}
trap cleanup EXIT

sudo modprobe tun
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no moprobe in container: this will break the test

Copilot AI review requested due to automatic review settings March 8, 2026 00:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines +123 to +130
- name: Clone wolfSSL, wolfSSH, wolfMQTT (pinned to stable tags)
run: |
set -euo pipefail
cd ..
git clone --depth 1 https://github.com/wolfSSL/wolfssl.git
git clone --depth 1 https://github.com/wolfSSL/wolfssh.git
git clone --depth 1 https://github.com/wolfSSL/wolfmqtt.git

Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step title says the wolfSSL/wolfSSH/wolfMQTT clones are “pinned to stable tags”, but the commands clone default branches without a tag/commit checkout. This makes CI non-reproducible and can introduce breakage from upstream changes; consider checking out explicit tags or specific commits (or updating the step description to match reality).

Copilot uses AI. Check for mistakes.
echo "=== Test 4: MQTT Broker ==="
sleep 5 # allow recovery from TLS echo session
# Extract cert from certs.h for mosquitto
sed -n '/server_cert_pem\[\]/,/^";$/p' src/port/certs.h \
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cert extraction pipeline likely captures more than just the certificate because certs.h does not contain a line matching ^";$/ (the closing line is of the form "-----END CERTIFICATE-----\\n";). As written, the range can run to EOF and include the embedded private key in /tmp/wolfip_cert.pem, which is both unnecessary and may break --cafile parsing. Consider tightening the extraction to stop at the end-certificate line (or using a more direct grep/sed that only emits the CERTIFICATE PEM block).

Suggested change
sed -n '/server_cert_pem\[\]/,/^";$/p' src/port/certs.h \
sed -n '/server_cert_pem\[\]/,/^"-----END CERTIFICATE-----\\\\n";$/p' src/port/certs.h \

Copilot uses AI. Check for mistakes.
BOARD_IP="${1:-192.168.12.11}"

# Validate BOARD_IP to block shell metacharacter injection via eval
if ! [[ "$BOARD_IP" =~ ^[A-Za-z0-9._-]+$ ]]; then
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BOARD_IP regex allows values starting with -, which can be interpreted as options by commands like ping, nc, and ssh (option injection). Consider rejecting a leading hyphen (e.g., [[ $BOARD_IP != -* ]]) and/or using -- before the host argument where supported.

Suggested change
if ! [[ "$BOARD_IP" =~ ^[A-Za-z0-9._-]+$ ]]; then
if [[ "$BOARD_IP" == -* ]] || ! [[ "$BOARD_IP" =~ ^[A-Za-z0-9._-]+$ ]]; then

Copilot uses AI. Check for mistakes.
run_cmd() {
cmd_show "$1"
echo ""
eval "$1" 2>&1 | sed 's/^/ /'
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_cmd executes its argument via eval, which is unnecessary for the fixed command patterns used in this script and expands the attack surface if validation ever regresses. Prefer executing commands directly (or using a bash array for argv) so ${BOARD_IP} stays a single, safely-quoted argument.

Suggested change
eval "$1" 2>&1 | sed 's/^/ /'
bash -c "$1" 2>&1 | sed 's/^/ /'

Copilot uses AI. Check for mistakes.
Comment on lines +412 to +418
va_start(ap, fmt);
n = vsnprintf(buf, sizeof(buf), fmt, ap);
va_end(ap);
uart_puts(buf);
if (n >= (int)sizeof(buf))
uart_puts("...[truncated]\n");
}
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vsnprintf can return a negative value on encoding error, in which case the contents of buf are unspecified. Consider handling n < 0 explicitly (e.g., emit a fallback message and return) before calling uart_puts(buf).

Copilot uses AI. Check for mistakes.
Comment on lines +47 to 52
* wolfIP's internal DHCP state machine only retries for ~4 seconds
* (DHCP_DISCOVER_RETRIES=1 x 2s timeout). After that it sets state to
* DHCP_OFF and the UDP socket stops accepting unicast DHCP responses
* (because DHCP_IS_RUNNING becomes false). We re-init periodically to
* keep trying, but must space re-inits apart to avoid socket churn
* (close/reopen loses in-flight responses). */
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this port, the DHCP timing comments/values assume DHCP_DISCOVER_RETRIES=1, but src/port/va416xx/config.h does not override DHCP_DISCOVER_RETRIES/DHCP_REQUEST_RETRIES, so the wolfIP defaults (3) still apply. Either define these retry macros for VA416xx when DHCP is enabled, or update the timing comments/timeout constants to match the actual retry behavior.

Suggested change
* wolfIP's internal DHCP state machine only retries for ~4 seconds
* (DHCP_DISCOVER_RETRIES=1 x 2s timeout). After that it sets state to
* DHCP_OFF and the UDP socket stops accepting unicast DHCP responses
* (because DHCP_IS_RUNNING becomes false). We re-init periodically to
* keep trying, but must space re-inits apart to avoid socket churn
* (close/reopen loses in-flight responses). */
* wolfIP's internal DHCP state machine retries for a finite period based
* on DHCP_DISCOVER_RETRIES and DHCP_REQUEST_RETRIES (wolfIP defaults are 3).
* After the stack gives up it sets state to DHCP_OFF and the UDP socket
* stops accepting unicast DHCP responses (because DHCP_IS_RUNNING becomes
* false). We re-init periodically to keep trying, but must space re-inits
* far enough apart to avoid socket churn (close/reopen loses in-flight
* responses) and to ensure the previous DHCP attempt has fully timed out. */

Copilot uses AI. Check for mistakes.

# Library paths - default to sibling directories (clone alongside pattern)
WOLFSSL_ROOT ?= $(ROOT)/../wolfssl
WOLFSSL_ROOT ?= $(ROOT)/../wolfssl-alt
Copy link

Copilot AI Mar 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WOLFSSL_ROOT now defaults to $(ROOT)/../wolfssl-alt, but the README/workflows (and the other STM32 port Makefiles) reference cloning wolfssl into ../wolfssl. Unless wolfssl-alt is guaranteed to exist for contributors, this default will break the common build path; consider reverting the default to ../wolfssl (and documenting any alternative fork via an opt-in override).

Suggested change
WOLFSSL_ROOT ?= $(ROOT)/../wolfssl-alt
WOLFSSL_ROOT ?= $(ROOT)/../wolfssl

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants