Waveshare RP2040-ETH

The RP2040 SoC [35] 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 Waveshare 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 RP2040-ETH [17] is a reduce pico sized RP2040 development board. The on-board USB-C connector makes it compatible to future standards. It comes with an on-board companion chip which integrates the TCP/IP protocol stack for network communication. The castellated module allows soldering direct to carrier boards.

Features and Resources

Printed Circuit Board

5V/480㎃ 3.3V/800㎃ 3.3V(OUT) 3.3V(EN/PS)

133㎒ 4㎆ 264㎅ RST RGB 10BASE-T USB-C UF2

14 13 3 2 1 1

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

  • 264㎅ on-chip SRAM

  • 4㎆ on-board QSPI flash with XIP capabilities

  • USB 1.1 controller (host/device)

  • On-board USB-C connector

  • On-board 3.3V LDO regulator with 800㎃

  • On-board RESET button

  • On-board BOOT button

  • On-board RGB LED

  • On-board 10BASE-T Ethernet controller via UART with integrated TCP/IP protocol stack

  • 2 CTL signals from Ethernet controller

  • 1 RST signal to Ethernet controller

  • 14 GPIO pins via edge pinout, compatible with some Pico HATs

  • 1 UART peripheral via edge pinout

  • 2 I2C controllers via edge pinout

  • 1 SPI controller via edge pinout

  • 13 PWM channels via edge pinout

  • 3 ADC analog inputs via edge pinout

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

  • 1 Watchdog timer peripheral

  • 1 Temperature sensor on-chip

Design Data

Waveshare RP2040-ETH

Positions

Waveshare RP2040-ETH details
  1. USB Type-C connector
    Supports USB1.1 hosts and slave devices
  2. BOOT button
    press it when resetting to enter download mode
  3. RESET button

  4. RP2040

  5. RJ45 Ethernet port

  1. ME6217C33
    800㎃ low dropout, low noise, ultra-fast LDO
  2. W25Q32JV
    4㎆ NOR-Flash
  3. CH9120
    Ethernet serial port transmission IC
  4. WS2812B
    RGB LED

Data Sheets

Flash partitions

QSPI NOR-Flash

bootrom

code_partition

storage_partition

primary 4㎆

256B

1㎆ - 256B

3㎆

Pinouts

The peripherals of the RP2040 SoC [35] 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 RP2040-ETH is only partially identical to the original Raspberry Pi Pico board. About half of the pins provided on the edge were skipped for internal on-board purposes.

Note that also internal signals are not wired in same way. The internal RP2040 GPIO line 23 is not routed to the voltage regulator for SMPS power saving modes, due to the lack of such kind of functionality on applied SMPS (ME6217). Also the internal RP2040 GPIO line 29 (instead of 24 as in other one to one clones) is routed to the USB connector for USB VBUS monitoring. This omits the logical sensing of the USB bus voltage and also the monitoring of the system voltage, but it replaces it by combining the two original functions on line 29, now for USB VBUS.

But the GPIO line 25 is routed to the on-board user RGB LED in expected manner. In addition, GPIO lines 17 to 20 are used for control and UART communication with the on-board Ethernet controller that integrates an embedded but complete TCP/IP stack (incl. UDP, ICMP, IGMP, ARP).

Pin Mapping

Pinout

on-edge(1-40):

3 1 3 1(2) 1 1

on-board:

1 RGB 1 10BASE-T

Default Zephyr Peripheral Mapping

 

  • 1 UART0_TX : GP0 (PWM0)
  • 2 UART0_RX : GP1 (PWM1)
  • 3 GND
  • 4 (UART0_CTS) : GP2 (PWM2)
    nc (I2C1_SDA)
  • 5 (UART0_RTS) : GP3 (PWM3)
    nc (I2C1_SCL)
  • 6 SPI0_RX : GP4 (PWM4)
  • 7 SPI0_CSN : GP5 (PWM5)
  • 8 GND
  • 9 SPI0_SCK : GP6 (PWM6)
  • 10 SPI0_TX : GP7 (PWM7)
  • 11 I2C0_SDA : GP8 (PWM8)
  • 12 I2C0_SCL : GP9 (PWM9)
  • 13 
  • 14 PIO/PWM : GP10 (PWM10)
  • 15 PIO/PWM : GP11 (PWM11)
  • 16 PIO/PWM : GP12 (PWM12)
  • 17 PIO/PWM : GP13 (PWM13)
  • 18 
  • 19 PIO/PWM : GP14 (PWM14)
  • 20 PIO/PWM : GP15 (PWM15)
  • 21 PIO/PWM : GP16 (PWM0)
  • 22 GPIO17 : GP17 (PWM1)
    nc 10BASE-T TCP connect ETH_TCPCS
  • 23 
  • 24 GPIO18 : GP18 (PWM2)
    nc 10BASE-T data config ETH_CFG0
  • 25 GPIO19 : GP19 (PWM3)
    nc 10BASE-T reset ETH_RSTI
  • 26 UART1_TX : GP20 (PWM4)
    nc 10BASE-T data down ETH_RX
  • 27 UART1_RX : GP21 (PWM5)
    nc 10BASE-T data up ETH_TX
  • 28 
  • 29 PIO/PWM : GP22 PWM6
  • 30 RUN (RESET)
  • nc PIO/PWM : GP23 (PWM7)
  • nc PIO/PWM : GP24 (PWM8)
  • nc PIO0 : GP25 (PWM9)
    nc on-board user RGB_LED_DI
  • 31 ADC_CH0 : GP26 (PWM10)
  • 32 ADC_CH1 : GP27 (PWM11)
  • 33 GND
  • 34 ADC_CH2 : GP28 (PWM12)
  • nc ADC_CH3 : GP29 (PWM13)
    nc on-board VBUS/3 monitoring
  • 35 ADC_VREF
  • 36 3V3(OUT)
  • 37 3V3_EN
    nc on-board SMPS power enable
  • 38 GND
  • 39 VSYS
  • 40 VBUS

Devicetree compatible

Waveshare RP2040-ETH 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 waveshare_rp2040_eth

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

west build -b waveshare_rp2040_eth -S usb-console

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

Connections and IOs

The Waveshare wiki [16] 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.

System Clock

The RP2040 [35] 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 [11] libraries.

GPIO (PWM) Ports

The RP2040 [35] 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. Only 13 PWM channels are available on the edge connectors, but not supported in default configuration. There is also no internal on-board component that requires or use any PWM functionality.

ADC/TS Ports

The RP2040 [35] MCU has 1 ADC with 4 channels and an additional fifth channel for the on-chip temperature sensor (TS). The ADC channels 0-2 are available on the Raspberry Pi Pico header. 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 [35] MCU has 2 SPIs. To the edge connectors SPI0 is usable for external devices over GP7 (MOSI), GP4 (MISO), GP6 (SCK), and GP5 (CSn) on the Raspberry Pi Pico header. Attention, this differs from the standard layout. SPI1 is not available in any default setup.

I2C Port

The RP2040 [35] MCU has 2 I2Cs. The default serial bus I2C0 is usable for external devices over GP8 (I2C0_SDA) and GP9 (I2C0_SCL). Attention, this differs from the standard layout. I2C1 is not available in any default setup, but could be configured to GP2 (I2C1_SDA) and GP3 (I2C1_SCL) on the Raspberry Pi Pico header (also not in line with the standard layout).

Serial Port

The RP2040 [35] MCU has 2 UARTs. One of the UARTs (UART0) is connected to external devices over GP0 (TX) and GP1 (RX) on the Raspberry Pi Pico header, optional with full featured EIA 232D handshake signals, and is the Zephyr console. UART1 will be used internaly for communication with the on-board Ethernet controller.

USB Device Port

The RP2040 [35] 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: RP2040-ETH (CDC ACM)
Manufacturer: Waveshare (Raspberry Pi)
SerialNumber: B69F8448A6E91514

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

RP2040

0x101F:

RP2040-Zero

0x1020:

RP2040-Plus

0x1021:

RP2040-LCD-0.96

0x1039:

RP2040-LCD-1.28

0x103A:

RP2040-One

0x1044:

Power Management HAT (B)

0x1055:

RP2040-ETH

0x1056:

RP2040-Geek

0x1057:

RP2040-Touch-LCD-1.28

0x1083:

RP2040-PiZero

0x1084:

RP2040-Tiny

0x1085:

RP2040-Matrix

0x1086:

RP2040-BLE

0x1087:

PICO-Cam-A

RP2350

0x10B0:

RP2350-Zero

0x10B1:

RP2350-Plus

0x10B2:

RP2350-Tiny

0x10B3:

RP2350-LCD-1.28

0x10B4:

RP2350-Touch-LCD-1.28

0x10B5:

RP2350-One

0x10B6:

RP2350-Geek

0x10B7:

RP2350-LCD-0.96

0x10C3:

RP2350-ETH

 

Programmable I/O (PIO)

The RP2040 SoC [35] 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 [11] 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

The board can only be flashed with a UF2 file. There is no SWD connector.

Using UF2

By default, building an application for the 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 [35] ships the UF2 compatible [6] bootloader pico-bootrom-rp2040 [13], a native support in silicon. The full source for the RP2040 bootrom at pico-bootrom-rp2040 [13] 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 [12] 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 [15] module. Possible selections:

CONFIG_RP2_FLASH_AT25SF128A:

boot2_at25sf128a.S [38]

CONFIG_RP2_FLASH_GENERIC_03H:

boot2_generic_03h.S [39]

CONFIG_RP2_FLASH_IS25LP080:

boot2_is25lp080.S [40]

CONFIG_RP2_FLASH_W25Q080:

boot2_w25q080.S [41]

CONFIG_RP2_FLASH_W25X10CL:

boot2_w25x10cl.S [42]

The board set this option to CONFIG_RP2_FLASH_W25Q080.

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

Debugging

The board does not provide any SWD connector, thus debugging software is not possible.

Basic Samples

LED Blinky and Fade

Waveshare RP2040-ETH WS2812 LED Test Pattern

WS2812 LED Test Pattern by PIO

See also Zephyr sample: LED strip.

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

Hint

Neither LED Blinky nor LED Fade can be built and executed on this board, because this system has only one digital RGB LED. A simple GPIO or PWM control is not possible!

Hello Shell with USB-CDC/ACM Console

Hello Shell

See also Bridle sample: Hello Shell.

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

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: 0xb4de3e6fb1e7434f

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@40038000 (READY)
  DT node labels: uart1
- uart@40034000 (READY)
  DT node labels: uart0 pico_serial rpipico_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 pico_i2c0 pico_i2c rpipico_i2c0 rpipico_i2c
- pwm@40050000 (READY)
  DT node labels: pwm
- vreg@40064000 (READY)
  DT node labels: vreg
- rtc@4005c000 (READY)
  DT node labels: rtc
- 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

References