diff --git a/.gitignore b/.gitignore index 8eae74a..5223671 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ build toolchain *.orig -*.debug \ No newline at end of file +*.debug +*.swp diff --git a/Makefile b/Makefile index 5760c60..4b90ef9 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ export INSTALL_PATH := $(PWD) SDK_VERSION := 2.1.0 -PICOTOOL := $(INSTALL_PATH)/picotool/$(SDK_VERSION)/build/picotool +export PICOTOOL_PATH=$(INSTALL_PATH)/picotool/$(SDK_VERSION)/build export PICO_SDK_PATH=$(INSTALL_PATH)/sdk/$(SDK_VERSION) # if using a different platform or arch, set it here export PICO_PLATFORM=rp2350 +picotool = ${PICOTOOL_PATH}/picotool # project name, need to be passed as make input (ex: make project name=test) name := "" @@ -37,16 +38,16 @@ endif @./scripts/scaffold_project.bash $(name) $(SDK_VERSION) format: .check-name - @test -f "$(shell find /usr/bin/ -name astyle)" && astyle --style=java --indent=spaces=4 -K -xC120 $(name)/*.c + @(test -f "$(shell find /usr/bin/ -name astyle)" && astyle --style=java --indent=spaces=4 -K -xC120 $(name)/*.c) || echo "astyle bin formatter not found, skip it" run-debug: format @rm -f ${name}/${name}.debug @gcc -std=c99 -o2 ${name}/*.c -lm -o ${name}/${name}.debug && ./${name}/${name}.debug compile: format - rm -f ${name}/build/CMakeCache.txt + @rm -f ${name}/build/CMakeCache.txt @(test -d ${name} && mkdir -p ${name}/build && cd ${name}/build && cmake .. && make -j$(nproc) && echo "project compile successfully") || echo "error: unable to compile project: $(name)" push: compile - @(test -f $(name)/build/$(name).elf && $(PICOTOOL) load -fx -v $(name)/build/$(name).elf) || echo "error: unable to push project $(name) to device" + @(test -f $(name)/build/$(name).elf && $(picotool) load -fx -v $(name)/build/$(name).elf) || echo "error: unable to push project $(name) to device" diff --git a/bit_counter/CMakeLists.txt b/bit_counter/CMakeLists.txt index 575c776..9fa962f 100644 --- a/bit_counter/CMakeLists.txt +++ b/bit_counter/CMakeLists.txt @@ -11,6 +11,12 @@ include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) project(bit_counter C CXX ASM) +# force picotool executable path +add_executable(picotool IMPORTED GLOBAL) +set_target_properties(picotool PROPERTIES + IMPORTED_LOCATION "$(PICOTOOL_PATH)/picotool" +) + # Initialise the Raspberry Pi Pico SDK pico_sdk_init() diff --git a/breathing_led/CMakeLists.txt b/breathing_led/CMakeLists.txt index 025e95e..098d3a6 100644 --- a/breathing_led/CMakeLists.txt +++ b/breathing_led/CMakeLists.txt @@ -11,6 +11,13 @@ include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) project(breathing_led C CXX ASM) +# force picotool executable path +add_executable(picotool IMPORTED GLOBAL) +set_target_properties(picotool PROPERTIES + IMPORTED_LOCATION "$(PICOTOOL_PATH)/picotool" +) + + # Initialise the Raspberry Pi Pico SDK pico_sdk_init() diff --git a/simple_led/CMakeLists.txt b/simple_led/CMakeLists.txt index 2ea410d..323849c 100644 --- a/simple_led/CMakeLists.txt +++ b/simple_led/CMakeLists.txt @@ -10,6 +10,12 @@ include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) project(simple_led C CXX ASM) +# force picotool executable path +add_executable(picotool IMPORTED GLOBAL) +set_target_properties(picotool PROPERTIES + IMPORTED_LOCATION "$(PICOTOOL_PATH)/picotool" +) + pico_sdk_init() set(FREERTOS_SRC_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../freertos) diff --git a/templates/CMakeLists.txt.tpl b/templates/CMakeLists.txt.tpl index c8db396..b92fb29 100644 --- a/templates/CMakeLists.txt.tpl +++ b/templates/CMakeLists.txt.tpl @@ -11,6 +11,12 @@ include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake) project( C CXX ASM) +# force picotool executable path +add_executable(picotool IMPORTED GLOBAL) +set_target_properties(picotool PROPERTIES + IMPORTED_LOCATION "$(PICOTOOL_PATH)/picotool" +) + # Initialise the Raspberry Pi Pico SDK pico_sdk_init()