• Stars
    star
    3,536
  • Rank 12,455 (Top 0.3 %)
  • Language
    C
  • License
    BSD 3-Clause "New...
  • Created over 3 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Raspberry Pi Pico SDK

The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system necessary to write programs for the RP2040-based devices such as the Raspberry Pi Pico in C, C++ or assembly language.

The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike. A single program runs on the device at a time and starts with a conventional main() method. Standard C/C++ libraries are supported along with C level libraries/APIs for accessing all of the RP2040's hardware include PIO (Programmable IO).

Additionally the SDK provides higher level libraries for dealing with timers, synchronization, USB (TinyUSB) and multi-core programming along with various utilities.

The SDK can be used to build anything from simple applications, to fully fledged runtime environments such as MicroPython, to low level software such as RP2040's on-chip bootrom itself.

Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in pico-extras.

Documentation

See Getting Started with the Raspberry Pi Pico for information on how to setup your hardware, IDE/environment and for how to build and debug software for the Raspberry Pi Pico and other RP2040-based devices.

See Connecting to the Internet with Raspberry Pi Pico W to learn more about writing applications for your Raspberry Pi Pico W that connect to the internet.

See Raspberry Pi Pico C/C++ SDK to learn more about programming using the SDK, to explore more advanced features, and for complete PDF-based API documentation.

See Online Raspberry Pi Pico SDK API docs for HTML-based API documentation.

Example code

See pico-examples for example code you can build.

Getting the latest SDK code

The master branch of pico-sdk on GitHub contains the latest stable release of the SDK. If you need or want to test upcoming features, you can try the develop branch instead.

Quick-start your own project

These instructions are extremely terse, and Linux-based only. For detailed steps, instructions for other platforms, and just in general, we recommend you see Raspberry Pi Pico C/C++ SDK

  1. Install CMake (at least version 3.13), and GCC cross compiler

    sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
    
  2. Set up your project to point to use the Raspberry Pi Pico SDK

    • Either by cloning the SDK locally (most common) :

      1. git clone this Raspberry Pi Pico SDK repository

      2. Copy pico_sdk_import.cmake from the SDK into your project directory

      3. Set PICO_SDK_PATH to the SDK location in your environment, or pass it (-DPICO_SDK_PATH=) to cmake later.

      4. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize the SDK based on PICO_SDK_PATH
        # note: this must happen before project()
        include(pico_sdk_import.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
    • Or with the Raspberry Pi Pico SDK as a submodule :

      1. Clone the SDK as a submodule called pico-sdk

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize pico-sdk from submodule
        # note: this must happen before project()
        include(pico-sdk/pico_sdk_init.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
    • Or with automatic download from GitHub :

      1. Copy pico_sdk_import.cmake from the SDK into your project directory

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize pico-sdk from GIT
        # (note this can come from environment, CMake cache etc)
        set(PICO_SDK_FETCH_FROM_GIT on)
        
        # pico_sdk_import.cmake is a single file copied from this SDK
        # note: this must happen before project()
        include(pico_sdk_import.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
    • Or by cloning the SDK locally, but without copying pico_sdk_import.cmake:

      1. git clone this Raspberry Pi Pico SDK repository

      2. Setup a CMakeLists.txt like:

        cmake_minimum_required(VERSION 3.13)
        
        # initialize the SDK directly
        include(/path/to/pico-sdk/pico_sdk_init.cmake)
        
        project(my_project)
        
        # initialize the Raspberry Pi Pico SDK
        pico_sdk_init()
        
        # rest of your project
        
  3. Write your code (see pico-examples or the Raspberry Pi Pico C/C++ SDK documentation for more information)

    About the simplest you can do is a single source file (e.g. hello_world.c)

    #include <stdio.h>
    #include "pico/stdlib.h"
    
    int main() {
        setup_default_uart();
        printf("Hello, world!\n");
        return 0;
    }

    And add the following to your CMakeLists.txt:

    add_executable(hello_world
        hello_world.c
    )
    
    # Add pico_stdlib library which aggregates commonly used features
    target_link_libraries(hello_world pico_stdlib)
    
    # create map/bin/hex/uf2 file in addition to ELF.
    pico_add_extra_outputs(hello_world)

    Note this example uses the default UART for stdout; if you want to use the default USB see the hello-usb example.

  4. Setup a CMake build directory. For example, if not using an IDE:

    $ mkdir build
    $ cd build
    $ cmake ..
    

    When building for a board other than the Raspberry Pi Pico, you should pass -DPICO_BOARD=board_name to the cmake command above, e.g. cmake -DPICO_BOARD=pico_w .. to configure the SDK and build options accordingly for that particular board.

    Doing so sets up various compiler defines (e.g. default pin numbers for UART and other hardware) and in certain cases also enables the use of additional libraries (e.g. wireless support when building for PICO_BOARD=pico_w) which cannot be built without a board which provides the requisite functionality.

    For a list of boards defined in the SDK itself, look in this directory which has a header for each named board.

  5. Make your target from the build directory you created.

    $ make hello_world
  6. You now have hello_world.elf to load via a debugger, or hello_world.uf2 that can be installed and run on your Raspberry Pi Pico via drag and drop.

More Repositories

1

linux

Kernel source tree for Raspberry Pi-provided kernel builds. Issues unrelated to the linux kernel should be posted on the community forum at https://forums.raspberrypi.com/
C
10,950
star
2

documentation

The official documentation for Raspberry Pi computers and microcontrollers
Python
5,178
star
3

firmware

This repository contains pre-compiled binaries of the current Raspberry Pi kernel and modules, userspace libraries, and bootloader/GPU firmware.
5,133
star
4

pico-examples

C
2,763
star
5

noobs

NOOBS (New Out Of Box Software) - An easy Operating System install manager for the Raspberry Pi
Makefile
2,208
star
6

userland

Source code for ARM side libraries for interfacing to Raspberry Pi GPU.
C
2,040
star
7

tools

C
1,876
star
8

rpi-imager

The home of Raspberry Pi Imager, a user-friendly tool for creating bootable media for Raspberry Pi devices.
C
1,604
star
9

rpi-eeprom

Installation scripts and binaries for the Raspberry Pi 4 and Raspberry Pi 5 bootloader EEPROMs
Shell
1,257
star
10

pico-micropython-examples

Examples to accompany the "Raspberry Pi Pico Python SDK" book.
Python
948
star
11

usbboot

Raspberry Pi USB booting code, moved from tools repository
C
897
star
12

picamera2

New libcamera based python library
Python
823
star
13

debugprobe

C
730
star
14

hats

C
658
star
15

pico-tflmicro

Pico TensorFlow Lite Port
C++
619
star
16

picotool

C++
549
star
17

Raspberry-Pi-OS-64bit

Repository for containing issues on the 64 bit operating system (as distinct from the 32 bit one)
466
star
18

pico-extras

C
459
star
19

pico-playground

C
434
star
20

quake3

C
390
star
21

rpicam-apps

C++
383
star
22

maynard

Desktop environment for Wayland
C
336
star
23

piserver

Raspberry Pi Server wizard to serve Raspbian to network booting Pis
C++
306
star
24

pico-project-generator

Tool to automatically generate a Pico C SDK Project
Python
294
star
25

pico-bootrom-rp2040

C
271
star
26

raspiraw

Example app directly receiving raw data from CSI2 sensors
C
257
star
27

pico-setup-windows

PowerShell
252
star
28

libcamera

C++
211
star
29

utils

A collection of scripts and simple applications
C
148
star
30

openocd

C
141
star
31

windows-drivers

Windows IOT drivers
C
120
star
32

pico-bootrom-rp2350

C
120
star
33

cmprovision

Provisioning system for CM4 products
PHP
96
star
34

pico-setup

Shell
92
star
35

scratch

Scratch releases
79
star
36

usbbootgui

GUI for booting a Raspberry Pi device like Pi Zero or compute module as a device
M4
76
star
37

rp2350_hacking_challenge

CMake
70
star
38

tinyusb

C
67
star
39

rpi-sense

Sense HAT firmware and driver
Assembly
66
star
40

gpioexpander

Buildroot based ethernet gadget which gives a host access to PIGPIO to control GPIO pins
Makefile
63
star
41

usb-pid

Raspberry Pi Pico PID allocations
63
star
42

pico-vscode

The official VS Code extension for Raspberry Pi Pico development. It includes several features to simplify project creation and deployment.
TypeScript
62
star
43

target_fs

Shell
39
star
44

weston

The Weston Wayland Compositor
C
37
star
45

scriptexecutor

Simple buildroot based system for executing a remote script for manufacture programming
Shell
36
star
46

pico-host-sdl

C
27
star
47

pico-feedback

24
star
48

raspberrypi.github.io

Raspberry Pi GitHub organisations
HTML
20
star
49

pytrack

Python
17
star
50

Pi-Codec

Tools for the IQaudIO Pi-Codec / CodecZero sound cards
16
star
51

skygate

Python
15
star
52

style-guide

14
star
53

bookworm-feedback

13
star
54

CMSIS-RP2xxx-DFP

C
13
star
55

armulet

C++
8
star
56

pylibcamera

Meson
8
star
57

libpisp

C++
7
star
58

pico-sdk-tools

Shell
5
star
59

rpi-sb-provisioner

A minimal-input automatic secure boot provisioning system for Raspberry Pi devices.
Shell
5
star
60

pykms

Meson
2
star
61

FreeRTOS-Kernel

C
1
star
62

sweet-b

C
1
star