-
Notifications
You must be signed in to change notification settings - Fork 1
tooling: Add firmware build and deploy targets. #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3bc8e16
tooling: Add firmware build and deploy targets.
nedseb b667072
tooling: Fix firmware targets using absolute paths.
nedseb a3dfae2
tooling: Fix firmware targets using absolute paths.
nedseb 5b85f45
tooling: Auto-install npm deps in husky hooks after deepclean.
nedseb 95028ee
tooling: Address PR review feedback on firmware targets.
nedseb 94a2d0d
tooling: Separate firmware-update from firmware build.
nedseb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| #!/usr/bin/env sh | ||
| if [ ! -d node_modules ]; then | ||
| echo "Error: node_modules is missing. Run 'make setup' or 'npm install' first." | ||
| exit 1 | ||
| fi | ||
| npx --no-install commitlint --edit "$1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,6 @@ | ||
| #!/usr/bin/env sh | ||
| if [ ! -d node_modules ]; then | ||
| echo "Error: node_modules is missing. Run 'make setup' or 'npm install' first." | ||
| exit 1 | ||
| fi | ||
| npx --no-install validate-branch-name && npx --no-install git-precommit-checks && npx --no-install lint-staged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,61 @@ ci: lint test test-examples ## Run all CI checks (lint + tests + examples) | |
| .PHONY: build | ||
| build: lint test ## Build (lint + test) | ||
|
|
||
| # --- Firmware --- | ||
|
|
||
| $(MPY_DIR): | ||
| @echo "Cloning micropython-steami into $(CURDIR)/$(MPY_DIR)..." | ||
| @mkdir -p $(dir $(CURDIR)/$(MPY_DIR)) | ||
| git clone --branch $(MICROPYTHON_BRANCH) $(MICROPYTHON_REPO) $(CURDIR)/$(MPY_DIR) | ||
| cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) submodules | ||
|
|
||
| .PHONY: firmware | ||
| firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers | ||
| @echo "Linking local 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)..." | ||
| cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) | ||
| @echo "Firmware ready: $(CURDIR)/$(MPY_DIR)/ports/stm32/build-$(BOARD)/firmware.hex" | ||
|
|
||
| .PHONY: firmware-update | ||
| firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific submodules | ||
| @echo "Updating micropython-steami..." | ||
| rm -rf $(CURDIR)/$(MPY_DIR)/lib/micropython-steami-lib | ||
| cd $(CURDIR)/$(MPY_DIR) && git fetch origin && git checkout $(MICROPYTHON_BRANCH) && git checkout -- lib/micropython-steami-lib && git pull --ff-only | ||
| @echo "Updating required submodules for $(BOARD)..." | ||
| cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) submodules | ||
|
|
||
| .PHONY: deploy | ||
| deploy: $(MPY_DIR) ## Flash firmware to the board via OpenOCD | ||
| cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) deploy-openocd | ||
|
|
||
| .PHONY: run | ||
| run: ## Run a script on the board with live output (SCRIPT=path/to/file.py) | ||
| @if [ -z "$(SCRIPT)" ]; then \ | ||
| echo "Error: SCRIPT is required. Usage: make run SCRIPT=lib/.../example.py"; exit 1; \ | ||
| fi | ||
| mpremote connect $(PORT) run $(SCRIPT) | ||
|
|
||
| .PHONY: deploy-script | ||
| deploy-script: ## Deploy a script as main.py for autonomous execution (SCRIPT=path/to/file.py) | ||
| @if [ -z "$(SCRIPT)" ]; then \ | ||
| echo "Error: SCRIPT is required. Usage: make deploy-script SCRIPT=lib/.../example.py"; exit 1; \ | ||
| fi | ||
| mpremote connect $(PORT) cp $(SCRIPT) :main.py | ||
| mpremote connect $(PORT) reset | ||
| @echo "Script deployed as main.py and board reset." | ||
|
Comment on lines
+111
to
+125
|
||
|
|
||
| .PHONY: run-main | ||
| run-main: ## Re-execute main.py on the board and capture output | ||
| mpremote connect $(PORT) exec "exec(open('/flash/main.py').read())" | ||
|
|
||
| .PHONY: firmware-clean | ||
| firmware-clean: ## Clean firmware build artifacts | ||
| @if [ -d "$(MPY_DIR)/ports/stm32" ]; then \ | ||
| cd $(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) clean; \ | ||
| fi | ||
|
|
||
| # --- Hardware --- | ||
|
|
||
| .PHONY: repl | ||
|
|
@@ -141,8 +196,9 @@ clean: ## Remove build artifacts and caches | |
| find . -type d -name .mypy_cache -exec rm -rf {} + 2>/dev/null || true | ||
|
|
||
| .PHONY: deepclean | ||
| deepclean: clean ## Remove everything including node_modules | ||
| deepclean: clean ## Remove everything including node_modules and firmware | ||
| rm -rf node_modules | ||
| @if [ -d "$(BUILD_DIR)" ]; then rm -rf "$(BUILD_DIR)"; fi | ||
|
|
||
| .PHONY: help | ||
| help: ## Show this help | ||
|
|
@@ -159,4 +215,4 @@ printvars: | |
| # Affiche toutes les cibles disponibles dans le Makefile | ||
| .PHONY: list | ||
| list: | ||
| @LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$' | ||
| @LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | grep -E -v -e '^[^[:alnum:]]' -e '^$@$$' | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,9 @@ | ||
| export PATH := $(CURDIR)/node_modules/.bin:$(PATH) | ||
| PORT ?= /dev/ttyACM0 | ||
|
|
||
| # Firmware build configuration | ||
| MICROPYTHON_REPO ?= https://github.com/steamicc/micropython-steami.git | ||
| MICROPYTHON_BRANCH ?= stm32-steami-rev1d-final | ||
| BOARD ?= STEAM32_WB55RG | ||
| BUILD_DIR ?= .build | ||
| MPY_DIR ?= $(BUILD_DIR)/micropython-steami |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git clone ... $(MPY_DIR)will fail on a fresh checkout if$(BUILD_DIR)(default.build) doesn’t exist, becausegit clonewon’t create missing parent directories. Create$(BUILD_DIR)first (e.g.,mkdir -p $(BUILD_DIR)) before cloning, or setMPY_DIRto a path whose parents are guaranteed to exist.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 95028ee. Added
mkdir -pbefore clone.