mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-12 19:10:32 +03:00
PICO: Makefile uf2 support using picotool (#14402)
* Adding picotool build recipe in makefiles. * Use semaphore in directory for default goal recipe for target * Suggestions from coderabbitai * Further coderabbit suggestions * Wrong case * Minor change to improve logic * Further improvements. - submodules replaced with specific submodule for pico_sdk (to avoid all developers needing this) * Removing need for remote on git submodule update for configs, as we have the commit occurring daily. - made sure config also build uf2 * Simplified firmware output selection for target * Moved UF2 outside of EXST * Missed two remnants of HEX_TARGETS * Adding check for target * As target is known default output can be set in platform mk file or target mk file - no need for file indicator (i.e. .exe or .uf2) * Update config.mk for less verbosity
This commit is contained in:
parent
f26efcc622
commit
1dcc611388
5 changed files with 142 additions and 67 deletions
|
@ -9,6 +9,7 @@ ifndef V
|
|||
export V0 :=
|
||||
export V1 := $(AT)
|
||||
export STDOUT :=
|
||||
export MAKE := $(MAKE) --no-print-directory
|
||||
else ifeq ($(V), 0)
|
||||
export V0 := $(AT)
|
||||
export V1 := $(AT)
|
||||
|
|
12
mk/config.mk
12
mk/config.mk
|
@ -57,21 +57,23 @@ endif #config
|
|||
.PHONY: configs
|
||||
configs:
|
||||
ifeq ($(shell realpath $(CONFIG_DIR)),$(shell realpath $(CONFIGS_SUBMODULE_DIR)))
|
||||
git submodule update --init --remote -- $(CONFIGS_SUBMODULE_DIR)
|
||||
@echo "Updating config submodule: $(CONFIGS_SUBMODULE_DIR)"
|
||||
$(V1) git submodule update --init -- $(CONFIGS_SUBMODULE_DIR) || { echo "Config submodule update failed. Please check your git configuration."; exit 1; }
|
||||
@echo "Submodule update succeeded."
|
||||
else
|
||||
ifeq ($(wildcard $(CONFIG_DIR)),)
|
||||
@echo "Hydrating clone for configs: $(CONFIG_DIR)"
|
||||
$(V0) git clone $(CONFIGS_REPO_URL) $(CONFIG_DIR)
|
||||
$(V1) git clone $(CONFIGS_REPO_URL) $(CONFIG_DIR)
|
||||
else
|
||||
$(V0) git -C $(CONFIG_DIR) pull origin
|
||||
$(V1) git -C $(CONFIG_DIR) pull origin
|
||||
endif
|
||||
endif
|
||||
|
||||
$(BASE_CONFIGS):
|
||||
@echo "Building target config $@"
|
||||
$(V0) $(MAKE) $(MAKE_PARALLEL) hex CONFIG=$@
|
||||
$(V0) $(MAKE) fwo CONFIG=$@
|
||||
@echo "Building target config $@ succeeded."
|
||||
|
||||
## <CONFIG>_rev : build configured target and add revision to filename
|
||||
$(addsuffix _rev,$(BASE_CONFIGS)):
|
||||
$(V0) $(MAKE) $(MAKE_PARALLEL) hex CONFIG=$(subst _rev,,$@) REV=yes
|
||||
$(V0) $(MAKE) fwo CONFIG=$(subst _rev,,$@) REV=yes
|
||||
|
|
51
mk/tools.mk
51
mk/tools.mk
|
@ -331,3 +331,54 @@ breakpad_clean:
|
|||
$(V1) [ ! -d "$(BREAKPAD_DIR)" ] || $(RM) -rf $(BREAKPAD_DIR)
|
||||
@echo " CLEAN $(BREAKPAD_DL_FILE)"
|
||||
$(V1) $(RM) -f $(BREAKPAD_DL_FILE)
|
||||
|
||||
# Raspberry Pi Pico tools
|
||||
PICOTOOL_REPO := https://github.com/raspberrypi/picotool.git
|
||||
PICOTOOL_DL_DIR := $(DL_DIR)/picotool
|
||||
PICOTOOL_BUILD_DIR := $(PICOTOOL_DL_DIR)/build
|
||||
PICOTOOL_DIR := $(TOOLS_DIR)/picotool
|
||||
PICO_SDK_PATH ?= $(ROOT_DIR)/lib/main/pico-sdk
|
||||
PICOTOOL ?= $(PICOTOOL_DIR)/picotool
|
||||
|
||||
ifneq ($(filter picotool_install uf2,$(MAKECMDGOALS)),)
|
||||
ifeq ($(wildcard $(PICO_SDK_PATH)/CMakeLists.txt),)
|
||||
$(error "PICO_SDK_PATH ($(PICO_SDK_PATH)) does not point to a valid Pico SDK. Please 'make pico_sdk' to hydrate the Pico SDK.")
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq ($(filter uf2,$(MAKECMDGOALS)),)
|
||||
ifeq (,$(wildcard $(PICOTOOL)))
|
||||
ifeq (,$(shell which picotool 2>/dev/null))
|
||||
$(error "picotool not in the PATH or configured. Run 'make picotool_install' to install in the tools folder.")
|
||||
else
|
||||
PICOTOOL := picotool
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: pico_sdk
|
||||
pico_sdk:
|
||||
@echo "Updating pico-sdk"
|
||||
$(V1) git submodule update --init --recursive -- lib/main/pico-sdk || { echo "Failed to update pico-sdk"; exit 1; }
|
||||
@echo "pico-sdk updated"
|
||||
|
||||
.PHONY: picotool_install
|
||||
picotool_install: | $(DL_DIR) $(TOOLS_DIR)
|
||||
picotool_install: picotool_clean
|
||||
@echo "\n CLONE $(PICOTOOL_REPO)"
|
||||
$(V1) git clone --depth 1 $(PICOTOOL_REPO) "$(PICOTOOL_DL_DIR)" || { echo "Failed to clone picotool repository"; exit 1; }
|
||||
@echo "\n BUILD $(PICOTOOL_BUILD_DIR)"
|
||||
$(V1) [ -d "$(PICOTOOL_DIR)" ] || mkdir -p $(PICOTOOL_DIR)
|
||||
$(V1) [ -d "$(PICOTOOL_BUILD_DIR)" ] || mkdir -p $(PICOTOOL_BUILD_DIR)
|
||||
$(V1) cmake -S $(PICOTOOL_DL_DIR) -B $(PICOTOOL_BUILD_DIR) -D PICO_SDK_PATH=$(PICO_SDK_PATH) || { echo "CMake configuration failed"; exit 1; }
|
||||
$(V1) $(MAKE) -C $(PICOTOOL_BUILD_DIR) || { echo "picotool build failed"; exit 1; }
|
||||
$(V1) cp $(PICOTOOL_BUILD_DIR)/picotool $(PICOTOOL_DIR)/picotool || { echo "Failed to install picotool binary"; exit 1; }
|
||||
@echo "\n VERSION:"
|
||||
$(V1) $(PICOTOOL_DIR)/picotool version
|
||||
|
||||
.PHONY: picotool_clean
|
||||
picotool_clean:
|
||||
@echo " CLEAN $(PICOTOOL_DIR)"
|
||||
$(V1) [ ! -d "$(PICOTOOL_DIR)" ] || $(RM) -rf $(PICOTOOL_DIR)
|
||||
@echo " CLEAN $(PICOTOOL_DL_DIR)"
|
||||
$(V1) [ ! -d "$(PICOTOOL_DL_DIR)" ] || $(RM) -rf $(PICOTOOL_DL_DIR)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue