boards: Add initial support for the Raspberry Pi Pico 2

The Raspberry Pi Pico 2 is Raspberry Pi's first board fitted with their
RP2350A SoC.

This adds a minimal board definition, sufficient to build and run
`samples/hello_world` and `samples/basic/blinky` on the board. Images
can be run on the target using OpenOCD. Raspberry Pi's `picotool` can
create a UF2 binary, which ensures that errata RP2350-E10 is avoided
e.g.

```
> picotool uf2 convert build\rpi_pico2\hello_world\zephyr\zephyr.elf \
    build\rpi_pico2\hello_world\zephyr\zephyr.uf2 \
    --family rp2350-arm-s --abs-block`
```

Raspberry Pi Pico 2 is a low-cost, high-performance microcontroller
board with flexible digital interfaces. Key features include:

- RP2350A microcontroller chip designed by Raspberry Pi in the United
  Kingdom
- Dual Cortex-M33 or Hazard3 processors at up to 150MHz
- 520KB of SRAM, and 4MB of on-board flash memory
- USB 1.1 with device and host support
- Low-power sleep and dormant modes
- Drag-and-drop programming using mass storage over USB
- 26x multi-function GPIO pins including 3 that can be used for ADC
- 2x SPI, 2x I2C, 2x UART, 3x 12-bit 500ksps Analogue to Digital
  Converter (ADC), 24x controllable PWM channels
- 2x Timer with 4 alarms, 1x AON Timer
- Temperature sensor
- 3x Programmable IO (PIO) blocks, 12 state machines total for custom
  peripheral support
    - Flexible, user-programmable high-speed IO
    - Can emulate interfaces such as SD Card and VGA

The Raspberry Pi Pico 2 comes as a castellated module which allows
soldering direct to carrier boards.

Only enable timer 0 for now. Timer 1 won't work correctly until the
rpi_pico HAL has picked up the fix for `hardware_alarm_irq_handler`. See
https://github.com/raspberrypi/pico-sdk/pull/1949 .

Added some documentation for the board itself (mostly aiming to refer to
canonical sources of information rather duplicate). Add entries in the
release notes where applicable.

boards/raspberrypi/rpi_pico2/doc/img/rpi_pico2.webp is a cropped and
compressed version of https://www.raspberrypi.com/documentation/microcontrollers/images/pico-2.png
which is released under the CC-BY-SA-4.0 license. See https://github.com/raspberrypi/documentation/blob/develop/LICENSE.md

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé 2024-08-21 22:05:51 +01:00 committed by Benjamin Cabé
commit 5c39bb22a0
17 changed files with 412 additions and 75 deletions

View file

@ -0,0 +1,30 @@
/*
* Copyright (c) 2021 Yonatan Schachter
*
* SPDX-License-Identifier: Apache-2.0
*/
/* Pico and Pico 2 boards (but not Pico W) have a common LED placement. */
/ {
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
label = "LED";
};
};
pwm_leds {
compatible = "pwm-leds";
status = "disabled";
pwm_led0: pwm_led_0 {
pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM_LED";
};
};
aliases {
led0 = &led0;
pwm-led0 = &pwm_led0;
};
};

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2021, Yonatan Schachter
* SPDX-License-Identifier: Apache-2.0
*/
/* The Pico and Pico 2 are pin compatible. */
&pinctrl {
uart0_default: uart0_default {
group1 {
pinmux = <UART0_TX_P0>;
};
group2 {
pinmux = <UART0_RX_P1>;
input-enable;
};
};
i2c0_default: i2c0_default {
group1 {
pinmux = <I2C0_SDA_P4>, <I2C0_SCL_P5>;
input-enable;
input-schmitt-enable;
};
};
i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_P6>, <I2C1_SCL_P7>;
input-enable;
input-schmitt-enable;
};
};
spi0_default: spi0_default {
group1 {
pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
};
group2 {
pinmux = <SPI0_RX_P16>;
input-enable;
};
};
pwm_ch4b_default: pwm_ch4b_default {
group1 {
pinmux = <PWM_4B_P25>;
};
};
adc_default: adc_default {
group1 {
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
input-enable;
};
};
};

View file

@ -96,6 +96,8 @@ hardware features:
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi-pio`
.. _rpi_pico_pin_mapping:
Pin Mapping
===========

View file

@ -5,53 +5,4 @@
#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
&pinctrl {
uart0_default: uart0_default {
group1 {
pinmux = <UART0_TX_P0>;
};
group2 {
pinmux = <UART0_RX_P1>;
input-enable;
};
};
i2c0_default: i2c0_default {
group1 {
pinmux = <I2C0_SDA_P4>, <I2C0_SCL_P5>;
input-enable;
input-schmitt-enable;
};
};
i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_P6>, <I2C1_SCL_P7>;
input-enable;
input-schmitt-enable;
};
};
spi0_default: spi0_default {
group1 {
pinmux = <SPI0_CSN_P17>, <SPI0_SCK_P18>, <SPI0_TX_P19>;
};
group2 {
pinmux = <SPI0_RX_P16>;
input-enable;
};
};
pwm_ch4b_default: pwm_ch4b_default {
group1 {
pinmux = <PWM_4B_P25>;
};
};
adc_default: adc_default {
group1 {
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
input-enable;
};
};
};
#include "../common/rpi_pico-pinctrl-common.dtsi"

View file

@ -7,27 +7,4 @@
/dts-v1/;
#include "rpi_pico-common.dtsi"
/ {
leds {
compatible = "gpio-leds";
led0: led_0 {
gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>;
label = "LED";
};
};
pwm_leds {
compatible = "pwm-leds";
status = "disabled";
pwm_led0: pwm_led_0 {
pwms = <&pwm 9 PWM_MSEC(20) PWM_POLARITY_NORMAL>;
label = "PWM_LED";
};
};
aliases {
led0 = &led0;
pwm-led0 = &pwm_led0;
};
};
#include "../common/rpi_pico-led.dtsi"

View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Andrew Featherstone
# SPDX-License-Identifier: Apache-2.0
if BOARD_RPI_PICO2
config USB_SELF_POWERED
default n
endif # BOARD_RPI_PICO2

View file

@ -0,0 +1,5 @@
# Copyright (c) 2024 Andrew Featherstone
# SPDX-License-Identifier: Apache-2.0
config BOARD_RPI_PICO2
select SOC_RP2350A_M33 if BOARD_RPI_PICO2_RP2350A_M33

View file

@ -0,0 +1,6 @@
board:
name: rpi_pico2
full_name: Raspberry Pi Pico 2
vendor: raspberrypi
socs:
- name: rp2350a

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -0,0 +1,87 @@
.. zephyr:board:: rpi_pico2
Overview
********
The Raspberry Pi Pico 2 is the second-generation product in the Raspberry Pi
Pico family. From the `Raspberry Pi website <https://www.raspberrypi.com/documentation/microcontrollers/pico-series.html>`_ is referred to as Pico 2.
There are many limitations of the board currently. Including but not limited to:
- The Zephyr build only supports configuring the RP2350A with the Cortex-M33 cores.
- As with the Pico 1, there's no support for running any code on the second core.
Hardware
********
- Dual Cortex-M33 or Hazard3 processors at up to 150MHz
- 520KB of SRAM, and 4MB of on-board flash memory
- USB 1.1 with device and host support
- Low-power sleep and dormant modes
- Drag-and-drop programming using mass storage over USB
- 26 multi-function GPIO pins including 3 that can be used for ADC
- 2 SPI, 2 I2C, 2 UART, 3 12-bit 500ksps Analogue to Digital - Converter (ADC), 24 controllable PWM channels
- 2 Timer with 4 alarms, 1 AON Timer
- Temperature sensor
- 3 Programmable IO (PIO) blocks, 12 state machines total for custom peripheral support
- Flexible, user-programmable high-speed IO
- Can emulate interfaces such as SD Card and VGA
Supported Features
==================
The ``rpi_pico2/rp2350a/m33`` board target supports the following
hardware features:
.. list-table::
:header-rows: 1
* - Peripheral
- Kconfig option
- Devicetree compatible
* - NVIC
- N/A
- :dtcompatible:`arm,v8m-nvic`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`raspberrypi,pico-adc`
* - Clock controller
- :kconfig:option:`CONFIG_CLOCK_CONTROL`
- :dtcompatible:`raspberrypi,pico-clock-controller`
* - Counter
- :kconfig:option:`CONFIG_COUNTER`
- :dtcompatible:`raspberrypi,pico-timer`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`raspberrypi,pico-gpio`
* - HWINFO
- :kconfig:option:`CONFIG_HWINFO`
- N/A
* - I2C
- :kconfig:option:`CONFIG_I2C`
- :dtcompatible:`snps,designware-i2c`
* - PWM
- :kconfig:option:`CONFIG_PWM`
- :dtcompatible:`raspberrypi,pico-pwm`
* - SPI
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`raspberrypi,pico-uart`
Connections and IOs
===================
The default pin mapping is unchanged from the Pico 1 (see :ref:`rpi_pico_pin_mapping`).
Programming and Debugging
*************************
As with the Pico 1, the SWD interface can be used to program and debug the
device, e.g. using OpenOCD with the `Raspberry Pi Debug Probe <https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html>`_ .
References
**********
.. target-notes::

View file

@ -0,0 +1,8 @@
/*
* Copyright (c) 2024, Andrew Featherstone
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2350a-pinctrl.h>
#include "../common/rpi_pico-pinctrl-common.dtsi"

View file

@ -0,0 +1,144 @@
/*
* Copyright (c) 2024 Andrew Featherstone
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <freq.h>
#include <zephyr/dt-bindings/i2c/i2c.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include "rpi_pico2-pinctrl.dtsi"
#include "../common/rpi_pico-led.dtsi"
/ {
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,code-partition = &code_partition;
};
aliases {
watchdog0 = &wdt0;
};
pico_header: connector {
compatible = "raspberrypi,pico-header";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map = <0 0 &gpio0 0 0>, /* GP0 */
<1 0 &gpio0 1 0>, /* GP1 */
<2 0 &gpio0 2 0>, /* GP2 */
<3 0 &gpio0 3 0>, /* GP3 */
<4 0 &gpio0 4 0>, /* GP4 */
<5 0 &gpio0 5 0>, /* GP5 */
<6 0 &gpio0 6 0>, /* GP6 */
<7 0 &gpio0 7 0>, /* GP7 */
<8 0 &gpio0 8 0>, /* GP8 */
<9 0 &gpio0 9 0>, /* GP9 */
<10 0 &gpio0 10 0>, /* GP10 */
<11 0 &gpio0 11 0>, /* GP11 */
<12 0 &gpio0 12 0>, /* GP12 */
<13 0 &gpio0 13 0>, /* GP13 */
<14 0 &gpio0 14 0>, /* GP14 */
<15 0 &gpio0 15 0>, /* GP15 */
<16 0 &gpio0 16 0>, /* GP16 */
<17 0 &gpio0 17 0>, /* GP17 */
<18 0 &gpio0 18 0>, /* GP18 */
<19 0 &gpio0 19 0>, /* GP19 */
<20 0 &gpio0 20 0>, /* GP20 */
<21 0 &gpio0 21 0>, /* GP21 */
<22 0 &gpio0 22 0>, /* GP22 */
<26 0 &gpio0 26 0>, /* GP26 */
<27 0 &gpio0 27 0>, /* GP27 */
<28 0 &gpio0 28 0>; /* GP28 */
};
};
&flash0 {
reg = <0x10000000 DT_SIZE_M(4)>;
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
/* Reserved memory for an image definition block. The block is much
* smaller than 256 bytes, but in practice the linker places the vector
* table at a much larger alignment offset.
*/
image_def: partition@0 {
label = "image_def";
reg = <0x00000000 0x100>;
read-only;
};
/*
* Usable flash. Starts at 0x100, after the image definition block.
* The partition size is 4MB minus the 0x100 bytes taken by the
* image definition.
*/
code_partition: partition@100 {
label = "code-partition";
reg = <0x100 (DT_SIZE_M(4) - 0x100)>;
read-only;
};
};
};
&uart0 {
current-speed = <115200>;
status = "okay";
pinctrl-0 = <&uart0_default>;
pinctrl-names = "default";
};
&gpio0 {
status = "okay";
};
&spi0 {
clock-frequency = <DT_FREQ_M(8)>;
pinctrl-0 = <&spi0_default>;
pinctrl-names = "default";
};
&i2c0 {
clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c0_default>;
pinctrl-names = "default";
status = "okay";
};
&i2c1 {
clock-frequency = <I2C_BITRATE_STANDARD>;
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
status = "okay";
};
&adc {
pinctrl-0 = <&adc_default>;
pinctrl-names = "default";
status = "okay";
};
&pwm {
pinctrl-0 = <&pwm_ch4b_default>;
pinctrl-names = "default";
divider-int-0 = <255>;
};
&timer0 {
status = "okay";
};
zephyr_udc0: &usbd {
status = "okay";
};
pico_serial: &uart0 {};

View file

@ -0,0 +1,22 @@
/*
* Copyright (c) 2024 Andrew Featherstone
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
/* The build system assumes that there's a cpucluster-specific file.
*
* This file provides composition of the device tree:
* 1. The common features of the SoC
* 2. Core-specific configuration.
* 3. Board-specific configuration.
*/
#include <raspberrypi/rpi_pico/rp2350a.dtsi>
#include <raspberrypi/rpi_pico/m33.dtsi>
/* there's nothing specific to the Cortex-M33 cores vs the (not yet
* implemented) Hazard3 cores.
*/
#include "rpi_pico2.dtsi"

View file

@ -0,0 +1,20 @@
identifier: rpi_pico2/rp2350a/m33
name: Raspberry Pi Pico 2 (Cortex-M33)
type: mcu
arch: arm
flash: 4096
ram: 520
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- clock
- counter
- gpio
- hwinfo
- i2c
- pwm
- spi
- uart

View file

@ -0,0 +1,12 @@
# This configuration is orthogonal to whether the Cortex-M33 or Hazard3 cores
# are in use, but Zephyr does not support providing a qualifier-agnostic
# _defconfig file.
CONFIG_CLOCK_CONTROL=y
CONFIG_CONSOLE=y
CONFIG_GPIO=y
CONFIG_RESET=y
CONFIG_SERIAL=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
CONFIG_UART_CONSOLE=y
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_USE_DT_CODE_PARTITION=y

View file

@ -57,6 +57,11 @@ Devicetree
the devicetree property ``poll-interval-ms``.
In interrupt mode, the devicetree property ``repeat`` is supported.
Raspberry Pi
============
* ``CONFIG_SOC_SERIES_RP2XXX`` is renamed to :kconfig:option:`CONFIG_SOC_SERIES_RP2040`.
STM32
=====
@ -64,7 +69,6 @@ STM32
as it was introduced earlier.
The Kconfig method for configuration is now removed.
Modules
*******

View file

@ -104,10 +104,14 @@ Boards & SoC Support
* Added support for these SoC series:
* Added Raspberry Pi RP2350
* Made these changes in other SoC series:
* Added support for these boards:
* :zephyr:board:`Raspberry Pi Pico 2 <rpi_pico2>`: ``rpi_pico2``
* Made these board changes:
* All HWMv1 board name aliases which were added as deprecated in v3.7 are now removed