Build "Hello World - Raspberry Pi RP2040 Getting Started

Table of Contents

Advertisement

Getting started with Raspberry Pi Pico
The destination for
pico_enable_stdio_usb(hello_world 1)
pico_enable_stdio_uart(hello_world 0)
1. Enable
2. Disable
This means that without changing the C source code, you can change the destination for
Pico Examples:
https://github.com/raspberrypi/pico-examples/tree/master/hello_world/usb/CMakeLists.txt
 1 if (TARGET tinyusb_device)
 2
add_executable(hello_usb
 3
 4
 5
 6
# Pull in our pico_stdlib which aggregates commonly used features
 7
target_link_libraries(hello_usb pico_stdlib)
 8
 9
# enable usb output, disable uart output
10
pico_enable_stdio_usb(hello_usb 1)
11
pico_enable_stdio_uart(hello_usb 0)
12
13
# create map/bin/hex/uf2 file etc.
14
pico_add_extra_outputs(hello_usb)
15
16
# add url via pico_set_program_url
17
example_auto_set_url(hello_usb)
18 elseif(PICO_ON_DEVICE)
19
message(WARNING "not building hello_usb because TinyUSB submodule is not initialized in
 
the SDK")
20 endif()

4.2. Build "Hello World"

As we did for the previous "Blink" example, change directory into the
tree, and run
$ cd hello_world
$ make -j4
Scanning dependencies of target ELF2UF2Build
[
0%] Creating directories for 'ELF2UF2Build'
 
.
 
.
[ 33%] Linking CXX executable hello_usb.elf
[ 33%] Built target hello_usb
 
.
 
.
[100%] Linking CXX executable hello_serial.elf
[100%] Built target hello_serial
This will build two separate examples programs in the
4.2. Build "Hello World"
can be changed using CMake directives, with output directed to UART or USB CDC, or to both,
stdout
output via USB CDC (USB serial)
printf
output via UART
printf
hello_usb.c
)
.
make
Lines 1 - 20
hello_world
and
hello_world/serial/
from UART to USB.
stdio
directory inside the
pico-examples/build
directories.
hello_world/usb/
13

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the RP2040 and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Pico

Table of Contents

Save PDF