Skip to content

Commit 8e069bb

Browse files
committed
boards: pico_spe: add support
Add variant of rp2040 with SinglePairEthernet Signed-off-by: Frank Bintakies <[email protected]>
1 parent d4b7bf9 commit 8e069bb

File tree

13 files changed

+737
-0
lines changed

13 files changed

+737
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright (c) 2024 KWS Computersysteme Gmbh
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_PICO_SPE
5+
6+
config RP2_FLASH_W25Q080
7+
default y
8+
9+
if I2C_DW
10+
11+
config I2C_DW_CLOCK_SPEED
12+
default 125
13+
14+
endif # I2C_DW
15+
16+
config USB_SELF_POWERED
17+
default n
18+
19+
config PHY_INIT_PRIORITY
20+
default 82
21+
depends on NET_L2_ETHERNET && ETH_DRIVER
22+
23+
if NETWORKING
24+
25+
config NET_L2_ETHERNET
26+
default y
27+
28+
if ETH_LAN865X
29+
30+
config NET_IF_MAX_IPV4_COUNT
31+
default 2
32+
33+
endif # ETH_LAN865X
34+
35+
endif # NETWORKING
36+
37+
endif # BOARD_PICO_SPE
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Copyright (c) 2024 KWS Computersysteme Gmbh
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_PICO_SPE
5+
select SOC_RP2040

boards/kws/pico_spe/board.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# This configuration allows selecting what debug adapter debugging Pico-SPE
4+
# by a command-line argument.
5+
# It is mainly intended to support both the 'picoprobe' and 'raspberrypi-swd'
6+
# adapter described in "Getting started with Raspberry Pi Pico".
7+
# And any other SWD debug adapter might also be usable with this configuration.
8+
9+
# Set RPI_PICO_DEBUG_ADAPTER to select debug adapter by command-line arguments.
10+
# e.g.) west build -b pico_spe -- -DRPI_PICO_DEBUG_ADAPTER=raspberrypi-swd
11+
# The value is treated as a part of an interface file name that
12+
# the debugger's configuration file.
13+
# The value must be the 'stem' part of the name of one of the files
14+
# in the openocd interface configuration file.
15+
# The setting is store to CMakeCache.txt.
16+
if ("${RPI_PICO_DEBUG_ADAPTER}" STREQUAL "")
17+
set(RPI_PICO_DEBUG_ADAPTER "cmsis-dap")
18+
endif()
19+
20+
board_runner_args(openocd --cmd-pre-init "source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]")
21+
board_runner_args(openocd --cmd-pre-init "transport select swd")
22+
board_runner_args(openocd --cmd-pre-init "source [find target/rp2040.cfg]")
23+
24+
# The adapter speed is expected to be set by interface configuration.
25+
# But if not so, set 2000 to adapter speed.
26+
board_runner_args(openocd --cmd-pre-init "set_adapter_speed_if_not_set 2000")
27+
28+
board_runner_args(jlink "--device=RP2040_M0_0")
29+
board_runner_args(uf2 "--board-id=RPI-RP2")
30+
board_runner_args(pyocd "--target=rp2040")
31+
32+
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
33+
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
34+
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)
35+
include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
36+
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)

boards/kws/pico_spe/board.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
board:
2+
name: pico_spe
3+
full_name: SinglePairEthernet Pico
4+
vendor: kws
5+
socs:
6+
- name: rp2040
98.6 KB
Loading

boards/kws/pico_spe/doc/index.rst

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
.. _pico_spe:
2+
3+
Pico-SPE
4+
#################
5+
6+
Overview
7+
********
8+
9+
The Pico-SPE is a small, low-cost, versatile boards from
10+
KWS Computersysteme Gmbh. They are equipped with an RP2040 SoC, an on-board LED,
11+
a USB connector, an SWD interface. The Pico-SPE Additionally contains an
12+
Microchip LAN8651 10Base-T1S module. The USB bootloader allows the
13+
ability to flash without any adapter, in a drag-and-drop manner.
14+
It is also possible to flash and debug the boards with their SWD interface,
15+
using an external adapter.
16+
17+
Hardware
18+
********
19+
- Dual core Arm Cortex-M0+ processor running up to 133MHz
20+
- 264KB on-chip SRAM
21+
- 16MB on-board QSPI flash with XIP capabilities
22+
- 16 GPIO pins
23+
- 3 Analog inputs
24+
- 2 UART peripherals
25+
- 2 I2C controllers
26+
- 16 PWM channels
27+
- USB 1.1 controller (host/device)
28+
- 8 Programmable I/O (PIO) for custom peripherals
29+
- On-board LED
30+
- 1 Watchdog timer peripheral
31+
- Microchip LAN8651 10Base-T1S
32+
33+
34+
.. figure:: img/pico_spe.png
35+
:align: center
36+
:alt: Pico-SPE
37+
38+
Pico-SPE(above)
39+
(Images courtesy of KWS Computersysteme Gmbh)
40+
41+
Supported Features
42+
==================
43+
44+
The pico_spe board configuration supports the following
45+
hardware features:
46+
47+
.. list-table::
48+
:header-rows: 1
49+
50+
* - Peripheral
51+
- Kconfig option
52+
- Devicetree compatible
53+
* - NVIC
54+
- N/A
55+
- :dtcompatible:`arm,v6m-nvic`
56+
* - UART
57+
- :kconfig:option:`CONFIG_SERIAL`
58+
- :dtcompatible:`raspberrypi,pico-uart`
59+
* - GPIO
60+
- :kconfig:option:`CONFIG_GPIO`
61+
- :dtcompatible:`raspberrypi,pico-gpio`
62+
* - ADC
63+
- :kconfig:option:`CONFIG_ADC`
64+
- :dtcompatible:`raspberrypi,pico-adc`
65+
* - I2C
66+
- :kconfig:option:`CONFIG_I2C`
67+
- :dtcompatible:`snps,designware-i2c`
68+
* - SPI
69+
- :kconfig:option:`CONFIG_SPI`
70+
- :dtcompatible:`raspberrypi,pico-spi`
71+
* - USB Device
72+
- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
73+
- :dtcompatible:`raspberrypi,pico-usbd`
74+
* - HWINFO
75+
- :kconfig:option:`CONFIG_HWINFO`
76+
- N/A
77+
* - Watchdog Timer (WDT)
78+
- :kconfig:option:`CONFIG_WATCHDOG`
79+
- :dtcompatible:`raspberrypi,pico-watchdog`
80+
* - PWM
81+
- :kconfig:option:`CONFIG_PWM`
82+
- :dtcompatible:`raspberrypi,pico-pwm`
83+
* - Flash
84+
- :kconfig:option:`CONFIG_FLASH`
85+
- :dtcompatible:`raspberrypi,pico-flash`
86+
* - Clock controller
87+
- :kconfig:option:`CONFIG_CLOCK_CONTROL`
88+
- :dtcompatible:`raspberrypi,pico-clock-controller`
89+
* - UART (PIO)
90+
- :kconfig:option:`CONFIG_SERIAL`
91+
- :dtcompatible:`raspberrypi,pico-uart-pio`
92+
* - SPI (PIO)
93+
- :kconfig:option:`CONFIG_SPI`
94+
- :dtcompatible:`raspberrypi,pico-spi-pio`
95+
* - LAN8651 Single Pair Ethernet
96+
- :kconfig:option:`CONFIG_NETWORKING`
97+
- :dtcompatible:`microchip,lan865x`
98+
99+
Pin Mapping
100+
===========
101+
102+
The peripherals of the RP2040 SoC can be routed to various pins on the board.
103+
The configuration of these routes can be modified through DTS. Please refer to
104+
the datasheet to see the possible routings for each peripheral.
105+
106+
External pin mapping on the Pico-SPE is identical to the Pico, but note that internal
107+
RP2040 GPIO lines 10, 11, 12, 13, 20, 21 are routed to the Microchip LAN8651 on the
108+
Pico-SPE.
109+
110+
Default Zephyr Peripheral Mapping:
111+
----------------------------------
112+
113+
.. rst-class:: rst-columns
114+
115+
- UART0_TX : P0
116+
- UART0_RX : P1
117+
- I2C0_SDA : P4
118+
- I2C0_SCL : P5
119+
- I2C1_SDA : P6
120+
- I2C1_SCL : P7
121+
- ADC_CH0 : P26
122+
- ADC_CH1 : P27
123+
- ADC_CH2 : P28
124+
125+
Programmable I/O (PIO)
126+
**********************
127+
The RP2040 SoC comes with two PIO periherals. These are two simple
128+
co-processors that are designed for I/O operations. The PIOs run
129+
a custom instruction set, generated from a custom assembly language.
130+
PIO programs are assembled using :command:`pioasm`, a tool provided by Raspberry Pi.
131+
132+
Zephyr does not (currently) assemble PIO programs. Rather, they should be
133+
manually assembled and embedded in source code. An example of how this is done
134+
can be found at :zephyr_file:`drivers/serial/uart_rpi_pico_pio.c`.
135+
136+
Sample: SPI via PIO
137+
====================
138+
139+
The :zephyr_file:`samples/sensor/bme280/README.rst` sample includes a
140+
demonstration of using the PIO SPI driver to communicate with an
141+
environmental sensor. The PIO SPI driver supports using any
142+
combination of GPIO pins for an SPI bus, as well as allowing up to
143+
four independent SPI buses on a single board (using the two SPI
144+
devices as well as both PIO devices).
145+
146+
Programming and Debugging
147+
*************************
148+
149+
Flashing
150+
========
151+
152+
Using SEGGER JLink
153+
------------------
154+
155+
You can Flash the pico_spe with a SEGGER JLink debug probe as described in
156+
:ref:`Building, Flashing and Debugging <west-flashing>`.
157+
158+
Here is an example of building and flashing the :zephyr:code-sample:`blinky` application.
159+
160+
.. zephyr-app-commands::
161+
:zephyr-app: samples/basic/blinky
162+
:board: pico_spe
163+
:goals: build
164+
165+
.. code-block:: bash
166+
167+
west flash --runner jlink
168+
169+
Using OpenOCD
170+
-------------
171+
172+
To use CMSIS-DAP, You must configure **udev**.
173+
174+
Create a file in /etc/udev.rules.d with any name, and write the line below.
175+
176+
.. code-block:: bash
177+
178+
ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="000c", MODE="660", GROUP="plugdev", TAG+="uaccess"
179+
180+
This example is valid for the case that the user joins to ``plugdev`` groups.
181+
182+
The Pico-SPE has an SWD interface that can be used to program
183+
and debug the on board RP2040. This interface can be utilized by OpenOCD.
184+
To use it with the RP2040, OpenOCD version 0.12.0 or later is needed.
185+
186+
If you are using a Debian based system (including RaspberryPi OS, Ubuntu. and more),
187+
using the `pico_setup.sh`_ script is a convenient way to set up the forked version of OpenOCD.
188+
189+
Depending on the interface used (such as JLink), you might need to
190+
checkout to a branch that supports this interface, before proceeding.
191+
Build and install OpenOCD as described in the README.
192+
193+
Here is an example of building and flashing the :zephyr:code-sample:`blinky` application.
194+
195+
.. zephyr-app-commands::
196+
:zephyr-app: samples/basic/blinky
197+
:board: pico_spe
198+
:goals: build flash
199+
:gen-args: -DOPENOCD=/usr/local/bin/openocd -DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts -DRPI_PICO_DEBUG_ADAPTER=cmsis-dap
200+
201+
Set the environment variables **OPENOCD** to :file:`/usr/local/bin/openocd`
202+
and **OPENOCD_DEFAULT_PATH** to :file:`/usr/local/share/openocd/scripts`. This should work
203+
with the OpenOCD that was installed with the default configuration.
204+
This configuration also works with an environment that is set up by the `pico_setup.sh`_ script.
205+
206+
**RPI_PICO_DEBUG_ADAPTER** specifies what debug adapter is used for debugging.
207+
208+
If **RPI_PICO_DEBUG_ADAPTER** was not assigned, ``cmsis-dap`` is used by default.
209+
The other supported adapters are ``raspberrypi-swd``, ``jlink`` and ``blackmagicprobe``.
210+
How to connect ``cmsis-dap`` and ``raspberrypi-swd`` is described in `Getting Started with Pico-SPE`_.
211+
Any other SWD debug adapter maybe also work with this configuration.
212+
213+
The value of **RPI_PICO_DEBUG_ADAPTER** is cached, so it can be omitted from
214+
``west flash`` and ``west debug`` if it was previously set while running
215+
``west build``.
216+
217+
**RPI_PICO_DEBUG_ADAPTER** is used in an argument to OpenOCD as ``"source [find interface/${RPI_PICO_DEBUG_ADAPTER}.cfg]"``.
218+
Thus, **RPI_PICO_DEBUG_ADAPTER** needs to be assigned the file name of the debug adapter.
219+
220+
You can also flash the board with the following
221+
command that directly calls OpenOCD (assuming a SEGGER JLink adapter is used):
222+
223+
.. code-block:: console
224+
225+
$ 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'
226+
227+
Using UF2
228+
---------
229+
230+
If you don't have an SWD adapter, you can flash the Pico-SPE with
231+
a UF2 file. By default, building an app for this board will generate a
232+
:file:`build/zephyr/zephyr.uf2` file. If the Pico is powered on with the ``BOOTSEL``
233+
button pressed, it will appear on the host as a mass storage device. The
234+
UF2 file should be drag-and-dropped to the device, which will flash the Pico.
235+
236+
Debugging
237+
=========
238+
239+
The SWD interface can also be used to debug the board. To achieve this, you can
240+
either use SEGGER JLink or OpenOCD.
241+
242+
Using SEGGER JLink
243+
------------------
244+
245+
Use a SEGGER JLink debug probe and follow the instruction in
246+
:ref:`Building, Flashing and Debugging<west-debugging>`.
247+
248+
249+
Using OpenOCD
250+
-------------
251+
252+
Install OpenOCD as described for flashing the board.
253+
254+
Here is an example for debugging the :zephyr:code-sample:`blinky` application.
255+
256+
.. zephyr-app-commands::
257+
:zephyr-app: samples/basic/blinky
258+
:board: pico_spe
259+
:maybe-skip-config:
260+
:goals: debug
261+
:gen-args: -DOPENOCD=/usr/local/bin/openocd -DOPENOCD_DEFAULT_PATH=/usr/local/share/openocd/scripts -DRPI_PICO_DEBUG_ADAPTER=raspberrypi-swd
262+
263+
As with flashing, you can specify the debug adapter by specifying **RPI_PICO_DEBUG_ADAPTER**
264+
at ``west build`` time. No needs to specify it at ``west debug`` time.
265+
266+
You can also debug with OpenOCD and gdb launching from command-line.
267+
Run the following command:
268+
269+
.. code-block:: console
270+
271+
$ openocd -f interface/jlink.cfg -c 'transport select swd' -f target/rp2040.cfg -c "adapter speed 2000" -c 'targets rp2040.core0'
272+
273+
On another terminal, run:
274+
275+
.. code-block:: console
276+
277+
$ gdb-multiarch
278+
279+
Inside gdb, run:
280+
281+
.. code-block:: console
282+
283+
(gdb) tar ext :3333
284+
(gdb) file path/to/zephyr.elf
285+
286+
You can then start debugging the board.
287+
288+
.. target-notes::
289+
.. _pico_setup.sh:
290+
https://raw.githubusercontent.com/raspberrypi/pico-setup/master/pico_setup.sh
291+
292+
.. _Getting Started with Pico-SPE:
293+
https://kws-computer.de/go/pico-spe-getting-started
294+
295+
.. _Pico-SPE Documentation:
296+
https://kws-computer.de/go/pico-spe-datasheet

0 commit comments

Comments
 (0)