Skip to content

tooling: Add daplink-deploy-bootloader and SWD-based interface flash targets. #388

@nedseb

Description

@nedseb

Context

PR #387 added make daplink-firmware / make daplink-deploy-usb to build and update the DAPLink interface firmware via the MAINTENANCE USB volume. This covers the routine update path (no external probe needed).

For bootloader updates and for interface updates without entering MAINTENANCE mode, an external SWD probe is required. These cases are not yet covered by the Makefile.

Background

DAPLink consists of two parts:

Part Address Update path
Bootloader 0x08000000 External SWD probe only (rarely needed)
Interface firmware 0x08002000 MAINTENANCE USB (routine) or external SWD probe

A board with a working bootloader can update its interface firmware via MAINTENANCE USB without any external hardware. But an external SWD probe (ST-Link, J-Link, or another DAPLink board) can flash either part.

Proposed targets

make daplink-deploy-bootloader        # Flash bootloader via SWD probe (default: pyocd)
make daplink-deploy-bootloader-pyocd  # Flash bootloader via pyOCD
make daplink-deploy-bootloader-openocd # Flash bootloader via OpenOCD

make daplink-deploy-pyocd             # Flash interface firmware via pyOCD (no MAINTENANCE mode)
make daplink-deploy-openocd           # Flash interface firmware via OpenOCD (no MAINTENANCE mode)

daplink-deploy-pyocd / daplink-deploy-openocd are useful when:

  • Recovering from a bricked interface firmware that prevents MAINTENANCE mode
  • Automating CI flashing without manual button press
  • Flashing via an external probe attached to the SWD pins (not the on-board DAPLink)

Implementation notes

Addresses

  • Bootloader binary: stm32f103xb_bl_crc.bin at 0x08000000
  • Interface firmware: stm32f103xb_steami32_if_crc.bin at 0x08002000

pyOCD command

pyocd flash -t stm32f103rb --base-address 0x08000000 stm32f103xb_bl_crc.bin

For the interface firmware, the same pattern with --base-address 0x08002000.

OpenOCD command

openocd -f interface/stlink.cfg -c "transport select swd" \
    -f target/stm32f1x.cfg \
    -c "init; reset halt; stm32f1x unlock 0; reset halt" \
    -c "program <bin> verify <address>" \
    -c "reset; exit"

Bootstrap problem

A board's own DAPLink cannot reflash itself (the SWD probe cannot reset its own host MCU). For initial flash or recovery via SWD, an external probe is required (not the board's own DAPLink). This must be documented clearly in the help text and CONTRIBUTING.md.

Bootloader build

The DAPLink build also produces stm32f103xb_bl_crc.bin — already available in $(DAPLINK_BUILD_DIR) after make daplink-firmware. No separate build step needed.

Tasks

  • Add daplink-deploy-bootloader (alias to daplink-deploy-bootloader-pyocd)
  • Add daplink-deploy-bootloader-pyocd and daplink-deploy-bootloader-openocd
  • Add daplink-deploy-pyocd and daplink-deploy-openocd for interface flash via SWD (no MAINTENANCE mode required)
  • Update CONTRIBUTING.md to document the SWD-based flash methods, including the bootstrap warning
  • Verify on hardware with an external probe (ST-Link)

Related

Metadata

Metadata

Assignees

Labels

releasedtoolingDeveloper tooling, build system, hooks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions