Skip to content

Commit 4004540

Browse files
authored
fix: Force frozen rebuild and switch deploy to pyOCD. (#379)
* fix: Force frozen module regeneration on every firmware build. * tooling: Add pyOCD deploy target and install via pip. * docs: Update CONTRIBUTING for pyOCD as default deploy tool. * docs: Mention pyOCD in devcontainer description.
1 parent bf8a482 commit 4004540

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"dockerfile": "Dockerfile"
55
},
66

7-
// USB access for STeaMi board (DAPLink / mpremote / OpenOCD).
7+
// USB access for STeaMi board (DAPLink / mpremote / pyOCD / OpenOCD).
88
// Privileged mode is required for firmware flashing and board communication.
99
// This is incompatible with GitHub Codespaces but essential for local use.
1010
"privileged": true,

CONTRIBUTING.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,15 +120,16 @@ For local development (without dev container):
120120
* Python 3.10+
121121
* Node.js 22+ (for husky, commitlint, lint-staged, semantic-release)
122122
* `arm-none-eabi-gcc` toolchain (for `make firmware`)
123-
* OpenOCD (for `make deploy`)
123+
* `pyocd` (for `make deploy`, installed via `pip install -e ".[flash]"`)
124+
* OpenOCD (optional, for `make deploy-openocd`)
124125
* `mpremote` (installed via `pip install -e ".[test]"`)
125126
* GitHub CLI (`gh`)
126127

127128
Then run `make setup` to install all dependencies and git hooks. This creates a `.venv` with ruff, pytest, mpremote, and MicroPython type stubs for Pylance.
128129

129130
## Dev Container
130131

131-
A dev container is available for VS Code (local Docker only, not GitHub Codespaces). It includes all prerequisites out of the box: Python 3.10, Node.js 22, ruff, pytest, mpremote, arm-none-eabi-gcc, OpenOCD, and the GitHub CLI.
132+
A dev container is available for VS Code (local Docker only, not GitHub Codespaces). It includes all prerequisites out of the box: Python 3.10, Node.js 22, ruff, pytest, mpremote, pyOCD, arm-none-eabi-gcc, OpenOCD, and the GitHub CLI.
132133

133134
1. Open the repository in VS Code
134135
2. When prompted, click **Reopen in Container** (or use the command palette: *Dev Containers: Reopen in Container*)
@@ -139,7 +140,7 @@ The container also provides:
139140
* **zsh + oh-my-zsh** as default shell with persistent shell history
140141
* **Pylance** configured with MicroPython STM32 stubs (no false `import machine` errors)
141142
* **Serial Monitor** extension for board communication
142-
* **USB passthrough** for mpremote, OpenOCD, and firmware flashing (the container runs in privileged mode with `/dev/bus/usb` mounted)
143+
* **USB passthrough** for mpremote, pyOCD, OpenOCD, and firmware flashing (the container runs in privileged mode with `/dev/bus/usb` mounted)
143144
* **udev rules** for the DAPLink interface (auto-started on container creation)
144145

145146
Note: GitHub Codespaces is not supported because the container requires privileged mode and USB device access for board communication.
@@ -192,7 +193,8 @@ The drivers are "frozen" into the MicroPython firmware for the STeaMi board. The
192193
```bash
193194
make firmware # Clone micropython-steami (if needed), link local drivers, build
194195
make firmware-update # Refresh the MicroPython clone and board-specific submodules
195-
make deploy # Flash firmware via OpenOCD
196+
make deploy # Flash firmware via pyOCD (default)
197+
make deploy-openocd # Flash firmware via OpenOCD (alternative)
196198
make run SCRIPT=lib/steami_config/examples/show_config.py # Run with live output
197199
make deploy-script SCRIPT=lib/.../calibrate_magnetometer.py # Deploy as main.py for autonomous use
198200
make run-main # Re-execute the deployed main.py

Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $(VENV_DIR)/bin/activate:
2929

3030
.PHONY: install
3131
install: $(VENV_DIR)/bin/activate node_modules/.package-lock.json ## Install dev tools (pip + npm)
32-
$(VENV_DIR)/bin/pip install -e ".[dev,test]"
32+
$(VENV_DIR)/bin/pip install -e ".[dev,test,flash]"
3333

3434
# --- Linting ---
3535

@@ -107,6 +107,7 @@ firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers
107107
rm -rf $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib
108108
ln -s $(CURDIR) $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib
109109
@echo "Building firmware for $(BOARD)..."
110+
rm -f $(STM32_DIR)/build-$(BOARD)/frozen_content.c
110111
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD)
111112
@echo "Firmware ready: $(STM32_DIR)/build-$(BOARD)/firmware.hex"
112113

@@ -123,7 +124,14 @@ firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific s
123124
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) submodules
124125

125126
.PHONY: deploy
126-
deploy: $(MPY_DIR) ## Flash firmware to the board via OpenOCD
127+
deploy: deploy-pyocd ## Flash firmware (default: pyocd)
128+
129+
.PHONY: deploy-pyocd
130+
deploy-pyocd: $(MPY_DIR) ## Flash firmware via pyOCD (CMSIS-DAP)
131+
$(PYTHON) -m pyocd flash $(STM32_DIR)/build-$(BOARD)/firmware.elf --format elf
132+
133+
.PHONY: deploy-openocd
134+
deploy-openocd: $(MPY_DIR) ## Flash firmware via OpenOCD
127135
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) deploy-openocd
128136

129137
.PHONY: run

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ requires-python = ">=3.7"
1212
[project.optional-dependencies]
1313
dev = ["ruff==0.11.6", "micropython-stm32-stubs>=1.24"]
1414
test = ["pytest==7.4.0", "pyyaml==6.0.2", "mpremote>=1.0"]
15+
flash = ["pyocd>=0.44"]
1516

1617
[tool.setuptools]
1718
# No Python packages to install — this project contains MicroPython drivers

0 commit comments

Comments
 (0)