Skip to content

tooling(daplink_bridge): Add SWD-based DAPLink flash targets.#394

Merged
nedseb merged 1 commit intomainfrom
tooling/daplink-deploy-swd
Apr 14, 2026
Merged

tooling(daplink_bridge): Add SWD-based DAPLink flash targets.#394
nedseb merged 1 commit intomainfrom
tooling/daplink-deploy-swd

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Apr 14, 2026

Summary

Implements #388.

Five new Make targets for flashing the DAPLink chip via an external SWD probe (ST-Link, J-Link, or another CMSIS-DAP board):

Target Purpose
daplink-bootloader Build stm32f103xb_bl (47 KB, address 0x08000000)
daplink-deploy-pyocd Flash interface firmware via SWD (pyocd, no MAINTENANCE mode)
daplink-deploy-openocd Flash interface firmware via SWD (openocd)
daplink-deploy-bootloader Alias → -pyocd variant
daplink-deploy-bootloader-pyocd Flash bootloader via SWD (pyocd)
daplink-deploy-bootloader-openocd Flash bootloader via SWD (openocd)

Design notes

  • OpenOCD flow inspired by steamicc/DapLink-EasyFlash: ST-Link with transport select hla_swd, reset_config none separate, stm32f1x unlock 0 before program verify so read-protected chips can be recovered in one shot.
  • pyOCD uses the built-in stm32f103rc target (flash-compatible with the STM32F103CB on the DAPLink chip for the lower 128 KB). Configurable via DAPLINK_PYOCD_TARGET.
  • Both flows share a DAPLINK_OPENOCD_FLASH make-function and a DAPLINK_SWD_WARNING banner printed before every SWD deploy. The warning explains that a board cannot reflash its own on-board DAPLink and that an external probe is mandatory.
  • Override variables live in env.mk: DAPLINK_OPENOCD_INTERFACE, DAPLINK_OPENOCD_TRANSPORT, DAPLINK_OPENOCD_TARGET, DAPLINK_PYOCD_TARGET, DAPLINK_FLASH_ADDR, DAPLINK_BL_FLASH_ADDR — for non-ST-Link probes or custom layouts.
  • daplink-deploy-pyocd / daplink-deploy-openocd no longer trigger the "use the micropython- variant" deprecation message, since both now exist. The DEPRECATED_MICROPYTHON_ONLY macro is removed.

Test plan

  • make daplink-bootloader builds stm32f103xb_bl_crc.bin (Start 0x8000000, Length 0xbc00, CRC32 0x564aa44f).
  • make help lists the five new targets.
  • make -n on each SWD target prints the warning banner followed by the expected pyocd / openocd command with the correct base address (0x08000000 for bootloader, 0x08002000 for interface).
  • make lint / make test-mock still pass (364 passed, 2 skipped).
  • Hardware verification pending: flash with a real ST-Link on a STeaMi board. Both the interface SWD path and the bootloader SWD path should be validated before merge.

Closes

#388

Closes #388.

New Make targets for flashing the DAPLink chip via an external SWD probe:

  daplink-bootloader               Build stm32f103xb_bl (bootloader, 47 KB at 0x08000000)
  daplink-deploy-pyocd             Flash interface firmware via SWD (pyocd, no MAINTENANCE)
  daplink-deploy-openocd           Flash interface firmware via SWD (openocd)
  daplink-deploy-bootloader        Alias for bootloader-pyocd
  daplink-deploy-bootloader-pyocd  Flash bootloader via SWD (pyocd)
  daplink-deploy-bootloader-openocd Flash bootloader via SWD (openocd)

The OpenOCD sequence mirrors steamicc/DapLink-EasyFlash: ST-Link hla_swd
transport, `stm32f1x unlock 0` before `program verify` so locked chips can
be recovered. pyOCD uses the built-in `stm32f103rc` target (flash-compatible
with the STM32F103CB on the DAPLink chip for the lower 128 KB).

Every SWD target prints a bootstrap warning explaining that a board cannot
reflash its own on-board DAPLink via its own SWD pins — an EXTERNAL probe
is required on the target's SWD header.

CONTRIBUTING.md documents the new targets, the bootstrap constraint, and
the override variables (DAPLINK_OPENOCD_INTERFACE, DAPLINK_OPENOCD_TRANSPORT,
DAPLINK_PYOCD_TARGET) for non-ST-Link probes.

Since daplink-deploy-pyocd and daplink-deploy-openocd now exist, the
short-name deprecation messages for `deploy-pyocd` / `deploy-openocd` are
reverted to the standard DEPRECATED_FIRMWARE form that points to both the
micropython- and daplink- variants. The DEPRECATED_MICROPYTHON_ONLY macro
is removed.

Verified locally:
- make daplink-bootloader → builds stm32f103xb_bl_crc.bin (Start 0x8000000,
  Length 0xbc00, CRC32 0x564aa44f)
- make help lists the five new targets
- make -n on each SWD target produces the expected pyocd / openocd command
  with the warning prelude and the correct base address
- make lint / make test-mock still pass

Hardware verification pending: flashing with a real ST-Link on a STeaMi
board must be done before merging.
Copilot AI review requested due to automatic review settings April 14, 2026 08:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Makefile tooling to build and flash the DAPLink STM32F103 (bootloader + interface firmware) via an external SWD probe, complementing the existing USB MAINTENANCE update path and documenting the bootstrap limitation.

Changes:

  • Introduces new Make targets to build the DAPLink bootloader and flash bootloader/interface firmware via pyOCD or OpenOCD over SWD.
  • Adds configurable SWD flashing variables in env.mk (targets, OpenOCD interface/transport, and flash base addresses).
  • Updates contributor documentation to describe the new SWD-based flows and the “external probe required” warning.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
env.mk Adds DAPLink bootloader build dir and SWD-flash configuration defaults/overrides (addresses + pyOCD/OpenOCD knobs).
Makefile Implements new daplink-bootloader + SWD deploy targets; adds shared warning banner and OpenOCD flash helper; removes obsolete deprecation macro.
CONTRIBUTING.md Documents the new targets and clearly explains MAINTENANCE vs SWD flashing and the external-probe requirement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nedseb nedseb merged commit e46dc7b into main Apr 14, 2026
14 checks passed
@nedseb nedseb deleted the tooling/daplink-deploy-swd branch April 14, 2026 08:42
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.16.8 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants