Skip to content
Tercio S1

S1 firmware

2 min readFirmware v2 · protocol v2

The S1 firmware is open source (GPL-3.0), written in C++ against ST’s HAL and the STM32duino core, and built with PlatformIO. It is flashed through the SWD header with an ST-Link.

Tercio Control shows the firmware and protocol version on the motor’s Diagnostics tab. In Python: print(motor.info()).

  • An ST-Link (V2, V3 or a clone) or any SWD probe that PlatformIO or STM32CubeProgrammer supports.
  • Five jumper wires for the SWD header (J3): 3.3 V, SWDIO, SWCLK, NRST, GND.
  • PlatformIO (VS Code extension or the pio command line).
  • The source: Kerol-Dev/Tercio-s1.
  • DirectoryTercio-s1/Firmware
    • platformio.ini platform and core pinned to tested versions
    • Directorysrc
      • Directoryapp/ axis state machine, parameters, bus node, procedures
        • …
      • Directoryboard/ pins, clock, hardware revision
        • …
      • Directorycontrol/ planner, position controller, encoder tracking
        • …
      • Directorydrivers/ CAN-FD, TMC2209, step generator, flash storage, inputs
        • …
      • Directoryencoder/ AS5600, AS5048A
        • …
      • protocol/Protocol.h the CAN protocol v2 contract
    • Directorytest/ host unit tests
      • …
    • DirectoryLibraries/ Python and Arduino host libraries
      • …
    • DirectoryWeb_Server/ Tercio Control
      • …
  1. Power the S1 from its supply as usual. Do not power it from the probe.

  2. Connect the probe to J3: 3.3 V to pin 1 (voltage sense), SWDIO to 2, SWCLK to 3, NRST to 4, GND to 5.

  3. Build and flash from the Firmware folder:

    Terminal window
    pio run -e tercio_s1 -t upload

    Or flash the built .pio/build/tercio_s1/firmware.bin with STM32CubeProgrammer at address 0x08000000.

  4. The S1 restarts into the new firmware. Check the version in Tercio Control.

To run the unit tests for the planner, controller, encoder tracking, parameters and protocol codec on your computer:

Terminal window
pio test -e native

If the probe cannot connect, for example because a firmware keeps the chip busy or resets it:

  1. Fit a jumper on J6 pins 1–2 (BOOT0 to 3.3 V).
  2. Power-cycle the S1. It now starts ST’s ROM bootloader instead of the firmware, and the probe connects.
  3. Flash as above, or erase the chip with STM32CubeProgrammer (Full chip erase).
  4. Remove the jumper and power-cycle.