Name Date Size

..27-Apr.-20224 KiB

.github/H01-Nov.-20214 KiB

.gitignoreH A D18-Aug.-202138

.gitmodulesH A D30-Jun.-2022288

cmake/H18-Aug.-20214 KiB

CMakeLists.txtH A D18-May-20221.8 KiB

CONTRIBUTING.mdH A D01-Nov.-20212.2 KiB

docs/H30-Jun.-20224 KiB

external/H18-May-20224 KiB

lib/H30-Jun.-20224 KiB

LICENSE.TXTH A D18-Aug.-20211.5 KiB

pico_sdk_init.cmakeH A D18-May-20223.2 KiB

pico_sdk_version.cmakeH A D30-Jun.-20221.3 KiB

README.mdH A D30-Jun.-20226.2 KiB

src/H01-Nov.-20214 KiB

test/H30-Jun.-20224 KiB

tools/H30-Jun.-20224 KiB

README.md

1# Raspberry Pi Pico SDK
2
3The Raspberry Pi Pico SDK (henceforth the SDK) provides the headers, libraries and build system
4necessary to write programs for the RP2040-based devices such as the Raspberry Pi Pico
5in C, C++ or assembly language.
6
7The SDK is designed to provide an API and programming environment that is familiar both to non-embedded C developers and embedded C developers alike.
8A single program runs on the device at a time and starts with a conventional `main()` method. Standard C/C++ libraries are supported along with
9C level libraries/APIs for accessing all of the RP2040's hardware include PIO (Programmable IO).
10
11Additionally the SDK provides higher level libraries for dealing with timers, synchronization, USB (TinyUSB) and multi-core programming
12along with various utilities.
13
14The SDK can be used to build anything from simple applications, to fully fledged runtime environments such as MicroPython, to low level software
15such as RP2040's on-chip bootrom itself.
16
17Additional libraries/APIs that are not yet ready for inclusion in the SDK can be found in [pico-extras](https://github.com/raspberrypi/pico-extras).
18
19# Documentation
20
21See [Getting Started with the Raspberry Pi Pico](https://rptl.io/pico-get-started) for information on how to setup your
22hardware, IDE/environment and for how to build and debug software for the Raspberry Pi Pico
23and other RP2040-based devices.
24
25See [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) to learn more about programming using the
26SDK, to explore more advanced features, and for complete PDF-based API documentation.
27
28See [Online Raspberry Pi Pico SDK API docs](https://rptl.io/pico-doxygen) for HTML-based API documentation.
29
30# Example code
31
32See [pico-examples](https://github.com/raspberrypi/pico-examples) for example code you can build.
33
34# Quick-start your own project
35
36These instructions are extremely terse, and Linux-based only. For detailed steps,
37instructions for other platforms, and just in general, we recommend you see [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk)
38
391. Install CMake (at least version 3.13), and GCC cross compiler
40   ```
41   sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib
42   ```
431. Set up your project to point to use the Raspberry Pi Pico SDK
44
45   * Either by cloning the SDK locally (most common) :
46      1. `git clone` this Raspberry Pi Pico SDK repository
47      1. Copy [pico_sdk_import.cmake](https://github.com/raspberrypi/pico-sdk/blob/master/external/pico_sdk_import.cmake)
48         from the SDK into your project directory
49      2. Set `PICO_SDK_PATH` to the SDK location in your environment, or pass it (`-DPICO_SDK_PATH=`) to cmake later.
50      3. Setup a `CMakeLists.txt` like:
51
52          ```cmake
53          cmake_minimum_required(VERSION 3.13)
54
55          # initialize the SDK based on PICO_SDK_PATH
56          # note: this must happen before project()
57          include(pico_sdk_import.cmake)
58
59          project(my_project)
60
61          # initialize the Raspberry Pi Pico SDK
62          pico_sdk_init()
63
64          # rest of your project
65
66          ```
67
68   * Or with the Raspberry Pi Pico SDK as a submodule :
69      1. Clone the SDK as a submodule called `pico-sdk`
70      1. Setup a `CMakeLists.txt` like:
71
72          ```cmake
73          cmake_minimum_required(VERSION 3.13)
74
75          # initialize pico-sdk from submodule
76          # note: this must happen before project()
77          include(pico-sdk/pico_sdk_init.cmake)
78
79          project(my_project)
80
81          # initialize the Raspberry Pi Pico SDK
82          pico_sdk_init()
83
84          # rest of your project
85
86          ```
87
88   * Or with automatic download from GitHub :
89      1. Copy [pico_sdk_import.cmake](https://github.com/raspberrypi/pico-sdk/blob/master/external/pico_sdk_import.cmake)
90         from the SDK into your project directory
91      1. Setup a `CMakeLists.txt` like:
92
93          ```cmake
94          cmake_minimum_required(VERSION 3.13)
95
96          # initialize pico-sdk from GIT
97          # (note this can come from environment, CMake cache etc)
98          set(PICO_SDK_FETCH_FROM_GIT on)
99
100          # pico_sdk_import.cmake is a single file copied from this SDK
101          # note: this must happen before project()
102          include(pico_sdk_import.cmake)
103
104          project(my_project)
105
106          # initialize the Raspberry Pi Pico SDK
107          pico_sdk_init()
108
109          # rest of your project
110
111          ```
112
113   * Or by cloning the SDK locally, but without copying `pico_sdk_import.cmake`:
114       1. `git clone` this Raspberry Pi Pico SDK repository
115       2. Setup a `CMakeLists.txt` like:
116
117           ```cmake
118           cmake_minimum_required(VERSION 3.13)
119 
120           # initialize the SDK directly
121           include(/path/to/pico-sdk/pico_sdk_init.cmake)
122 
123           project(my_project)
124 
125           # initialize the Raspberry Pi Pico SDK
126           pico_sdk_init()
127 
128           # rest of your project
129 
130           ```
1311. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
132
133   About the simplest you can do is a single source file (e.g. hello_world.c)
134
135   ```c
136   #include <stdio.h>
137   #include "pico/stdlib.h"
138
139   int main() {
140       setup_default_uart();
141       printf("Hello, world!\n");
142       return 0;
143   }
144   ```
145   And add the following to your `CMakeLists.txt`:
146
147   ```cmake
148   add_executable(hello_world
149       hello_world.c
150   )
151
152   # Add pico_stdlib library which aggregates commonly used features
153   target_link_libraries(hello_world pico_stdlib)
154
155   # create map/bin/hex/uf2 file in addition to ELF.
156   pico_add_extra_outputs(hello_world)
157   ```
158
159   Note this example uses the default UART for _stdout_;
160   if you want to use the default USB see the [hello-usb](https://github.com/raspberrypi/pico-examples/tree/master/hello_world/usb) example.
161
162
1631. Setup a CMake build directory.
164      For example, if not using an IDE:
165      ```
166      $ mkdir build
167      $ cd build
168      $ cmake ..
169      ```
170
1711. Make your target from the build directory you created.
172      ```sh
173      $ make hello_world
174      ```
175
1761. 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.
177