Skip to content

Commit

Permalink
boards: Add initial support for the Raspberry Pi Pico 2
Browse files Browse the repository at this point in the history
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
raspberrypi/pico-sdk#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 <[email protected]>
Signed-off-by: Benjamin Cabé <[email protected]>
  • Loading branch information
kartben committed Dec 23, 2024
1 parent 05e0aad commit 5c39bb2
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 75 deletions.
30 changes: 30 additions & 0 deletions boards/raspberrypi/common/rpi_pico-led.dtsi
Original file line number Diff line number Diff line change
@@ -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;
};
};
56 changes: 56 additions & 0 deletions boards/raspberrypi/common/rpi_pico-pinctrl-common.dtsi
Original file line number Diff line number Diff line change
@@ -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;
};
};
};
2 changes: 2 additions & 0 deletions boards/raspberrypi/rpi_pico/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ hardware features:
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi-pio`

.. _rpi_pico_pin_mapping:

Pin Mapping
===========

Expand Down
51 changes: 1 addition & 50 deletions boards/raspberrypi/rpi_pico/rpi_pico-pinctrl.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -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"
25 changes: 1 addition & 24 deletions boards/raspberrypi/rpi_pico/rpi_pico.dts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 9 additions & 0 deletions boards/raspberrypi/rpi_pico2/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions boards/raspberrypi/rpi_pico2/Kconfig.rpi_pico2
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions boards/raspberrypi/rpi_pico2/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
board:
name: rpi_pico2
full_name: Raspberry Pi Pico 2
vendor: raspberrypi
socs:
- name: rp2350a
Binary file not shown.
87 changes: 87 additions & 0 deletions boards/raspberrypi/rpi_pico2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -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::
8 changes: 8 additions & 0 deletions boards/raspberrypi/rpi_pico2/rpi_pico2-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -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"
Loading

0 comments on commit 5c39bb2

Please sign in to comment.