Skip to content

Commit 7fe60d6

Browse files
committed
RP2350 and SDK 2.0.0 changes
1 parent c95295f commit 7fe60d6

File tree

171 files changed

+25048
-562
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+25048
-562
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
_deps
44
cmake-*
55
build
6+
build-*
67
.DS_Store
78
*.pdf

Diff for: CMakeLists.txt

+31-5
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ cmake_minimum_required(VERSION 3.12)
22

33
# Pull in SDK (must be before project)
44
include(pico_sdk_import.cmake)
5-
65
include(pico_extras_import_optional.cmake)
76

87
project(pico_examples C CXX ASM)
8+
99
set(CMAKE_C_STANDARD 11)
1010
set(CMAKE_CXX_STANDARD 17)
1111

12-
if (PICO_SDK_VERSION_STRING VERSION_LESS "1.3.0")
13-
message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.3.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
12+
if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0")
13+
message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.0.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}")
1414
endif()
1515

1616
set(PICO_EXAMPLES_PATH ${PROJECT_SOURCE_DIR})
@@ -24,11 +24,30 @@ endif()
2424
pico_sdk_init()
2525

2626
include(example_auto_set_url.cmake)
27+
28+
function(add_subdirectory_exclude_platforms NAME)
29+
if (ARGN)
30+
if (PICO_PLATFORM IN_LIST ARGN)
31+
message("Skipping ${NAME} example which is unsupported on this platform")
32+
return()
33+
endif()
34+
foreach(PATTERN IN LISTS ARGN)
35+
string(REGEX MATCH "${PATTERN}" MATCHED "${PICO_PLATFORM}")
36+
if (MATCHED)
37+
message("Skipping ${NAME} example which is unsupported on this platform")
38+
return()
39+
endif()
40+
endforeach()
41+
endif()
42+
add_subdirectory(${NAME})
43+
endfunction()
44+
2745
# Add blink example
28-
add_subdirectory(blink)
46+
add_subdirectory_exclude_platforms(blink)
47+
add_subdirectory_exclude_platforms(blink_simple)
2948

3049
# Add hello world example
31-
add_subdirectory(hello_world)
50+
add_subdirectory_exclude_platforms(hello_world)
3251

3352
add_compile_options(-Wall
3453
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
@@ -40,15 +59,19 @@ endif()
4059

4160
# Hardware-specific examples in subdirectories:
4261
add_subdirectory(adc)
62+
add_subdirectory(bootloaders)
4363
add_subdirectory(clocks)
4464
add_subdirectory(cmake)
65+
add_subdirectory(dcp)
4566
add_subdirectory(divider)
4667
add_subdirectory(dma)
4768
add_subdirectory(flash)
4869
add_subdirectory(gpio)
70+
add_subdirectory(hstx)
4971
add_subdirectory(i2c)
5072
add_subdirectory(interp)
5173
add_subdirectory(multicore)
74+
add_subdirectory(otp)
5275
add_subdirectory(picoboard)
5376
add_subdirectory(pico_w)
5477
add_subdirectory(pio)
@@ -59,5 +82,8 @@ add_subdirectory(spi)
5982
add_subdirectory(system)
6083
add_subdirectory(timer)
6184
add_subdirectory(uart)
85+
add_subdirectory(universal)
6286
add_subdirectory(usb)
6387
add_subdirectory(watchdog)
88+
add_subdirectory(sha)
89+
add_subdirectory(freertos)

Diff for: README.md

+76-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# Raspberry Pi Pico SDK Examples
1+
# Raspberry Pi RP2350 Pico SDK Examples - Early Access
2+
3+
## RP2350 Instructions
4+
5+
Everything below this section is from the stock pico-examples, so ignore URLs etc., but generally instructions are the same.
6+
7+
The Pico SDK default continues to be to build for RP2040 (PICO_PLATFORM=rp2040), so to build for RP2350, you need to pass
8+
`-DPICO_PLATFORM=rp2350` to CMake (or `-DPICO_PLATFORM=rp2350-riscv` for RISC-V).
9+
10+
Most, but not all examples, currently work on RP2350 however you should be able to do a full build with any of the above platforms (PICO_PLATFORM=host however currently fails on some examples)
11+
12+
For RISC-V compilation, you should take a compiler from here: https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable
13+
14+
# Original pico-examples docs
215

316
## Getting started
417

@@ -7,12 +20,13 @@ on getting up and running.
720

821
### First Examples
922

10-
App|Description | Link to prebuilt UF2
11-
---|---|---
12-
[hello_serial](hello_world/serial) | The obligatory Hello World program for Pico (Output over serial version) |
13-
[hello_usb](hello_world/usb) | The obligatory Hello World program for Pico (Output over USB version) | https://rptl.io/pico-hello-usb
14-
[blink](blink) | Blink an LED on and off. Pico W should use [picow_blink](pico_w/wifi/blink). | https://rptl.io/pico-blink
15-
[picow_blink](pico_w/wifi/blink) | Blinks the Pico W on-board LED (which is connected via the WiFi chip). | http://rptl.io/pico-w-blink
23+
App| Description | Link to prebuilt UF2
24+
---|----------------------------------------------------------------------------|---
25+
[hello_serial](hello_world/serial) | The obligatory Hello World program for Pico (Output over serial version) |
26+
[hello_usb](hello_world/usb) | The obligatory Hello World program for Pico (Output over USB version) | https://rptl.io/pico-hello-usb
27+
[blink](blink) | Blink an LED on and off. Works on both boards with regular LEDs and Pico W | https://rptl.io/pico-blink
28+
[blink_simple](blink_simple) | Blink an LED on and off. Does not work on Pico W. | https://rptl.io/pico-blink
29+
[picow_blink](pico_w/wifi/blink) | Blinks the Pico W on-board LED (which is connected via the WiFi chip). | http://rptl.io/pico-w-blink
1630

1731
### ADC
1832

@@ -26,6 +40,11 @@ App|Description
2640
[dma_capture](adc/dma_capture) | Use the DMA to capture many samples from the ADC.
2741
[read_vsys](adc/read_vsys) | Demonstrates how to read VSYS to get the voltage of the power supply.
2842

43+
### Bootloaders (RP2350 Only)
44+
App|Description
45+
---|---
46+
[enc_bootloader](bootloaders/encrypted) | A bootloader which decrypts binaries from flash into SRAM. See the separate [README](bootloaders/encrypted/README.md) for more information
47+
2948
### Clocks
3049

3150
App|Description
@@ -41,6 +60,12 @@ App|Description
4160
---|---
4261
[build_variants](cmake/build_variants) | Builds two version of the same app with different configurations
4362

63+
### DCP
64+
65+
App|Description
66+
---|---
67+
[hello_dcp](dcp/hello_dcp) | Use the double-precision coprocessor directly in assembler.
68+
4469
### DMA
4570

4671
App|Description
@@ -50,6 +75,12 @@ App|Description
5075
[channel_irq](dma/channel_irq) | Use an IRQ handler to reconfigure a DMA channel, in order to continuously drive data through a PIO state machine.
5176
[sniff_crc](dma/sniff_crc) | Use the DMA engine's 'sniff' capability to calculate a CRC32 on a data buffer.
5277

78+
### HSTX
79+
80+
App|Description
81+
---|---
82+
[dvi_out_hstx_encoder](dvi_out_hstx_encoder) `RP2350`| Use the HSTX to output a DVI signal with 3:3:2 RGB
83+
5384
### Flash
5485

5586
App|Description
@@ -59,6 +90,15 @@ App|Description
5990
[program](flash/program) | Erase a flash sector, program one flash page, and read back the data.
6091
[xip_stream](flash/xip_stream) | Stream data using the XIP stream hardware, which allows data to be DMA'd in the background whilst executing code from flash.
6192
[ssi_dma](flash/ssi_dma) | DMA directly from the flash interface (continuous SCK clocking) for maximum bulk read performance.
93+
[runtime_flash_permissions](flash/runtime_flash_permissions) | Demonstrates adding partitions at runtime to change the flash permissions
94+
95+
### FreeRTOS
96+
97+
These examples require you to set the `FREERTOS_KERNEL_PATH` to point to the FreeRTOS Kernel. See https://github.com/FreeRTOS/FreeRTOS-Kernel
98+
99+
App|Description
100+
---|---
101+
[hello_freertos](freertos/hello_freertos) | Examples that demonstrate how run FreeRTOS and tasks on 1 or 2 cores.
62102

63103
### GPIO
64104

@@ -107,6 +147,13 @@ App|Description
107147
[hello_multicore](multicore/hello_multicore) | Launch a function on the second core, printf some messages on each core, and pass data back and forth through the mailbox FIFOs.
108148
[multicore_fifo_irqs](multicore/multicore_fifo_irqs) | On each core, register and interrupt handler for the mailbox FIFOs. Show how the interrupt fires when that core receives a message.
109149
[multicore_runner](multicore/multicore_runner) | Set up the second core to accept, and run, any function pointer pushed into its mailbox FIFO. Push in a few pieces of code and get answers back.
150+
[multicore_doorbell](multicore/multicore_doorbell) | Claims two doorbells for signaling between the cores. Counts how many doorbell IRQs occur on the second core and uses doorbells to coordinate exit.
151+
152+
### OTP
153+
154+
App|Description
155+
---|---
156+
[hello_otp](otp/hello_otp) | Demonstrate reading and writing from the OTP on RP2350, along with some of the features of OTP (error correction and page locking).
110157

111158
### Pico Board
112159

@@ -123,6 +170,7 @@ App|Description
123170
---|---
124171
[picow_access_point](pico_w/wifi/access_point) | Starts a WiFi access point, and fields DHCP requests.
125172
[picow_blink](pico_w/wifi/blink) | Blinks the on-board LED (which is connected via the WiFi chip).
173+
[picow_blink_slow_clock](pico_w/wifi/blink_slow_clock) | Blinks the on-board LED (which is connected via the WiFi chip) with a slower system clock to show how to reconfigure communication with the WiFi chip under those circumstances
126174
[picow_iperf_server](pico_w/wifi/iperf) | Runs an "iperf" server for WiFi speed testing.
127175
[picow_ntp_client](pico_w/wifi/ntp_client) | Connects to an NTP server to fetch and display the current time.
128176
[picow_tcp_client](pico_w/wifi/tcp_client) | A simple TCP client. You can run [python_test_tcp_server.py](pico_w/wifi/python_test_tcp/python_test_tcp_server.py) for it to connect to.
@@ -136,7 +184,7 @@ App|Description
136184
#### FreeRTOS examples
137185

138186
These are examples of integrating Pico W networking under FreeRTOS, and require you to set the `FREERTOS_KERNEL_PATH`
139-
to point to the FreeRTOS Kernel.
187+
to point to the FreeRTOS Kernel. See https://github.com/FreeRTOS/FreeRTOS-Kernel
140188

141189
App|Description
142190
---|---
@@ -237,6 +285,7 @@ App|Description
237285
[pwm](pio/pwm) | Pulse width modulation on PIO. Use it to gradually fade the brightness of an LED.
238286
[spi](pio/spi) | Use PIO to erase, program and read an external SPI flash chip. A second example runs a loopback test with all four CPHA/CPOL combinations.
239287
[squarewave](pio/squarewave) | Drive a fast square wave onto a GPIO. This example accesses low-level PIO registers directly, instead of using the SDK functions.
288+
[squarewave_div_sync](pio/squarewave) | Generates a square wave on three GPIOs and synchronises the divider on all the state machines
240289
[st7789_lcd](pio/st7789_lcd) | Set up PIO for 62.5 Mbps serial output, and use this to display a spinning image on a ST7789 serial LCD.
241290
[quadrature_encoder](pio/quadrature_encoder) | A quadrature encoder using PIO to maintain counts independent of the CPU.
242291
[quadrature_encoder_substep](pio/quadrature_encoder_substep) | High resolution speed measurement using a standard quadrature encoder
@@ -267,6 +316,13 @@ App|Description
267316
[rtc_alarm](rtc/rtc_alarm) | Set an alarm on the RTC to trigger an interrupt at a date/time 5 seconds into the future.
268317
[rtc_alarm_repeat](rtc/rtc_alarm_repeat) | Trigger an RTC interrupt once per minute.
269318

319+
### SHA-256
320+
321+
App|Description
322+
---|---
323+
[hello_sha256](sha/sha256) | Demonstrates how to use the pico_sha256 library to calculate a checksum using the hardware in rp2350
324+
[mbedtls_sha256](sha/mbedtls_sha256) | Demonstrates using the SHA-256 hardware acceleration in mbedtls
325+
270326
### SPI
271327

272328
App|Description
@@ -283,7 +339,9 @@ App|Description
283339

284340
App|Description
285341
---|---
342+
[boot_info](system/boot_info) | Demonstrate how to read and interpret sys info boot info.
286343
[hello_double_tap](system/hello_double_tap) | An LED blink with the `pico_bootsel_via_double_reset` library linked. This enters the USB bootloader when it detects the system being reset twice in quick succession, which is useful for boards with a reset button but no BOOTSEL button.
344+
[rand](system/rand) | Demonstrate how to use the pico random number functions.
287345
[narrow_io_write](system/narrow_io_write) | Demonstrate the effects of 8-bit and 16-bit writes on a 32-bit IO register.
288346
[unique_board_id](system/unique_board_id) | Read the 64 bit unique ID from external flash, which serves as a unique identifier for the board.
289347

@@ -303,6 +361,16 @@ App|Description
303361
[lcd_uart](uart/lcd_uart) | Display text and symbols on a 16x02 RGB LCD display via UART
304362
[uart_advanced](uart/uart_advanced) | Use some other UART features like RX interrupts, hardware control flow, and data formats other than 8n1.
305363

364+
### Universal
365+
366+
These are examples of how to build universal binaries which run on RP2040, and RP2350 Arm & RISC-V.
367+
These require you to set `PICO_ARM_TOOLCHAIN_PATH` and `PICO_RISCV_TOOLCHAIN_PATH` to appropriate paths, to ensure you have compilers for both architectures.
368+
369+
App|Description
370+
---|---
371+
[hello_universal](universal/hello_universal) | The obligatory Hello World program for Pico (USB and serial output). On RP2350 it will reboot to the other architecture after every 10 prints.
372+
[nuke_universal](universal/CMakeLists.txt#L107) | Same as the [nuke](flash/nuke) binary, but universal. On RP2350 runs as a packaged SRAM binary, so is written to flash and copied to SRAM by the bootloader
373+
306374
### USB Device
307375

308376
#### TinyUSB Examples

Diff for: adc/CMakeLists.txt

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
if (NOT PICO_NO_HARDWARE)
2-
add_subdirectory(adc_console)
3-
add_subdirectory(dma_capture)
4-
add_subdirectory(hello_adc)
5-
add_subdirectory(joystick_display)
6-
add_subdirectory(onboard_temperature)
7-
add_subdirectory(microphone_adc)
8-
add_subdirectory(read_vsys)
9-
endif ()
1+
if (TARGET hardware_adc)
2+
add_subdirectory_exclude_platforms(adc_console)
3+
add_subdirectory_exclude_platforms(dma_capture)
4+
add_subdirectory_exclude_platforms(hello_adc)
5+
add_subdirectory_exclude_platforms(joystick_display)
6+
add_subdirectory_exclude_platforms(onboard_temperature)
7+
add_subdirectory_exclude_platforms(microphone_adc)
8+
add_subdirectory_exclude_platforms(read_vsys)
9+
else()
10+
message("Skipping ADC examples as hardware_adc is unavailable on this platform")
11+
endif()

Diff for: adc/adc_console/adc_console.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void printhelp() {
1717
void __not_in_flash_func(adc_capture)(uint16_t *buf, size_t count) {
1818
adc_fifo_setup(true, false, 0, false, false);
1919
adc_run(true);
20-
for (int i = 0; i < count; i = i + 1)
20+
for (size_t i = 0; i < count; i = i + 1)
2121
buf[i] = adc_fifo_get_blocking();
2222
adc_run(false);
2323
adc_fifo_drain();

Diff for: adc/joystick_display/joystick_display.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ int main() {
2828
uint bar_x_pos = adc_x_raw * bar_width / adc_max;
2929
uint bar_y_pos = adc_y_raw * bar_width / adc_max;
3030
printf("\rX: [");
31-
for (int i = 0; i < bar_width; ++i)
31+
for (uint i = 0; i < bar_width; ++i)
3232
putchar( i == bar_x_pos ? 'o' : ' ');
3333
printf("] Y: [");
34-
for (int i = 0; i < bar_width; ++i)
34+
for (uint i = 0; i < bar_width; ++i)
3535
putchar( i == bar_y_pos ? 'o' : ' ');
3636
printf("]");
3737
sleep_ms(50);

Diff for: adc/read_vsys/read_vsys.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ int main() {
2828
}
2929
#endif
3030

31-
bool old_battery_status;
32-
float old_voltage;
31+
bool old_battery_status = false;
3332
bool battery_status = true;
33+
float old_voltage = -1;
3434
char *power_str = "UNKNOWN";
3535

3636
while(true) {
@@ -50,7 +50,7 @@ int main() {
5050
if (battery_status && voltage_return == PICO_OK) {
5151
const float min_battery_volts = 3.0f;
5252
const float max_battery_volts = 4.2f;
53-
int percent_val = ((voltage - min_battery_volts) / (max_battery_volts - min_battery_volts)) * 100;
53+
int percent_val = (int) (((voltage - min_battery_volts) / (max_battery_volts - min_battery_volts)) * 100);
5454
snprintf(percent_buf, sizeof(percent_buf), " (%d%%)", percent_val);
5555
}
5656

Diff for: blink_simple/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
add_executable(blink_simple
2+
blink_simple.c
3+
)
4+
5+
# pull in common dependencies
6+
target_link_libraries(blink_simple pico_stdlib)
7+
8+
# create map/bin/hex/uf2 file etc.
9+
pico_add_extra_outputs(blink_simple)
10+
11+
# call pico_set_program_url to set path to example on github, so users can find the source for an example via picotool
12+
example_auto_set_url(blink_simple)

Diff for: blink_simple/blink_simple.c

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
#include "pico/stdlib.h"
8+
9+
#ifndef LED_DELAY_MS
10+
#define LED_DELAY_MS 250
11+
#endif
12+
13+
// Initialize the GPIO for the LED
14+
void pico_led_init(void) {
15+
#ifdef PICO_DEFAULT_LED_PIN
16+
// A device like Pico that uses a GPIO for the LED will define PICO_DEFAULT_LED_PIN
17+
// so we can use normal GPIO functionality to turn the led on and off
18+
gpio_init(PICO_DEFAULT_LED_PIN);
19+
gpio_set_dir(PICO_DEFAULT_LED_PIN, GPIO_OUT);
20+
#endif
21+
}
22+
23+
// Turn the LED on or off
24+
void pico_set_led(bool led_on) {
25+
#if defined(PICO_DEFAULT_LED_PIN)
26+
// Just set the GPIO on or off
27+
gpio_put(PICO_DEFAULT_LED_PIN, led_on);
28+
#endif
29+
}
30+
31+
int main() {
32+
pico_led_init();
33+
while (true) {
34+
pico_set_led(true);
35+
sleep_ms(LED_DELAY_MS);
36+
pico_set_led(false);
37+
sleep_ms(LED_DELAY_MS);
38+
}
39+
}

Diff for: bootloaders/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory_exclude_platforms(encrypted host rp2040 rp2350-riscv)

0 commit comments

Comments
 (0)