Skip to content

Commit

Permalink
boards: pimoroni: pico_plus2: Add Pimoroni Pico Plus2 board
Browse files Browse the repository at this point in the history
Pinoroni Pico Plus2 is an RP2350B based board that has
more rich I/O, RAM, and Flash than the original Raspberry Pi Pico2.

Signed-off-by: TOKITA Hiroshi <[email protected]>
  • Loading branch information
soburi committed Dec 7, 2024
1 parent 0eca523 commit 23b9588
Show file tree
Hide file tree
Showing 20 changed files with 636 additions and 0 deletions.
9 changes: 9 additions & 0 deletions boards/pimoroni/pico_plus2/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024 TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

if BOARD_PICO_PLUS2

config USB_SELF_POWERED
default n

endif # BOARD_PICO_PLUS2
5 changes: 5 additions & 0 deletions boards/pimoroni/pico_plus2/Kconfig.pico_plus2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (c) 2024 TOKITA Hiroshi
# SPDX-License-Identifier: Apache-2.0

config BOARD_PICO_PLUS2
select SOC_RP2350B_M33 if BOARD_PICO_PLUS2_RP2350B_M33
18 changes: 18 additions & 0 deletions boards/pimoroni/pico_plus2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: Apache-2.0

if("${RPI_PICO_DEBUG_ADAPTER}" STREQUAL "")
set(RPI_PICO_DEBUG_ADAPTER "cmsis-dap")
endif()

board_runner_args(openocd --cmd-pre-init "source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]")
board_runner_args(openocd --cmd-pre-init "source [find target/rp2350.cfg]")

# The adapter speed is expected to be set by interface configuration.
# The Raspberry Pi's OpenOCD fork doesn't, so match their documentation at
# https://www.raspberrypi.com/documentation/microcontrollers/debug-probe.html#debugging-with-swd
board_runner_args(openocd --cmd-pre-init "set_adapter_speed_if_not_set 5000")

board_runner_args(uf2 "--board-id=RP2350")

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)
6 changes: 6 additions & 0 deletions boards/pimoroni/pico_plus2/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
board:
name: pico_plus2
full_name: Pimoroni Pico Plus2
vendor: pimoroni
socs:
- name: rp2350b
215 changes: 215 additions & 0 deletions boards/pimoroni/pico_plus2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,215 @@
.. zephyr:board:: pico_plus2
Overview
********

The Raspberry Pi Pico and Pico W are small, low-cost, versatile boards from
Raspberry Pi. They are equipped with an RP2040 SoC, an on-board LED,
a USB connector, and an SWD interface. The Pico W additionally contains an
Infineon CYW43439 2.4 GHz Wi-Fi/Bluetooth module. The USB bootloader allows the
ability to flash without any adapter, in a drag-and-drop manner.
It is also possible to flash and debug the boards with their SWD interface,
using an external adapter.

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

.. figure:: img/rpi_pico.jpg
:align: center
:alt: Raspberry Pi Pico

Raspberry Pi Pico (above) and Pico W (below)
(Images courtesy of Raspberry Pi)

Supported Features
==================

The ``pico_plus2/rp2350b/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`
* - DMA
- :kconfig:option:`CONFIG_DMA`
- :dtcompatible:`raspberrypi,pico-dma`
* - 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`
* - UART (PIO)
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`raspberrypi,pico-uart-pio`


Programming and Debugging
*************************

Flashing
========

Using OpenOCD
-------------

To use CMSIS-DAP, You must configure **udev**.

Create a file in /etc/udev.rules.d with any name, and write the line below.

.. code-block:: bash
ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000c", MODE="660", GROUP="plugdev", TAG+="uaccess"
This example is valid for the case that the user joins to `plugdev` groups.

Check failure on line 102 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:102 default role used (hint: for inline literals, use double backticks) (default-role)

The Raspberry Pi Pico has an SWD interface that can be used to program
and debug the on board RP2040. This interface can be utilized by OpenOCD.
To use it with the RP2040, OpenOCD version 0.12.0 or later is needed.

If you are using a Debian based system (including RaspberryPi OS, Ubuntu. and more),
using the `pico_setup.sh`_ script is a convenient way to set up the forked version of OpenOCD.

Depending on the interface used (such as JLink), you might need to
checkout to a branch that supports this interface, before proceeding.
Build and install OpenOCD as described in the README.

Here is an example of building and flashing the :zephyr:code-sample:`blinky` application.

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: rpi_pico
:goals: build flash
:gen-args: -DOPENOCD=/usr/local/bin/openocd -DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts -DRPI_PICO_DEBUG_ADAPTER=cmsis-dap

Set the environment variables **OPENOCD** to `/usr/local/bin/openocd`

Check failure on line 123 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:123 default role used (hint: for inline literals, use double backticks) (default-role)
and **OPENOCD_DEFAULT_PATH** to `/usr/local/share/openocd/scripts`. This should work

Check failure on line 124 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:124 default role used (hint: for inline literals, use double backticks) (default-role)
with the OpenOCD that was installed with the default configuration.
This configuration also works with an environment that is set up by the `pico_setup.sh`_ script.

**RPI_PICO_DEBUG_ADAPTER** specifies what debug adapter is used for debugging.

If **RPI_PICO_DEBUG_ADAPTER** was not assigned, `cmsis-dap` is used by default.

Check failure on line 130 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:130 default role used (hint: for inline literals, use double backticks) (default-role)
The other supported adapters are `raspberrypi-swd`, `jlink` and `blackmagicprobe`.

Check failure on line 131 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:131 default role used (hint: for inline literals, use double backticks) (default-role)
How to connect `cmsis-dap` and `raspberrypi-swd` is described in `Getting Started with Raspberry Pi Pico`_.

Check failure on line 132 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:132 default role used (hint: for inline literals, use double backticks) (default-role)
Any other SWD debug adapter maybe also work with this configuration.

The value of **RPI_PICO_DEBUG_ADAPTER** is cached, so it can be omitted from
`west flash` and `west debug` if it was previously set while running `west build`.

Check failure on line 136 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:136 default role used (hint: for inline literals, use double backticks) (default-role)

**RPI_PICO_DEBUG_ADAPTER** is used in an argument to OpenOCD as `"source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]"`.

Check failure on line 138 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:138 default role used (hint: for inline literals, use double backticks) (default-role)
Thus, **RPI_PICO_DEBUG_ADAPTER** needs to be assigned the file name of the debug adapter.

You can also flash the board with the following
command that directly calls OpenOCD (assuming a SEGGER JLink adapter is used):

.. code-block:: console
$ openocd -f interface/jlink.cfg -c 'transport select swd' -f target/rp2040.cfg -c "adapter speed 2000" -c 'targets rp2040.core0' -c 'program path/to/zephyr.elf verify reset exit'
Using UF2
---------

If you don't have an SWD adapter, you can flash the Raspberry Pi Pico with
a UF2 file. By default, building an app for this board will generate a
`build/zephyr/zephyr.uf2` file. If the Pico is powered on with the `BOOTSEL`

Check failure on line 153 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:153 default role used (hint: for inline literals, use double backticks) (default-role)
button pressed, it will appear on the host as a mass storage device. The
UF2 file should be drag-and-dropped to the device, which will flash the Pico.

Debugging
=========

The SWD interface can also be used to debug the board. To achieve this, you can
either use SEGGER JLink or OpenOCD.

Using SEGGER JLink
------------------

Use a SEGGER JLink debug probe and follow the instruction in
:ref:`Building, Flashing and Debugging<west-debugging>`.


Using OpenOCD
-------------

Install OpenOCD as described for flashing the board.

Here is an example for debugging the :zephyr:code-sample:`blinky` application.

.. zephyr-app-commands::
:zephyr-app: samples/basic/blinky
:board: rpi_pico
:maybe-skip-config:
:goals: debug
:gen-args: -DOPENOCD=/usr/local/bin/openocd -DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts -DRPI_PICO_DEBUG_ADAPTER=raspberrypi-swd

As with flashing, you can specify the debug adapter by specifying **RPI_PICO_DEBUG_ADAPTER**
at `west build` time. No needs to specify it at `west debug` time.

Check failure on line 185 in boards/pimoroni/pico_plus2/doc/index.rst

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

SphinxLint

boards/pimoroni/pico_plus2/doc/index.rst:185 default role used (hint: for inline literals, use double backticks) (default-role)

You can also debug with OpenOCD and gdb launching from command-line.
Run the following command:

.. code-block:: console
$ openocd -f interface/jlink.cfg -c 'transport select swd' -f target/rp2040.cfg -c "adapter speed 2000" -c 'targets rp2040.core0'
On another terminal, run:

.. code-block:: console
$ gdb-multiarch
Inside gdb, run:

.. code-block:: console
(gdb) tar ext :3333
(gdb) file path/to/zephyr.elf
You can then start debugging the board.

.. target-notes::

.. _pico_setup.sh:
https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh

.. _Getting Started with Raspberry Pi Pico:
https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
49 changes: 49 additions & 0 deletions boards/pimoroni/pico_plus2/pico_plus2-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 TOKITA Hiroshi
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/pinctrl/rpi-pico-rp2350b-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;
};
};

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_P40>, <ADC_CH1_P41>, <ADC_CH2_P42>, <ADC_CH3_P43>;
input-enable;
};
};
};
Loading

0 comments on commit 23b9588

Please sign in to comment.