Cytron Maker Pi RP2040

The RP2040 SoC [63] by Raspberry Pi Ltd. is a small sized and low-cost 32-bit dual ARM Cortex-M0+ microcontroller and predestined for versatile board designs. The Cytron Maker RP2040 board series based on this microcontroller offers a wide range with different scaling factors, in size, features and interfaces for communication, input and output.

Board Overview

Hardware

The Maker Pi RP2040 [23] is a special sized RP2040 development board designed for robot applications. This board comes with dual channel DC motor (H-bridge) driver, 4 servo motor (PWM) ports and 7 Grove System [26] connectors, ready for robot or motion control projects. The DC motor driver on-board is able to control 2 brushed DC motors or 1 bipolar/unipolar stepper motor rated from 3.6V to 6V, providing up to 1A current per channel. The built-in quick test buttons and motor output LEDs allow functional test of the motor driver in a quick and convenient way, without the need of writing any code. Vmotor for both DC and servo motors depends on the input voltage supplied to the board. It too has lots of LEDs useful for troubleshooting, is able to make quite some noise with the on-board piezo buzzer and comes with push buttons ready to detect your touch. There are three ways to supply power to the board: via USB (5V) socket, with a single cell LiPo/Li-Ion battery or through the VIN (3.6-6V) terminals. Power supply from all these power sources can all be controlled with the power on/off switch on-board.

Features and Resources

Printed Circuit Board

5V/500㎃ 3.3V/300㎃ 3.6-6V/1A(Vmotor/Vbat) Vmotor/3.3V(OUT)

133㎒ 2㎆ 264㎅ USB-B LiPo/Fe UF2 SWD

RST BOOT USER BLUE RGB PIEZO DC Motor Servo Motor

13 8 3 1 1 1

  • Dual core Arm Cortex-M0+ processor running up to 133㎒

  • 264㎅ on-chip SRAM

  • 2㎆ on-board QSPI flash with XIP capabilities

  • USB 1.1 controller (host/device)

  • On-board USB-B micro connector

  • On-board DC-DC setp-up converter with 2A switch

  • On-board Lithium battery charger

  • On-board RESET button

  • On-board BOOT button

  • On-board 2 USER button

  • On-board 1 Piezo buzzer

  • On-board 2 RGB LED (strip)

  • On-board 13 LED

  • 13 GPIO pins via 7 Grove connectors

  • 1 UART peripheral via 1 Grove connector

  • 1 I2C controller via 1 Grove connector

  • 1 SPI controller via 2 Grove connectors

  • 8 PWM channels via 6 Grove connectors

  • 3 ADC analog inputs via 2 Grove connectors

  • 8 Programmable I/O (PIO) state machines for custom peripherals

  • 1 Watchdog timer peripheral

  • 1 Temperature sensor on-chip

Design Data

Maker Pi RP2040

Positions

Maker Pi RP2040 details
  1. USB Type-B connector
    Supports USB1.1 hosts and slave devices
  2. RESET button

  3. BOOT button
    press it when resetting to enter download mode
  4. Grove Port 1 - 7
    supports I2C, ADC0, ADC1, ADC2, GPIO/PWM
  5. WS2812B
    RGB LEDs
  6. USER buttons

  7. Piezo Buzzer
    3.6Vo-p (2.5~4.5V) @ 2.730㎑ with 80~87㏈
  8. LED monochrome
    user LEDs for diagnostic (not power indicator)
  9. RP2040

  10. W25Q16JV
    2㎆ NOR-Flash
  11. On/Off switch
    (Master) Motor Voltage on/off
  1. Battery header
    MX1.25 header, for 3.7V Lithium battery, allows recharging the battery and powering the board at the same time
  2. Motor Voltage terminal
    Screw terminal block, for 3.6~6V
  3. CT2105
    Lithium battery, single-cell, high-precision charger with overcharge voltage and current protection
  4. MCP7381T-2ACI
    Lithium battery, single-cell, 500㎃ @ 4.20V charge controller
  5. MT3608 (alternative SY7208)
    2A DC-DC buck-boost, step-up converter, 1~1.2㎒
  6. MX1515 (alternative MX1508 or MX1208)
    1.5A @ 2~10V dual-channel brushed DC motor drive (H-bridge) with 2.5A peak and able to use 2-6 AA/AAA dry batteries or 2-6 NiMH/NiCd rechargeable batteries on toy motors
  7. DC motor terminals

  8. Servo motors terminals

  9. DEBUG points
    Serial Wire Debug (SWD)

Data Sheets

Flash partitions

QSPI NOR-Flash

bootrom

code_partition

storage_partition

primary 2㎆

256B

1㎆ - 256B

1㎆

Pinouts

The peripherals of the RP2040 SoC [63] can be routed to various pins on the board. The configuration of these routes can be modified through DTS. Please refer to the datasheet to see the possible routings for each peripheral. The default assignments for the board is defined below.

External pin mapping on the Maker Pi RP2040 is not identical to any other standard edge connector, except the 7 Grove System [26] connectors. Note that only analog channel A0 - A2 are connected to the outside. GPIO line 29 will be used on-board as analog channel A3 for VM/2 voltage monitoring per default.

Pin Mapping

Pinout

on-edge(Grove):

2 (13) 1 (8) 3 1 1 1

on-board:

1 RST 1 BOOT 2 USER 13 BLUE 2 RGB 1 PIEZO 2 DC Motor (H-Bridge) 4 Servo Motor (3V3 PWM)

Default Zephyr Peripheral Mapping (Grove 1)

  • 1 UART0_RX : GP1 (PWM1)
  • 2 UART0_TX : GP0 (PWM0)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 2)

  • 1 SPI0_TX : GP2 (PWM2)
  • 2 SPI0_SCK : GP3 (PWM3)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 3)

  • 1 SPI0_CSN : GP4 (PWM4)
  • 2 SPI0_RX : GP5 (PWM5)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 4)

  • 1 I2C0_SCL : GP17 (PWM1)
  • 2 I2C0_SDA : GP16 (PWM0)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 5)

  • 1 ADC_CH0 : GP26 (PWM10)
  • 2 PIO/PWM : GP6 (PWM6)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 6)

  • 1 ADC_CH1 : GP27 (PWM11)
  • 2 ADC_CH0 : GP26 (PWM10)
  • 3 3V3(OUT)
  • 4 GND

Default Zephyr Peripheral Mapping (Grove 7)

  • 1 ADC_CH2 : GP28 (PWM12)
  • 2 PIO/PWM : GP7 PWM7
  • 3 3V3(OUT)
  • 4 GND

 

Default Zephyr On-Board Mapping

 

  • nc BLUE : GP7 PWM7
  • nc DCM1A : GP8 PWM8
  • nc DCM1B : GP9 PWM9
  • nc DCM2A : GP10 PWM10
  • nc DCM2B : GP11 PWM11
  • nc SRVM1 : GP12 PWM12
  • nc SRVM2 : GP13 PWM13
  • nc SRVM3 : GP14 PWM14
  • nc SRVM4 : GP15 PWM15
  • nc RGB : PIO0 : GP18
  • nc n.c. : GP19 (PWM3)
  • nc USER : GP20 (PWM4)
  • nc USER : GP21 (PWM5)
  • nc PIEZO : GP22 PWM6
  • nc n.c. : GP23 (PWM7)
  • nc n.c. : GP24 (PWM8)
  • nc n.c. : GP25 (PWM9)
  • nc ADC_CH3 : GP29 (PWM13)
    nc on-board VM/2 monitoring
  • nc 3V3 : ADC_VREF
  • nc RUN (RESET)

Devicetree compatible

Maker Pi RP2040 edge pinout

Supported Features

Similar to the Raspberry Pi Pico the board configuration supports the following hardware features:

Hardware Features Supported by Zephyr

Peripheral

Kconfig option

Devicetree compatible

Zephyr API

PINCTRL

CONFIG_PINCTRL

raspberrypi,pico-pinctrl

Pin Control API

GPIO

CONFIG_GPIO

raspberrypi,pico-gpio

General-Purpose Input/Output (GPIO)

UART

CONFIG_SERIAL

Universal Asynchronous Receiver-Transmitter (UART)

UDC (USB Device Controller)

CONFIG_USB_DEVICE_STACK_NEXT

raspberrypi,pico-usbd

USB device support APIs

I2C

CONFIG_I2C

raspberrypi,pico-i2c

Inter-Integrated Circuit (I2C) Bus

SPI

CONFIG_SPI

Serial Peripheral Interface (SPI) Bus

PWM

CONFIG_PWM

raspberrypi,pico-pwm

Pulse Width Modulation (PWM)

ADC

CONFIG_ADC

raspberrypi,pico-adc

Analog-to-Digital Converter (ADC)

Temperature (Sensor)

CONFIG_SENSOR

raspberrypi,pico-temp

Sensors

RTC

CONFIG_RTC

raspberrypi,pico-rtc

Real-Time Clock (RTC)

Timer (Counter)

CONFIG_COUNTER

raspberrypi,pico-timer

Counter

Watchdog Timer (WDT)

CONFIG_WATCHDOG

raspberrypi,pico-watchdog

Watchdog

Flash

CONFIG_FLASH

raspberrypi,pico-flash-controller

Flash and Flash map

PIO

CONFIG_PIO_RPI_PICO

raspberrypi,pico-pio

N/A

UART (PIO)

CONFIG_SERIAL

raspberrypi,pico-uart-pio

Universal Asynchronous Receiver-Transmitter (UART)

SPI (PIO)

CONFIG_SPI

raspberrypi,pico-spi-pio

Serial Peripheral Interface (SPI) Bus

DMA

CONFIG_DMA

raspberrypi,pico-dma

Direct Memory Access (DMA)

HWINFO

CONFIG_HWINFO

N/A

Hardware Information

VREG

CONFIG_REGULATOR

raspberrypi,core-supply-regulator

Regulators

RESET

CONFIG_RESET

raspberrypi,pico-reset

Reset Controller

CLOCK

CONFIG_CLOCK_CONTROL

Clock Control

NVIC

N/A

arm,v6m-nvic

Nested Vector Interrupts Controller

SYSTICK

N/A

arm,armv6m-systick

Other hardware features are not currently supported by Zephyr. The default configuration can be found in the different Kconfig files:

Board Configurations

The board can be configured for the following different use cases.

west build -b cytron_maker_pi_rp2040

Use the serial port UART0 on edge header as Zephyr console and for the shell.

west build -b cytron_maker_pi_rp2040 -S usb-console

Use the native USB device port with CDC-ACM as Zephyr console and for the shell.

Connections and IOs

The Cytron Marktplace [22] has detailed information about board connections. Download the different schematics or datasheets as linked above per board for more details. The pinout diagrams can also be found there.

Laced Grove Signal Interface

The board offers the option of connecting hardware modules via a variety of Grove connectors. These are provided by a specific interface for general signal mapping, the Laced Grove Signal Interface.

Following mappings are well known:

  • grove_gpios: GPIO mapping

  • grove_pwms: PWM mapping

In addition to the on-board hader for DC and servo motors, there are also 7 Grove connectors (Qwiic/STEMMA QT).

This is the GPIO signal line mapping from the RP2040 SOC [63] to the set of Grove connectors provided as Laced Grove Signal Interface.

This list must not be stable!

phandle index to shield –>

Signal : Meaning

cytron_maker_pi_rp2040

<&grove_gpios 0 …>

GP0: UART-TX (UART0/PWM0CHA/LED)

<&grove_d1_header 1 …>
↳ <&gpio0 0 …>

<&grove_gpios 1 …>

GP1: UART-RX (UART0/PWM0CHB/LED)

<&grove_d1_header 0 …>
↳ <&gpio0 1 …>

<&grove_gpios 2 …>

GP2: SPI-CLK (SPI0/PWM1CHA/LED)

<&grove_d3_header 1 …>
↳ <&gpio0 2 …>

<&grove_gpios 3 …>

GP3: SPI-MOSI (SPI0/PWM1CHB/LED)

<&grove_d3_header 0 …>
↳ <&gpio0 3 …>

<&grove_gpios 4 …>

GP4: SPI-MISO (SPI0/PWM2CHA/LED)

<&grove_d5_header 1 …>
↳ <&gpio0 4 …>

<&grove_gpios 5 …>

GP5: SPI-CS (SPI0/PWM2CHB/LED)

<&grove_d5_header 0 …>
↳ <&gpio0 5 …>

<&grove_gpios 6 …>

GP6: DIO6 (PWM3CHA/LED)

<&grove_d26_header 1 …>
↳ <&gpio0 6 …>

<&grove_gpios 7 …>

GP7: DIO7 (PWM3CHB/LED/BL)

<&grove_d28_header 1 …>
↳ <&gpio0 7 …>

<&grove_gpios 8 …>

GP8: M1A (PWM4CHA)

not wired (DC Motor 1A)

<&grove_gpios 9 …>

GP9: M1B (PWM4CHB)

not wired (DC Motor 1B)

<&grove_gpios 10 …>

GP10: M2A (PWM5CHA)

not wired (DC Motor 2A)

<&grove_gpios 11 …>

GP11: M2B (PWM5CHB)

not wired (DC Motor 2B)

<&grove_gpios 12 …>

GP12: SM1 (PWM6CHA)

not wired (Servo Motor 1)

<&grove_gpios 13 …>

GP13: SM2 (PWM6CHB)

not wired (Servo Motor 2)

<&grove_gpios 14 …>

GP14: SM3 (PWM7CHA)

not wired (Servo Motor 3)

<&grove_gpios 15 …>

GP15: SM4 (PWM7CHB)

not wired (Servo Motor 4)

<&grove_gpios 16 …>

GP16: I2C-SDA (I2C0/PWM0CHA/LED)

<&grove_d17_header 1 …>
↳ <&gpio0 16 …>

<&grove_gpios 17 …>

GP17: I2C-SCL (I2C0/PWM0CHB/LED)

<&grove_d17_header 0 …>
↳ <&gpio0 17 …>

<&grove_gpios 18 …>

GP18: WS2812 (PWM1CHA)

not wired (RGB LED)

<&grove_gpios 19 …>

GP19

not wired

<&grove_gpios 20 …>

GP20: B1 (PWM2CHA)

not wired (Button 1)

<&grove_gpios 21 …>

GP21: B2 (PWM2CHB)

not wired (Button 2)

<&grove_gpios 22 …>

GP22: BZ (PWM3CHA)

not wired (Buzzer)

<&grove_gpios 23 …>

GP23

not wired

<&grove_gpios 24 …>

GP24

not wired

<&grove_gpios 25 …>

GP25

not wired

<&grove_gpios 26 …>

GP26: ADC0/DIO26 (ADC/PWM5CHA/LED)

<&grove_d26_header 0 …>,
↳ <&grove_d27_header 1 …>
↳ <&gpio0 26 …>

<&grove_gpios 27 …>

GP27: ADC1/DIO27 (ADC/PWM5CHB/LED)

<&grove_d27_header 0 …>
↳ <&gpio0 27 …>

<&grove_gpios 28 …>

GP28: ADC2/DIO28 (ADC/PWM6CHA/LED)

<&grove_d28_header 0 …>
↳ <&gpio0 28 …>

<&grove_gpios 29 …>

GP29: ADC3 (ADC/PWM6CHB)

not wired (ADC3 @ VMotor/2)

<&grove_gpios 30 …>

<&grove_gpios 31 …>

System Clock

The RP2040 [63] MCU is configured to use the 12㎒ external crystal with the on-chip PLL generating the 125㎒ system clock. The internal AHB and APB units are set up in the same way as the upstream Raspberry Pi Pico C/C++ SDK [14] libraries.

GPIO (PWM) Ports

The RP2040 [63] MCU has 1 GPIO cell which covers all I/O pads and 8 PWM function unit each with 2 channels beside a dedicated Timer unit. The channels PWM4 A to PWM5 B are reserved for the on-board DC motor H-bridge driver and also PWM5 A to PWM7 B for driving servo motors. The channel PWM3 A will be used for the on-board Piezo buzzer.

ADC/TS Ports

The RP2040 [63] MCU has 1 ADC with 4 channels and an additional fifth channel for the on-chip temperature sensor (TS). Only the ADC channel 0-2 are available on three of the four Grove compatiple connectors, ADC channel 3 will be used for internal on-board voltage monitoring.

The external voltage reference ADC_VREF is directly connected to the 3.3V power supply.

SPI Port

The RP2040 [63] MCU has 2 SPIs. The serial bus SPI0 is connect to external devices over GP3 (MOSI), GP4 (MISO), GP2 (SCK), and GP5 (CSn) by two Grove compatiple connectors. SPI1 is not available in any default setup.

I2C Port

The RP2040 [63] MCU has 2 I2Cs. The serial bus I2C0 and I2C1 are connect to external devices over GP16 (I2C0_SDA), GP17 (I2C0_SCL) by default or alternatively over GP4 (I2C0_SDA), GP5 (I2C0_SCL), GP2 (I2C1_SDA) and GP3 (I2C1_SCL) on the Grove compatiple connectors.

Serial Port

The RP2040 [63] MCU has 2 UARTs. One of the UARTs (UART0) is connected to external devices over GP0 (TX) and GP1 (RX) on the Grove compatiple connectors and is the Zephyr console.

USB Device Port

The RP2040 [63] MCU has a (native) USB device port that can be used to communicate with a host PC. See the USB sample applications for more, such as the USB CDC ACM UART sample sample which sets up a virtual serial port that echos characters back to the host PC. As an alternative to the default Zephyr console on serial port the Bridle USB Console Snippet (usb-console) can be used to enable CDC ACM and switch the console to USB:

USB device idVendor=2e8a, idProduct=000a, bcdDevice= 4.05
USB device strings: Mfr=1, Product=2, SerialNumber=3
Product: Maker Pi RP2040 (CDC ACM)
Manufacturer: Cytron (Raspberry Pi)
SerialNumber: BF002B12140C620C

To integrate specific USB device functions that do not follow a USB standard class, the following alternate identifier numbers are available for the various Cytron RP2040 and RP2350 boards according to the Raspberry Pi USB product ID list [12]:

RP2040

0x1000:

Maker Nano RP2040

0x100F:

Maker Pi RP2040

0x1071:

Maker UNO RP2040

0x1074:

EDU PICO

0x107E:

EDU PICO

0x1093:

IRIV IO Controller

0x109C:

SUMO:BIT Expansion Board

RP2350

0x1096:

MOTION 2350 Pro

 

Programmable I/O (PIO)

The RP2040 SoC [63] comes with two PIO periherals. These are two simple co-processors that are designed for I/O operations. The PIOs run a custom instruction set, generated from a custom assembly language. PIO programs are assembled using pioasm, a tool provided by Raspberry Pi. Further information can be found in the Raspberry Pi Pico C/C++ SDK [14] document, section with title “Using PIOASM, the PIO Assembler”.

Zephyr does not (currently) assemble PIO programs. Rather, they should be manually assembled and embedded in source code. An example of how this is done can be found at drivers/serial/uart_rpi_pico_pio.c or drivers/spi/spi_rpi_pico_pio.c.

Programming and Debugging

Flashing

Using UF2

If you don’t have an SWD adapter, you can flash the board with a UF2 file. By default, building an application for this board will generate a build/zephyr/zephyr.uf2 file. If the board is powered on with the BOOTSEL button pressed, it will appear on the host as a mass storage device:

USB device idVendor=2e8a, idProduct=0003, bcdDevice= 1.00
USB device strings: Mfr=1, Product=2, SerialNumber=0
Product: RP2 Boot
Manufacturer: Raspberry Pi
SerialNumber: E0C9125B0D9B

The UF2 file should be drag-and-dropped or copied on command line to the device, which will then flash the board.

RP2040 Boot-ROM

Each RP2040 SoC [63] ships the UF2 compatible [6] bootloader pico-bootrom-rp2040 [16], a native support in silicon. The full source for the RP2040 bootrom at pico-bootrom-rp2040 [16] includes versions B0, B1 and B2 of the bootrom, which correspond to the same silicon revisions, respectively.

Note that every time you build a program for the RP2040, the Pico SDK selects an appropriate second stage bootloader based on what kind of external QSPI Flash type the board configuration you are building for was giving. There are several versions of boot2 [15] for different flash chips, and each one is exactly 256 bytes of code which is put right at the start of the eventual program binary. On Zephyr the boot2 versions are part of the Raspberry Pi Pico HAL [21] module. Possible selections:

CONFIG_RP2_FLASH_AT25SF128A:

boot2_at25sf128a.S [66]

CONFIG_RP2_FLASH_GENERIC_03H:

boot2_generic_03h.S [67]

CONFIG_RP2_FLASH_IS25LP080:

boot2_is25lp080.S [68]

CONFIG_RP2_FLASH_W25Q080:

boot2_w25q080.S [69]

CONFIG_RP2_FLASH_W25X10CL:

boot2_w25x10cl.S [70]

The board set this option to CONFIG_RP2_FLASH_W25Q080.

Further information can be found in the RP2040 Datasheet [64], sections with title “Bootrom” and “Processor Controlled Boot Sequence” or Brian Starkey’s Blog article Pico serial bootloader [20]

Using OpenOCD

To use PicoProbe [17] or Raspberry Pi Debug Probe [18], you must configure udev. Create a file in /etc/udev.rules.d with any name, and write the line below:

ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="0004", MODE="660", GROUP="plugdev", TAG+="uaccess"
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.

The board 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 [19] 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 Blinky application:

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/blinky -- \
-DOPENOCD=/usr/local/bin/openocd \
-DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts \
-DCYTRON_RP2040_DEBUG_ADAPTER=picoprobe
west flash -r openocd -d build/cytron_maker_pi_rp2040

Set the environment variables OPENOCD to /usr/local/bin/openocd and OPENOCD_DEFAULT_PATH to /usr/local/share/openocd/scripts. This should work 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 [19] script.

CYTRON_RP2040_DEBUG_ADAPTER specifies what debug adapter is used for debugging. If CYTRON_RP2040_DEBUG_ADAPTER was not assigned, cmsis-dap is used by default. The other supported adapters are picoprobe, raspberrypi-swd, jlink and blackmagicprobe. How to connect picoprobe and raspberrypi-swd is described in Getting Started Guide with Raspberry Pi Pico [13]. Any other SWD debug adapter maybe also work with this configuration. The value of CYTRON_RP2040_DEBUG_ADAPTER is cached, so it can be omitted from west flash and west debug if it was previously set while running west build. CYTRON_RP2040_DEBUG_ADAPTER is used in an argument to OpenOCD as "source [find interface/${CYTRON_RP2040_DEBUG_ADAPTER}.cfg]". Thus, CYTRON_RP2040_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):

$ 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'

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 Building, Flashing and Debugging.

Using OpenOCD

Install OpenOCD as described for flashing the board.

Here is an example for debugging the Blinky application:

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/blinky -- \
-DOPENOCD=/usr/local/bin/openocd \
-DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts \
-DCYTRON_RP2040_DEBUG_ADAPTER=raspberrypi-swd
west debug -d build/cytron_maker_pi_rp2040

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

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

$ 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:

$ gdb-multiarch

Inside gdb, run:

(gdb) tar ext :3333
(gdb) file path/to/zephyr.elf

You can then start debugging the board.

Basic Samples

LED Blinky and Fade

Blue User LED Blinky by GPIO

See also Zephyr sample: Blinky.

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/blinky
west flash -d build/cytron_maker_pi_rp2040

Blue User LED Blinky by PWM

See also Zephyr sample: PWM Blinky.

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/blinky_pwm
west flash -d build/cytron_maker_pi_rp2040

Blue User LED Fade by PWM

See also Zephyr sample: Fade LED.

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/fade_led
west flash -d build/cytron_maker_pi_rp2040

Blue User LED On/Off by GPIO Button

See also Zephyr sample: Button.

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/button
west flash -d build/cytron_maker_pi_rp2040
Maker Pi RP2040 WS2812 LED Test Pattern

WS2812 LED Test Pattern by PIO

See also Zephyr sample: LED strip.

west build -b cytron_maker_pi_rp2040/rp2040 -p -d build/cytron_maker_pi_rp2040 zephyr/samples/drivers/led/led_strip -- -DCONFIG_SAMPLE_LED_UPDATE_DELAY=500
west flash -d build/cytron_maker_pi_rp2040

Hello Shell with USB-CDC/ACM Console

Hello Shell

See also Bridle sample: Hello Shell.

west build -b cytron_maker_pi_rp2040/rp2040 -p -S "usb-console" -d build/cytron_maker_pi_rp2040 bridle/samples/helloshell
west flash -d build/cytron_maker_pi_rp2040

Simple test execution on target

(text in bold is a command input)

uart:~$ hello -h
hello - say hello
uart:~$ hello
Hello from shell.
uart:~$ hwinfo devid
Length: 8
ID: 0xe4629c9593563629

uart:~$ kernel version
Zephyr version 4.5.0

uart:~$ bridle version
Bridle version 4.4.99

uart:~$ bridle version long
Bridle version 4.4.99.0

uart:~$ bridle info
Zephyr: 4.5.0
Bridle: 4.4.99
uart:~$ device list
devices:
- clock-controller@40008000 (READY)
  DT node labels: clocks
- reset-controller@4000c000 (READY)
  DT node labels: reset
- snippet_cdc_acm_console_uart (READY)
  DT node labels: snippet_cdc_acm_console_uart
- timer@40054000 (READY)
  DT node labels: timer
- uart@40034000 (READY)
  DT node labels: uart0 grove_serial
- watchdog@40058000 (READY)
  DT node labels: wdt0
- pio@50200000 (READY)
  DT node labels: ((pio_hw_t *)0x50200000u)
- dma@50000000 (READY)
  DT node labels: dma
- gpio-port@0 (READY)
  DT node labels: gpio0
- usbd@50110000 (READY)
  DT node labels: usbd zephyr_udc0
- adc@4004c000 (READY)
  DT node labels: adc
- flash-controller@18000000 (READY)
  DT node labels: ssi
- i2c@40044000 (READY)
  DT node labels: i2c0 zephyr_i2c grove_i2c
- pwm@40050000 (READY)
  DT node labels: pwm grove_pwm_d0 grove_pwm_d1 grove_pwm_d2 grove_pwm_d3 grove_pwm_d4 grove_pwm_d5 grove_pwm_d6 grove_pwm_d7 grove_pwm_d16 grove_pwm_d17 grove_pwm_d26 grove_pwm_d27 grove_pwm_d28
- vreg@40064000 (READY)
  DT node labels: vreg
- rtc@4005c000 (READY)
  DT node labels: rtc
- pwm-leds (READY)
  DT node labels: pwm_leds
- pio-ws2812 (READY)
- ws2812 (READY)
  DT node labels: ws2812 led_strip
- dietemp (READY)
  DT node labels: die_temp
uart:~$ history
[  0] history
[  1] device list
[  2] bridle info
[  3] bridle version long
[  4] bridle version
[  5] kernel version
[  6] hwinfo devid
[  7] hello
[  8] hello -h

More Samples

Input dump with USB-CDC/ACM Console

Prints all input events as defined by the shields Devicetree. See also Zephyr sample: Input dump.

Print the input events related to the two on-board user button using the Input subsystem API. That are:

BTN1 : zephyr,code = <INPUT_KEY_0>;
BTN2 : zephyr,code = <INPUT_KEY_1>;

Devicetree compatible

  • zephyr,lvgl-keypad-input with devicetree relation lvgl_keypad: lvgl-keypad { input = <&gpio_keys>; };

    BTN1 : input-codes = <INPUT_KEY_0>; : lvgl-codes = <LV_KEY_ENTER>;
    BTN2 : input-codes = <INPUT_KEY_1>; : lvgl-codes = <LV_KEY_NEXT>;

Button Input Dump

west build -b cytron_maker_pi_rp2040/rp2040 -p -S "usb-console" -d build/cytron_maker_pi_rp2040 zephyr/samples/subsys/input/input_dump
west flash -d build/cytron_maker_pi_rp2040

Simple logging output on target

*** Booting Zephyr OS build v4.5.0…***
Input sample started
I: input event: dev=gpio-keys        SYN type= 1 code= 11 value=1
I: input event: dev=gpio-keys        SYN type= 1 code= 11 value=0
I: input event: dev=gpio-keys        SYN type= 1 code=  2 value=1
I: input event: dev=gpio-keys        SYN type= 1 code=  2 value=0

Sounds from the speaker with USB-CDC/ACM Console

Maker Pi RP2040 Piezo Buzzer Test

Piezo Buzzer Test

The sample is prepared for the on-board PWM_BUZZER connected to the PWM channel at GP22 / PWM6 (PWM3CHA).

The PWM period is 880 ㎐, twice the concert pitch frequency of 440 ㎐.

Invoke west build and west flash:

west build -b cytron_maker_pi_rp2040/rp2040 -p -S "usb-console" -d build/cytron_maker_pi_rp2040 bridle/samples/buzzer
west flash -d build/cytron_maker_pi_rp2040

Simple test execution on target

  1. play a beep

  2. play a folk song

  3. play a chrismas song

uart:~$ buzzer beep
uart:~$ buzzer play folksong
uart:~$ buzzer play xmastime

Drive a motor with USB-CDC/ACM Console

Servomotor Test

Maker Pi RP2040 Servomotor Test

The sample is prepared for servomotor PWM_SERVO_0 at first on-board channel at GP12 / PWM12 (PWM6CHA).

Connect a servomotor MG996R to the first on-board PWM channel for servomotors, the 4×3 pin header block at position 19. See the board positions diagram for details.

The corresponding PWM pulse widths for a range of -90° to +90° (180°) are 500 ㎲ to 2,500 ㎲ with a period of 50 ㎐. All these servomotor specific parameters are preset by the snippet PWM Servomotor Preset Snippet (pwm-servo) that have to use to get access to this dedicated PWM channel together with the original Zephyr Servomotor sample. Invoke west build and west flash with this snipped and optional mixed with others, for example:

west build -b cytron_maker_pi_rp2040/rp2040 -p always -S "usb-console pwm-servo" -d build/cytron_maker_pi_rp2040 zephyr/samples/basic/servo_motor
west flash -d build/cytron_maker_pi_rp2040

Display Test and Demonstration

This samples and test applications are only applicable together with the Waveshare 2.4 LCD shield. This LCD module have to connected by free wiring.

Connect the Waveshare 2.4 LCD module by free wiring to the Grove connectors. Following module’s pin assignments for Grove System.

Grove

Pin

Maker Pi RP2040

Pin

Waveshare 2.4 LCD

2

3

3V3(OUT)

1

VCC

2

4

GND

2

GND

2

1

SPI0_TX : D3

3

DIN MOSI

ILI9341 Serial Data Input

2

2

SPI0_SCK : D2

4

CLK SCK

ILI9341 Serial Clock Input

3

1

SPI0_CSN : D5

5

CS CSN

ILI9341 Chip Select Input

5

2

GP6 : D6

6

DC DC

ILI9341 Data/Command

7

1

GP28 : D28 (ADC2)

7

RST RST

ILI9341 Reset

7

2

GP7 PWM7 : D7

8

BL BL BL

LCD Backlight

LCD Orientation and Bit Order Test

See also Zephyr sample: Display.

west build -b cytron_maker_pi_rp2040/rp2040 -p -S "usb-console" --shield "waveshare_2_4_lcd" -d build/cytron_maker_pi_rp2040 zephyr/samples/drivers/display
west flash -d build/cytron_maker_pi_rp2040

LVGL Basic Sample

See also Zephyr sample: LVGL basic sample.

west build -b cytron_maker_pi_rp2040/rp2040 -p -S "usb-console" --shield "waveshare_2_4_lcd" -d build/cytron_maker_pi_rp2040 zephyr/samples/subsys/display/lvgl
west flash -d build/cytron_maker_pi_rp2040

This sample comes with a Shell command line access to the LVGL backend on the console, here configured for a USB console:

Simple test execution on target

uart:~$ lvgl
lvgl - LVGL shell commands
Subcommands:
  stats   :Show LVGL statistics
  monkey  :LVGL monkey testing

uart:~$ lvgl stats
stats - Show LVGL statistics
Subcommands:
  memory  : Show LVGL memory statistics
            Usage: memory [-c]
                   -c  dump chunk information

uart:~$ lvgl stats memory
Heap at 0x200015a0 contains 2047 units in 11 buckets

  bucket#    min units        total      largest      largest
             threshold       chunks      (units)      (bytes)
  -----------------------------------------------------------
        0            1            2            1            8
        1            2            3            3           24
       10         1024            1         1046         8368

8416 free bytes, 7396 allocated bytes, overhead = 568 bytes (3.5%)

References