Skip to content

Fix card.binary HIL test build on STM32 Arduino core 3.x - #256

Merged
haydenroche5 merged 6 commits into
masterfrom
hroche/fix-card-binary-serial-conflict
Sep 23, 2026
Merged

haydenroche5 merged 6 commits into
masterfrom
hroche/fix-card-binary-serial-conflict

Conversation

@haydenroche5

@haydenroche5 haydenroche5 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

This PR gets the note-c card.binary HIL tests job passing again, as it did before 2026-08-29. It had several separate problems.

  • Build: test/hitl/card.binary/platformio.ini uses platform = ststm32 with no version. Around 2026-09-05, CI started to use ststm32 20.0.0, which brings in STM32 Arduino core 3.0. Core 3.0 declares Serial2 and Serial3 itself, and it makes HardwareSerial an abstract class. The test's own Serial2/Serial3 objects then fail to compile.
  • Silent upload failure: GDB ran each flash step as an -ex command and ended with quit, so it exited 0 even when the connect or load failed. The job then failed later with a misleading Timed out waiting for test port.
  • Shared Notecard state: barcelona-notestation-1 is shared with the note-zephyr HIL tests. They leave a product UID on the Notecard that has no Notehub project. The Notecard then delays its connect attempts, so waitForNotecardConnected timed out before any test set the product.
  • Token leak: The workflow printed NOTEHUB_ACCESS_TOKEN and MD5SRV_TOKEN in plain text in every step's env: block.

Two related fixes live outside this repo:

  • A Zephyr image with power management blocked SWD flashing on the Swan. blues/notestation#140 fixes that by connecting under reset, and it shipped in notestation-v3.7.1.
  • The station's Notecard had no Wi-Fi antenna. That is now fixed at the site.

Changes

  • NotecardComms.h, NotecardComms.cpp:
    • Remove Serial2, which nothing used.
    • Rename Serial3 to notecardSerial, on the same pins (A5 RX, A4 TX).
    • Use Uart on core 3.x and HardwareSerial on core 2.x.
  • platformio.ini, new upload.gdb:
    • GDB runs the flash steps from a sourced file with -batch, so it stops at the first failed command and exits non-zero.
    • echo markers and compare-sections show in the log what was flashed.
    • 1>&2 puts GDB's output in the CI log, because pio test hides the upload command's stdout.
  • test_card_binary.cpp: waitForNotecardConnected sends the suite's hub.set (product and mode) before it waits. A product change also clears the Notecard's connect delay.
  • notecard-binary-tests.yml: Send ::add-mask:: for both tokens before they go into GITHUB_ENV.

Test plan

  • Local builds pass on core 3.0 (ststm32 20.0.0) and core 2.12 (ststm32 19.7.1). astyle 3.1 reports no changes.
  • With an unreachable GDB server, PlatformIO fails the upload with [upload] Error 1 and shows GDB's error.
  • HIL on barcelona-notestation-1 with notestation-v3.7.1 passes 14/14 (run 35827541275). The log shows load size 184036 and matched for all 7 sections. The run started with the note-zephyr product and the Notecard in its connect delay, and waitForNotecardConnected passed.
  • The HIL logs show *** for both tokens. No ory_at_ values appear.

Notes

  • This PR does not pin the platform version.
  • Known issue, not fixed here: a build with -DNOTECARD_DEBUG_STLINK fails to link.
  • Architecture docs and source-research/: no update needed. The change touches only HIL test code and the HIL workflow. The indexed symbols in NotecardComms.h and NotecardComms.cpp keep their line numbers.
  • Old run logs still show the tokens in plain text.

🤖 Generated with Claude Code

haydenroche5 and others added 3 commits September 23, 2026 03:13
- PlatformIO's ststm32 20.0.0 platform brings in STM32 Arduino core 3.0.
  The test's platformio.ini does not pin the platform, so CI picked it up.
- Core 3.x declares Serial2 and Serial3 itself. The test's own Serial2 and
  Serial3 objects then fail with "conflicting declaration".
- Core 3.x also makes HardwareSerial an abstract class. Uart is now the
  concrete UART class.
- Remove Serial2. No code uses it.
- Rename Serial3 to notecardSerial. It keeps the same pins (A5 RX, A4 TX).
- Pick Uart on core 3.x and HardwareSerial on core 2.x, so the test builds
  on both cores.
- Checked with local builds on core 3.0 (ststm32 20.0.0) and core 2.12
  (ststm32 19.7.1).

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The workflow writes NOTEHUB_ACCESS_TOKEN and MD5SRV_TOKEN to GITHUB_ENV.
  GitHub does not mask values that a step writes there. It printed both
  tokens in plain text in the env block of every later step.
- The "Notehub HTTP route request" log line also printed MD5SRV_TOKEN.
- Send ::add-mask:: for each token before the step writes it to
  GITHUB_ENV. GitHub then shows *** in place of the token in all later
  output.

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- The upload command passed each GDB command with -ex and ended with
  "quit". GDB runs later -ex commands after one fails, and "quit" exits 0.
  A failed connect or load looked like a successful upload.
- The job then waited for the Swan's USB port and failed with a
  misleading "Timed out waiting for test port" error.
- Move "monitor reset halt", "load", and "monitor reset" into upload.gdb
  and run GDB with -batch. GDB stops the file at the first failed command
  and exits non-zero, so PlatformIO fails the upload step.
- Checked locally: with an unreachable GDB server, PlatformIO fails with
  "[upload] Error 1" and GDB's error message.

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@haydenroche5 haydenroche5 self-assigned this Sep 23, 2026
haydenroche5 and others added 3 commits September 23, 2026 05:50
- GDB prints load progress only for interactive commands, so the CI log
  never showed whether the firmware load happened.
- Add echo markers and compare-sections to upload.gdb. compare-sections
  reads the flash back and prints matched or MIS-MATCHED for each section.
- compare-sections reports a mismatch as a warning, so it does not fail
  the upload. A failed connect, reset, or load still does.

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- "pio test" shows the upload command's stderr but hides its stdout. GDB
  writes echo and compare-sections output to stdout, so the markers from
  the last commit did not show in the CI log.
- Send GDB's stdout to stderr with 1>&2. PlatformIO runs the upload
  command through a shell, and GDB's exit status still reaches it.
- Checked locally with a stand-in for GDB_CMD: its stdout now shows, and a
  non-zero exit still fails the upload with "[upload] Error".

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- barcelona-notestation-1 is shared with note-zephyr HIL tests. They leave
  the Notecard with product com.blues.note-zephyr.hil, which has no
  Notehub project, so the Notecard delays its connect attempts
  ("connect delayed", product-noexist) for several minutes.
- The waitForNotecardConnected test ran before any test sent hub.set, so
  it waited 5 minutes on the old product and failed. The next test's
  hub.set cleared the delay, and the Notecard connected 13 s later.
- Send the suite's hub.set (product and continuous mode) at the start of
  waitForNotecardConnected. A product change also takes the Notecard out
  of the penalty box.

This commit message was written by Claude, an AI agent.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@haydenroche5
haydenroche5 merged commit c381efd into master Sep 23, 2026
16 checks passed
@haydenroche5
haydenroche5 deleted the hroche/fix-card-binary-serial-conflict branch September 23, 2026 13:51
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.

2 participants