Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,21 @@ $(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
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) submodules

.PHONY: firmware
firmware: $(MPY_DIR) ## Build MicroPython firmware with current drivers
@set -e
@if [ ! -f "$(MPY_DIR)/lib/micropython-lib/README.md" ]; then \
echo "Initializing submodules for $(BOARD)..."; \
cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) submodules; \
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) submodules; \
fi
@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"
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD)
@echo "Firmware ready: $(STM32_DIR)/build-$(BOARD)/firmware.hex"

.PHONY: firmware-update
firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific submodules
Expand All @@ -117,11 +117,11 @@ firmware-update: $(MPY_DIR) ## Update the MicroPython clone and board-specific s
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
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

In firmware-update, the preceding cd $(CURDIR)/$(MPY_DIR) && ... runs in the same .ONESHELL script, so the working directory remains $(MPY_DIR) for subsequent commands. With STM32_DIR defined as a relative path ($(MPY_DIR)/ports/stm32), $(MAKE) -C $(STM32_DIR) will resolve to $(MPY_DIR)/$(MPY_DIR)/ports/stm32 and likely fail. Consider avoiding a persistent cd (e.g., use git -C $(CURDIR)/$(MPY_DIR) ... or wrap the git command in a subshell) and/or define STM32_DIR as an absolute path (e.g., $(abspath ...)).

Suggested change
cd $(CURDIR)/$(MPY_DIR) && git fetch origin && git checkout $(MICROPYTHON_BRANCH) && git checkout -- lib/micropython-steami-lib && git pull --ff-only
git -C $(CURDIR)/$(MPY_DIR) fetch origin
git -C $(CURDIR)/$(MPY_DIR) checkout $(MICROPYTHON_BRANCH)
git -C $(CURDIR)/$(MPY_DIR) checkout -- lib/micropython-steami-lib
git -C $(CURDIR)/$(MPY_DIR) pull --ff-only

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 in 6ffe093: replaced cd ... && git ... with git -C for each git command. No more cd in the entire Makefile.

@echo "Updating required submodules for $(BOARD)..."
cd $(CURDIR)/$(MPY_DIR)/ports/stm32 && $(MAKE) BOARD=$(BOARD) submodules
$(MAKE) -C $(STM32_DIR) 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
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) deploy-openocd

.PHONY: run
run: ## Run a script on the board with live output (SCRIPT=path/to/file.py)
Expand All @@ -145,8 +145,8 @@ run-main: ## Re-execute main.py on the board and capture output

.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; \
@if [ -d "$(STM32_DIR)" ]; then \
$(MAKE) -C $(STM32_DIR) BOARD=$(BOARD) clean; \
fi

# --- Hardware ---
Expand Down
1 change: 1 addition & 0 deletions env.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ MICROPYTHON_BRANCH ?= stm32-steami-rev1d-final
BOARD ?= STEAM32_WB55RG
BUILD_DIR ?= .build
MPY_DIR ?= $(BUILD_DIR)/micropython-steami
STM32_DIR = $(MPY_DIR)/ports/stm32
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

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

env.mk uses ?= for other user-configurable variables (e.g., MPY_DIR, BUILD_DIR). Consider using STM32_DIR ?= ... as well (and possibly an absolute form via $(abspath ...)) so callers can override the path consistently when needed.

Suggested change
STM32_DIR = $(MPY_DIR)/ports/stm32
STM32_DIR ?= $(MPY_DIR)/ports/stm32

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 in 6ffe093: changed to STM32_DIR ?= for consistency with the other overridable variables.

Loading