From 621ebf5ea2e686a45c0903f6ce0033709d82eab1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Sun, 12 Apr 2026 19:30:21 +0200 Subject: [PATCH 1/4] fix: Force frozen module regeneration on every firmware build. --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 564ee803..ab078ca4 100644 --- a/Makefile +++ b/Makefile @@ -107,6 +107,7 @@ firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers rm -rf $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib ln -s $(CURDIR) $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib @echo "Building firmware for $(BOARD)..." + rm -f $(STM32_DIR)/build-$(BOARD)/frozen_content.c $(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) @echo "Firmware ready: $(STM32_DIR)/build-$(BOARD)/firmware.hex" @@ -123,7 +124,14 @@ firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific s $(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) submodules .PHONY: deploy -deploy: $(MPY_DIR) ## Flash firmware to the board via OpenOCD +deploy: deploy-pyocd ## Flash firmware (default: pyocd) + +.PHONY: deploy-pyocd +deploy-pyocd: $(MPY_DIR) ## Flash firmware via pyOCD (CMSIS-DAP) + pyocd flash $(STM32_DIR)/build-$(BOARD)/firmware.elf --format elf + +.PHONY: deploy-openocd +deploy-openocd: $(MPY_DIR) ## Flash firmware via OpenOCD $(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) deploy-openocd .PHONY: run From 09aaed1e64a3f54044e921be1ba6e06780151a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Sun, 12 Apr 2026 19:32:37 +0200 Subject: [PATCH 2/4] tooling: Add pyOCD deploy target and install via pip. --- Makefile | 4 ++-- pyproject.toml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ab078ca4..1c57082a 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ $(VENV_DIR)/bin/activate: .PHONY: install install: $(VENV_DIR)/bin/activate node_modules/.package-lock.json ## Install dev tools (pip + npm) - $(VENV_DIR)/bin/pip install -e ".[dev,test]" + $(VENV_DIR)/bin/pip install -e ".[dev,test,flash]" # --- Linting --- @@ -128,7 +128,7 @@ deploy: deploy-pyocd ## Flash firmware (default: pyocd) .PHONY: deploy-pyocd deploy-pyocd: $(MPY_DIR) ## Flash firmware via pyOCD (CMSIS-DAP) - pyocd flash $(STM32_DIR)/build-$(BOARD)/firmware.elf --format elf + $(PYTHON) -m pyocd flash $(STM32_DIR)/build-$(BOARD)/firmware.elf --format elf .PHONY: deploy-openocd deploy-openocd: $(MPY_DIR) ## Flash firmware via OpenOCD diff --git a/pyproject.toml b/pyproject.toml index 56ef184f..376665d6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ requires-python = ">=3.7" [project.optional-dependencies] dev = ["ruff==0.11.6", "micropython-stm32-stubs>=1.24"] test = ["pytest==7.4.0", "pyyaml==6.0.2", "mpremote>=1.0"] +flash = ["pyocd>=0.44"] [tool.setuptools] # No Python packages to install — this project contains MicroPython drivers From 291df8b879e3e4d91fe41da1e428f821dde90369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Mon, 13 Apr 2026 04:00:48 +0200 Subject: [PATCH 3/4] docs: Update CONTRIBUTING for pyOCD as default deploy tool. --- CONTRIBUTING.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d72e27f9..2fcc547e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -120,7 +120,8 @@ For local development (without dev container): * Python 3.10+ * Node.js 22+ (for husky, commitlint, lint-staged, semantic-release) * `arm-none-eabi-gcc` toolchain (for `make firmware`) -* OpenOCD (for `make deploy`) +* `pyocd` (for `make deploy`, installed via `pip install -e ".[flash]"`) +* OpenOCD (optional, for `make deploy-openocd`) * `mpremote` (installed via `pip install -e ".[test]"`) * GitHub CLI (`gh`) @@ -192,7 +193,8 @@ The drivers are "frozen" into the MicroPython firmware for the STeaMi board. The ```bash make firmware # Clone micropython-steami (if needed), link local drivers, build make firmware-update # Refresh the MicroPython clone and board-specific submodules -make deploy # Flash firmware via OpenOCD +make deploy # Flash firmware via pyOCD (default) +make deploy-openocd # Flash firmware via OpenOCD (alternative) make run SCRIPT=lib/steami_config/examples/show_config.py # Run with live output make deploy-script SCRIPT=lib/.../calibrate_magnetometer.py # Deploy as main.py for autonomous use make run-main # Re-execute the deployed main.py From 6343ad1d89d268c9fc099e9516954eabe12b7b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20NEDJAR?= Date: Mon, 13 Apr 2026 04:03:16 +0200 Subject: [PATCH 4/4] docs: Mention pyOCD in devcontainer description. --- .devcontainer/devcontainer.json | 2 +- CONTRIBUTING.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ef9b23f4..6698cad7 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,7 +4,7 @@ "dockerfile": "Dockerfile" }, - // USB access for STeaMi board (DAPLink / mpremote / OpenOCD). + // USB access for STeaMi board (DAPLink / mpremote / pyOCD / OpenOCD). // Privileged mode is required for firmware flashing and board communication. // This is incompatible with GitHub Codespaces but essential for local use. "privileged": true, diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2fcc547e..700be303 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -129,7 +129,7 @@ Then run `make setup` to install all dependencies and git hooks. This creates a ## Dev Container -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. +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. 1. Open the repository in VS Code 2. When prompted, click **Reopen in Container** (or use the command palette: *Dev Containers: Reopen in Container*) @@ -140,7 +140,7 @@ The container also provides: * **zsh + oh-my-zsh** as default shell with persistent shell history * **Pylance** configured with MicroPython STM32 stubs (no false `import machine` errors) * **Serial Monitor** extension for board communication -* **USB passthrough** for mpremote, OpenOCD, and firmware flashing (the container runs in privileged mode with `/dev/bus/usb` mounted) +* **USB passthrough** for mpremote, pyOCD, OpenOCD, and firmware flashing (the container runs in privileged mode with `/dev/bus/usb` mounted) * **udev rules** for the DAPLink interface (auto-started on container creation) Note: GitHub Codespaces is not supported because the container requires privileged mode and USB device access for board communication.