Skip to content

tooling: Add make deploy-usb for DAPLink mass-storage flashing.#382

Merged
nedseb merged 1 commit intomainfrom
tooling/deploy-usb
Apr 13, 2026
Merged

tooling: Add make deploy-usb for DAPLink mass-storage flashing.#382
nedseb merged 1 commit intomainfrom
tooling/deploy-usb

Conversation

@nedseb
Copy link
Copy Markdown
Contributor

@nedseb nedseb commented Apr 13, 2026

Closes #381

Summary

Add a portable make deploy-usb target that flashes the firmware by copying the .bin file to the DAPLink USB mass-storage volume. Useful as an alternative to make deploy (pyOCD) and make deploy-openocd.

Implementation

The detection logic is delegated to scripts/deploy_usb.py (Python, no external deps), which handles all three OS:

OS Detection method
Linux findmnt -n -o TARGET -S LABEL=STeaMi
macOS /Volumes/STeaMi (standard mount path)
Windows wmic logicaldisk where VolumeName='STeaMi'

The Makefile target is just:

deploy-usb: $(MPY_DIR) ## Flash firmware via DAPLink USB mass-storage
    @$(PYTHON) scripts/deploy_usb.py $(STM32_DIR)/build-$(BOARD)/firmware.bin

Notes

  • Detects volume by label, not by hardcoded path
  • DAPLink auto-resets the target after receiving a valid .bin
  • os.sync() ensures the write is flushed (Unix only, no-op on Windows)
  • Multiple boards: returns the first match (a --serial option could be added later)

Test plan

  • Error: firmware not found
  • Error: board not connected
  • Test on Linux with one board connected
  • Test on macOS
  • Test on Windows

Copilot AI review requested due to automatic review settings April 13, 2026 02:16
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 a new Makefile deploy target that flashes firmware by copying the built .bin to the board’s DAPLink USB mass-storage volume, and documents it in contributor docs.

Changes:

  • Add make deploy-usb target that detects the DAPLink mount (Linux via findmnt by label, macOS via /Volumes/...) and copies firmware.bin.
  • Update CONTRIBUTING.md to include the new deploy option alongside existing deploy targets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
Makefile Introduces deploy-usb target to deploy firmware via DAPLink USB mass-storage copy.
CONTRIBUTING.md Documents make deploy-usb as an alternative flashing method.

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

Comment thread Makefile Outdated
if [ -z "$$MOUNT" ] || [ ! -d "$$MOUNT" ]; then \
echo "Error: STeaMi board not found. Is it connected and mounted?"; \
exit 1; \
fi; \
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

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

deploy-usb copies $(STM32_DIR)/build-$(BOARD)/firmware.bin but only depends on $(MPY_DIR), so if the firmware hasn't been built yet the user will just get a generic cp failure. Consider either making deploy-usb depend on the firmware target, or adding an explicit pre-check for firmware.bin with a clearer message (e.g., instructing the user to run make firmware first).

Suggested change
fi; \
fi; \
if [ ! -f "$(STM32_DIR)/build-$(BOARD)/firmware.bin" ]; then \
echo "Error: firmware binary not found at $(STM32_DIR)/build-$(BOARD)/firmware.bin"; \
echo "Run 'make firmware BOARD=$(BOARD)' first."; \
exit 1; \
fi; \

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed: improved the error message in scripts/deploy_usb.py to instruct the user to run make firmware first when the binary is not found. Same approach as the existing deploy-pyocd and deploy-openocd targets which also don't depend on firmware (intentional, to allow re-flashing without rebuild).

@nedseb nedseb force-pushed the tooling/deploy-usb branch from 852cf8e to 4faa9aa Compare April 13, 2026 02:19
Comment thread scripts/deploy_usb.py Fixed
Comment thread scripts/deploy_usb.py Fixed
@nedseb nedseb force-pushed the tooling/deploy-usb branch 3 times, most recently from a6c1eba to 3b23775 Compare April 13, 2026 02:30
@nedseb nedseb force-pushed the tooling/deploy-usb branch 2 times, most recently from c14132b to f2eed4c Compare April 13, 2026 02:41
@nedseb nedseb merged commit 4d5e296 into main Apr 13, 2026
12 checks passed
@nedseb nedseb deleted the tooling/deploy-usb branch April 13, 2026 02:44
@semantic-release-updater
Copy link
Copy Markdown

🎉 This PR is included in version 0.16.3 🎉

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.

tooling: Add portable USB mass-storage deploy as alternative to OpenOCD.

2 participants