The Raspberry Pi Pico’s documentation currently only covers setup and building on a Raspberry Pi, so here is how to quickly install the SDK and run your first Pico application on your Linux machine!
Make sure you have the build toolchain (CMake, GNU Embedded Toolchain for Arm, etc.) installed and up-to-date:
$ sudo apt update $ sudo apt install cmake build-essential gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
Note: If you are not using a Debian-based distro such as Ubuntu, replace instances of “apt” with your distro’s package manager (pacman, dnf, etc.) and associated packages.
I am choosing to install the SDK to the standard “local source code” directory /usr/local/src:
$ cd /usr/local/src/ $ mkdir pi $ cd pi $ mkdir pico $ cd pico
Clone the pico-sdk repository and download submodules:
$ git clone -b master https://github.com/raspberrypi/pico-sdk.git $ cd pico-sdk $ git submodule update --init $ cd ..
Clone the pico-examples repository if you desire:
$ git clone -b master https://github.com/raspberrypi/pico-examples.git
Add the SDK directory to the PICO_SDK_PATH environment variable:
$ nano ~/.bash_aliases
Set this to wherever you decided to install your SDK:
export PICO_SDK_PATH=/usr/local/src/pi/pico/pico-sdk
Make a directory for your project and copy the “pico-sdk/external/pico_sdk_import.cmake” file into it. Import and initialize the Pico SDK by using the copied “pico_sdk_import.cmake” file at the beginning of your “CMakeLists.txt” as follows:
cmake_minimum_required(VERSION 3.13) # Include the SDK using the PICO_SDK_PATH environment variable: # (before project()) include(pico_sdk_import.cmake) project(project_name) # Initialize the Raspberry Pi Pico SDK: (after project()) pico_sdk_init() # The rest of your project goes here!
Use CMake to generate a makefile, then build your project: $ mkdir build $ cd build $ cmake .. $ make -j 4
To install your program onto your Pico, plug it in via USB while holding the “BOOTSEL” button and a new USB Mass Storage Device should automatically mount. Drag and drop the compiled “.uf2” file into the newly mounted Pico directory. The Pico should automatically unmount, restart, and run the application.
To view serial output from the Pico you must first add your username to the “dialout” group, then restart your computer:
$ sudo usermod -a -G dialout $USER $ sudo restart -r now
Install the screen program:
$ sudo apt install screen
The screen program syntax is as follows:
$ screen [DEVICE NAME] [BAUDRATE]
With the Pico connected, find the device name:
$ ls -l /dev/ttyUSB* /dev/ttyACM*
With my Pico connected via USB; my serial port is mounted to “/dev/ttyACM0” and the Pico’s baudrate is 115200, so the screen program should be ran as follows:
$ screen /dev/ttyACM0 115200
To exit the screen program, press Ctrl+A to enter command mode, type “:quit” then press the enter key.
Download the test project here.
Thanks for the most complete set of instructions for PICO development.