and can build it as we did before with our "Hello World" example.
$ mkdir build
$ cd build
$ export PICO_SDK_PATH=../../pico-sdk
$ cmake ..
$ make
IMPORTANT
The SDK builds binaries for the Raspberry Pi Pico by default. To build a binary for a different board, pass the
-DPICO_BOARD=<board> option to CMake, replacing the <board> placeholder with the name of the board you’d like to
target. To build a binary for Pico 2, pass -DPICO_BOARD=pico2. To build a binary for Pico W, pass -DPICO_BOARD=pico_w. To
specify a Wi-Fi network and password that your Pico W should connect to, pass -DWIFI_SSID="Your Network"
-DWIFI_PASSWORD="Your Password".
The make process will produce a number of different files. The important ones are shown in the following table.
File extension Description
.bin Raw binary dump of the program code and data
.elf The full program output, possibly including debug information
.uf2 The program code and data in a UF2 form that you can drag-and-drop on to the device
when it is mounted as a USB drive
.dis A disassembly of the compiled binary
.hex Hexdump of the compiled binary
.map A map file to accompany the .elf file describing where the linker has arranged segments
in memory
NOTE
UF2 (USB Flashing Format) is a Microsoft-developed file format used for flashing Raspberry Pi microcontrollers over
USB. For more information, see the Microsoft UF2 Specification Repo.
NOTE
To build a binary to run in SRAM, rather than Flash memory you can either setup your cmake build with
-DPICO_NO_FLASH=1 or you can add pico_set_binary_type(TARGET_NAME no_flash) to control it on a per binary basis in your
CMakeLists.txt file. You can download the RAM binary to Raspberry Pi microcontrollers via UF2. For example, if there
is no flash chip on your board, you can download a binary that runs on the on-chip RAM using UF2 as it simply
specifies the addresses of where data goes. Note you can only download in to RAM or FLASH, not both.
Debugging your project
Debugging your own project from the command line follows the same processes as we used for the "Hello World"
example back in Debug with SWD.
Need more detail?
There should be enough here to show you how to get started, but you may find yourself wondering why
some of these files and incantations are needed. The Raspberry Pi Pico-series C/C++ SDK book dives
Getting started with Raspberry Pi Pico-series
Manually Create your own Project 40