Skip to content

Run the Teensy tests from one test image, and give the firmware its clock and FreeRTOS settings - #19

Merged
AnakinRaW merged 7 commits into
mainfrom
claude/teensy-test-suite-9199da
Nov 16, 2026
Merged

AnakinRaW merged 7 commits into
mainfrom
claude/teensy-test-suite-9199da

Conversation

@AnakinRaW

Copy link
Copy Markdown
Owner

Summary

Every Teensy test of docs/firmware/testing.md now lives in one test image, firmware/tests/teensy, which is flashed once. The runner firmware/tools/teensy-tests.py picks the tests over USB serial, gives each one its time limit, and reads the result lines back. It restarts the Teensy before each program, detects a crash through PJRC's CrashReport or a lost port, and exits with 1 on a failure, a hang or a crash. A quick run is the default. --soak takes the durations testing.md states, and --bench adds the tests that need a person at the bench.

The image holds the programs driver-tick, psram, clock, lighting, servo, every-driver and start-up. The image runs them in a FreeRTOS task, as the firmware runs its main loop.

Writing the start-up test showed that no build included the firmware's four FreeRTOS settings. malloc() therefore took its memory from RAM1 instead of RAM2. The settings now stand in firmware/include/freertos_config_override.h, and the firmware, the test image and the bench programs put that folder on the include path through build_flags.

Commits

  • Warnings as errors. -Wall -Wextra -Werror reaches src and firmware/lib in both environments. FastLED 3.10.9 turns warnings off twice and back on once, so every #include <FastLED.h> stands between a diagnostic push and pop.
  • Build cache. The firmware, the test image and the bench programs share one build_cache_dir. It serves an object file only to the build folder that compiled it, and worktrees share that folder.
  • Test image and runner. The old projects of driver-tick, lighting, servo and every-driver moved into the image. quiet-libraries.py resolves lib_dir against the project, so a project below the root counts firmware/lib as its own.
  • FreeRTOS settings. The header moved from the gist to firmware/include. The bench programs' wrapper headers are gone.
  • Clock. firmware/lib/clock holds nowUs() on GPT2 with elapsedUs(), elapsedMs(), before() and startClock(). clock.wrap checks the wrap on the computer.
  • Firmware start. The main task gets the rest of RAM1 as a static stack, with an MPU guard below the interrupts' stack. It restores the priorities FreeRTOS resets, and its main loop blinks the LED by nowUs() without waiting.
  • New image tests. psram.found, psram.patterns, clock.rate and start-up.heap.

Test plan

  • python firmware/tools/teensy-tests.py --upload: 12 passed, 0 failed, 4 skipped in 29.2 s. The servo tests skip without the wire from pin 0 to pin 1.
  • clock.rate in a soak run over 60 s passes.
  • A broken assert makes the runner exit with 1. A probe program proved restart and resume, crash detection and the hang timeout.
  • pio test -e computer: 5 of 5.
  • Firmware debug and release, and the bench programs card-pull, load, stack and watchdog, build with -Werror.
  • The firmware runs on the Teensy and blinks the LED once a second.
  • _g_heap_start lies in RAM2 in the ELF of the firmware, the image and the benches.
  • tools/figcheck.py and clang-format 18 pass.
  • The bench tests with --bench, and the servo tests with the wire fitted, have not run on the new image.

🤖 Generated with Claude Code

AnakinRaW and others added 7 commits November 16, 2026 17:45
…'s warning switch

The root project gives src and firmware/lib -Wall -Wextra -Werror through build_src_flags in
both environments. FastLED 3.10.9's fl/gfx/colorutils.h turns warnings off twice and back on
once, so every #include <FastLED.h> stands between a diagnostic push and pop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ograms

Every project keeps its build cache in one folder under %LOCALAPPDATA%\pio. The cache serves an
object file only to the build folder that compiled it, and worktrees share each project's build
folder, so a build after another worktree's build takes back what it compiled before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test image in firmware/tests/teensy holds the Teensy tests of every program of testing.md,
each program in src/<program>, and takes its tests from the host over USB serial. The old
projects of driver-tick, lighting, servo and every-driver move into it, and each program reports
through test-harness.h.

firmware/tools/teensy-tests.py flashes the image with --upload, restarts the Teensy before each
program and runs one test at a time with the limit the image lists for it. It fails a test that
reports FAIL or ERROR, outlasts its limit, crashes or loses the port, and exits with 1 then. A run
is quick by default. --soak takes the durations testing.md states, and --bench adds the bench
tests.

quiet-libraries.py resolves lib_dir against the project, so a project below the root counts
firmware/lib as its own, and it counts the include folder as its own as well. CI checks the
format of the tests too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The settings stood in firmware/gist/freertos-config.h, and no build included them, so malloc()
took its memory from RAM1 instead of RAM2. They now stand in
firmware/include/freertos_config_override.h, the name the port includes, and the firmware and the
bench programs put that folder on the include path with build_flags. A project's include folder
does not reach the libraries with lib_ldf_mode = off, so the bench programs' wrapper headers go.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
firmware/lib/clock holds nowUs(), elapsedUs(), elapsedMs() and before() of general-design.md and
startClock(), which sets GPT2 to count microseconds from the 24 MHz crystal. The code leaves the
gist and the design document, which link to it now. clock.wrap runs on the computer against a
fake GPT2 counter and compares every answer across the wrap with the one away from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… blinks

setup() starts the clock and creates the main task with xTaskCreateStatic. Its stack is the rest
of RAM1, with an MPU guard of 32 bytes below the interrupts' stack. The main task restores the
temperature panic's and the pin interrupts' priorities, which the start of FreeRTOS resets, and
its main loop blinks the LED by nowUs() without waiting. The port's event responder, a timer and
a task for PJRC's MillisTimer, stays off. The task function is runMainTask in the bench programs
too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
psram.found compares the chip Teensyduino found with the design's 8 MB, and psram.patterns writes
12 fixed patterns and 4 pseudo-random sequences over the whole PSRAM and reads each back past the
cache. clock.rate reads nowUs() between two reads of the cycle counter for 5 s, or a minute in a
soak run. start-up.heap checks that a malloc() before main() and one in the main task lie apart
in RAM2.

The image now runs its tests in a FreeRTOS task, as the firmware runs its main loop, with the
firmware's FreeRTOS settings, and starts the clock in setup().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@AnakinRaW
AnakinRaW merged commit 156e6c2 into main Nov 16, 2026
6 checks passed
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.

1 participant