Template: Setup C/C++ Environment for Pico
From Waveshare Wiki
You can program the Pico with Raspberry Pi or Windows PC.
You can directly refer to the Offical manual of Raspberry Pi.
Raspberry Pi
- Please make sure that you use the Newest Raspberry Pi OS and the Pi 4 is recommended.
Pico SDK
- Open the terminal of the Raspberry Pi
- Run the following commands to get the SDK
cd ~/ mkdir pico cd pico git clone -b master https://github.com/raspberrypi/pico-sdk.git cd pico-sdk git submodule update --init
- Install the ToolChain
sudo apt update sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
- [Optional] If you want to update the SDK, you can run the following commands:
cd ~/pico/pico-sdk git pull git submodule update
Pico Examples
Here we use the pico-examples of Raspberry Pi for examples
- Download the examples
cd ~/pico git clone -b master https://github.com/raspberrypi/pico-examples.git
- Create build directory for Blink example
cd ~/pico/pico-examples mkdir build cd build
- Set the PICO_SDK_PATH
- Note that the path of the SDK maybe different according to the directory you saved
- If you follow this guide step by step, the relative path of the SDK should be ../../pico-sdk and the absolute path should be ~/pico/pico-sdk
- If you change the path of the sdk, please use the correct path
export PICO_SDK_PATH=../../pico-sdk
- Build the example
cmake .. make -j4
- After building, a .uf2 file and a .elf file are generated
- Press and hold the BOOTSEL button of the pico and connect it to Raspberry Pi by USB cable
- A portable disk RPI-RP2 is recognized, copy the .uf2 file to the RPi-RP2
- Pico will reboot and run the codes.