A Little Makefile to Configure your Raspberry Pi Pico Project
I put this little Makefile in the top of my Pico project directory. It handles making the build
directory and invoking cmake
with the right flags to build my actual make files.
Mostly I just do make install
to build and flash onto my device. (Presuming the device is in UF2 mode, that's a different post.)
#
# Path to my SDK installation
#
PICO_SDK_PATH ?= ~/pico-sdk
#
# Path to the mount point for my pico
#
PICO_MOUNT ?= /rpi-rp2
#
# Path to my UF2 image in the build directory
#
IMAGE = build/sbi-weather.uf2
all : $(IMAGE)
install : all
mount $(PICO_MOUNT)
cp $(IMAGE) $(PICO_MOUNT)/foo
sync
clean :
rm -rf build pico_sdk_import.cmake
build :
mkdir build
$(IMAGE): build/Makefile
( cd build ; make all )
build/Makefile : CMakeLists.txt pico_sdk_import.cmake | build
( cd build ; cmake -DPICO_SDK_PATH=$(PICO_SDK_PATH) .. )
pico_sdk_import.cmake : $(PICO_SDK_PATH)/external/pico_sdk_import.cmake
cp $< $@
.PHONY : all install clean $(IMAGE)
Note
I'm using a Raspberry Pi running Raspbian as my host. In the install
target the sync
command is helpful to push the dirty blocks out right now.
The mount
command also works fine for my user account because I have this in my /etc/fstab
LABEL=RPI-RP2 /rpi-rp2 msdos defaults,noauto,user 0 1