Skip to content

Flash the STM32

Goal: Build the CrossPad_STM32_r2 firmware and flash it over SWD or USB DFU, or flash a v1 board (PCB r16 / r19).

You need: Start here done, STM32_Programmer_CLI on PATH (the DFU script also finds it through STM32_PROG), Python with pyserial, and an ST-Link for SWD.

The STM32 reads the pads and bridges the ESP console to USB. Flash it when you change its firmware or it stops answering; SWD (step 5) needs an ST-Link, USB DFU (step 6) only the USB cable.

  1. Check whether the board already offers the update

    The ESP firmware carries an STM32 image and can flash it for you. Open Settings → Programming on the board.

    You should see: a STM32 running row with the running version, and below it the bundled version with an Update button (the bundled one is newer) or Reflash (the same version). Press it and wait until the board says it is done. If that works and you are not changing the STM32 firmware, you can stop here.

    If not: STM32 shows no link in Settings

  2. Clone the STM32 firmware (CrossPad_STM32_r2)

    This is the STM32 firmware for a v2 board (PCB r20), with its build files and flash scripts.

    Terminal window
    git clone https://github.com/CrossPad/CrossPad_STM32_r2.git
    cd CrossPad_STM32_r2

    You should see: Cloning into 'CrossPad_STM32_r2'... and no error.

    If not: STM32 firmware clone fails

  3. Put arm-none-eabi-gcc 14.3.x on PATH

    The build calls the compiler by its bare name, so it must be on PATH in this terminal. The build is set up for this compiler series, so use exactly this one.

    Terminal window
    export PATH=/path/to/arm-gnu-toolchain-14.3/bin:$PATH
    arm-none-eabi-gcc --version

    You should see: a first line with a 14.3.x version, followed by a build date.

    If not: STM32 build cannot find arm-none-eabi-gcc or stops at flash_guard

  4. Build the firmware

    The Debug preset builds into build/Debug, where the flash commands below look for CrossPad_STM32_r20.bin. The last build step checks that the image stays below the NVM page at the top of flash.

    Terminal window
    cmake --preset Debug
    cmake --build build/Debug

    You should see: near the end:

    -- flash_guard: … B used, … B free below NVM region @0x0801F800

    If not: STM32 build cannot find arm-none-eabi-gcc or stops at flash_guard

  5. Flash over SWD

    Connect the ST-Link to the board’s SWD pins and power the board. The command writes the image, resets the STM32 and starts it.

    Terminal window
    STM32_Programmer_CLI -c port=SWD freq=4000 -w build/Debug/CrossPad_STM32_r20.bin 0x08000000 -rst --start 0x08000000

    You should see: Start operation achieved successfully at the end. With -v, also Download verified successfully.

    If not: STM32_Programmer_CLI cannot connect over SWD

  6. Flash over USB DFU

    No ST-Link needed: with the board in USB serial mode (ESP USB port 303A:3456 listed; on the board: Settings → USB → Mode → MIDI + Serial), the script asks the board to enter DFU, flashes it and waits for the app to boot. It writes the first flash page last, so an interrupted flash recovers with a replug and a second run.

    Terminal window
    python3 tools/dfu_flash.py --enter

    You should see:

    STM_DFU -> …
    flashed, app booted (VCP back)

    If not: STM32 DFU flash fails

  7. Flash a v1 board (PCB r16 / r19, repo CrossPad_STM32)

    v1 boards use PlatformIO: pick the environment named after the PCB revision, Crosspad_16 or Crosspad_19; the _DFU variants (Crosspad_16_DFU, Crosspad_19_DFU) flash over USB DFU instead of an ST-Link. Run it from the CrossPad_STM32 folder.

    Terminal window
    pio run -e Crosspad_19 -t upload

    You should see: PlatformIO ends with a [SUCCESS] line.

    If not: STM32_Programmer_CLI cannot connect over SWD covers the ST-Link side as well.

SWD ends with Start operation achieved successfully, DFU with flashed, app booted (VCP back). Then check that the STM32 bridge port 0483:5740 is listed again:

Terminal window
python3 -m serial.tools.list_ports -v

You should see: a hwid: line with USB VID:PID=0483:5740.

If not: The STM32 bridge port is not listed