Skip to content

Commit 52b5ad0

Browse files
petejohansoncarlescufi
authored andcommitted
boards: arm: Add adafruit_kb2040 board
Add `adafruit_kb2040` board with `sparkfun,pro-micro` header. Signed-off-by: Peter Johanson <[email protected]>
1 parent 4b102bd commit 52b5ad0

9 files changed

+370
-0
lines changed
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2022 Pete Johanson
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config BOARD_ADAFRUIT_KB2040
5+
bool "Adafruit KB2040 Board"
6+
depends on SOC_RP2040
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Copyright (c) 2022 Peter Johanson
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if BOARD_ADAFRUIT_KB2040
5+
6+
config BOARD
7+
default "adafruit_kb2040"
8+
9+
config RP2_FLASH_W25Q080
10+
default y
11+
12+
endif # BOARD_ADAFRUIT_KB2040
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2021, Yonatan Schachter
3+
* Copyright (c) 2022, Peter Johanson
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>
8+
9+
&pinctrl {
10+
uart0_default: uart0_default {
11+
group1 {
12+
pinmux = <UART0_TX_P0>;
13+
};
14+
group2 {
15+
pinmux = <UART0_RX_P1>;
16+
input-enable;
17+
};
18+
};
19+
20+
i2c1_default: i2c1_default {
21+
group1 {
22+
pinmux = <I2C1_SDA_P2>;
23+
input-enable;
24+
};
25+
group2 {
26+
pinmux = <I2C1_SCL_P3>;
27+
input-enable;
28+
};
29+
};
30+
31+
spi0_default: spi0_default {
32+
group1 {
33+
pinmux = <SPI0_TX_P19>;
34+
};
35+
group2 {
36+
pinmux = <SPI0_RX_P20>;
37+
input-enable;
38+
};
39+
group3 {
40+
pinmux = <SPI0_SCK_P18>;
41+
};
42+
};
43+
44+
adc_default: adc_default {
45+
group1 {
46+
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
47+
input-enable;
48+
};
49+
};
50+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright (c) 2021 Yonatan Schachter
3+
* Copyright (c) 2022 Peter Johanson
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
/dts-v1/;
9+
10+
#include <rpi_pico/rp2040.dtsi>
11+
#include "adafruit_kb2040-pinctrl.dtsi"
12+
#include "sparkfun_pro_micro_connector.dtsi"
13+
#include <freq.h>
14+
15+
/ {
16+
chosen {
17+
zephyr,sram = &sram0;
18+
zephyr,flash = &flash0;
19+
zephyr,console = &uart0;
20+
zephyr,shell-uart = &uart0;
21+
zephyr,code-partition = &code_partition;
22+
};
23+
24+
aliases {
25+
watchdog0 = &wdt0;
26+
};
27+
28+
xtal_clk: xtal-clk {
29+
compatible = "fixed-clock";
30+
clock-frequency = <12000000>;
31+
#clock-cells = <0>;
32+
};
33+
};
34+
35+
&flash0 {
36+
reg = <0x10000000 DT_SIZE_M(8)>;
37+
38+
partitions {
39+
compatible = "fixed-partitions";
40+
#address-cells = <1>;
41+
#size-cells = <1>;
42+
43+
/* Reserved memory for the second stage bootloader */
44+
second_stage_bootloader: partition@0 {
45+
label = "second_stage_bootloader";
46+
reg = <0x00000000 0x100>;
47+
read-only;
48+
};
49+
50+
/*
51+
* Usable flash. Starts at 0x100, after the bootloader. The partition
52+
* size is 8MB minus the 0x100 bytes taken by the bootloader.
53+
*/
54+
code_partition: partition@100 {
55+
label = "code";
56+
reg = <0x100 (DT_SIZE_M(8) - 0x100)>;
57+
read-only;
58+
};
59+
};
60+
};
61+
62+
&uart0 {
63+
current-speed = <115200>;
64+
status = "okay";
65+
pinctrl-0 = <&uart0_default>;
66+
pinctrl-names = "default";
67+
};
68+
69+
&spi0 {
70+
status = "okay";
71+
pinctrl-0 = <&spi0_default>;
72+
pinctrl-names = "default";
73+
clock-frequency = <DT_FREQ_M(8)>;
74+
};
75+
76+
&i2c1 {
77+
status = "okay";
78+
pinctrl-0 = <&i2c1_default>;
79+
pinctrl-names = "default";
80+
clock-frequency = <I2C_BITRATE_FAST>;
81+
};
82+
83+
&gpio0 {
84+
status = "okay";
85+
};
86+
87+
&wdt0 {
88+
status = "okay";
89+
};
90+
91+
&adc {
92+
status = "okay";
93+
pinctrl-0 = <&adc_default>;
94+
pinctrl-names = "default";
95+
};
96+
97+
zephyr_udc0: &usbd {
98+
status = "okay";
99+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
identifier: adafruit_kb2040
2+
name: Adafruit KB2040
3+
type: mcu
4+
arch: arm
5+
flash: 8192
6+
ram: 264
7+
toolchain:
8+
- zephyr
9+
- gnuarmemb
10+
- xtools
11+
supported:
12+
- uart
13+
- gpio
14+
- adc
15+
- i2c
16+
- spi
17+
- hwinfo
18+
- watchdog
19+
- pwm
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
CONFIG_SOC_SERIES_RP2XXX=y
4+
CONFIG_SOC_RP2040=y
5+
CONFIG_BOARD_ADAFRUIT_KB2040=y
6+
7+
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000
8+
9+
# enable uart driver
10+
CONFIG_SERIAL=y
11+
CONFIG_UART_INTERRUPT_DRIVEN=y
12+
13+
# enable console
14+
CONFIG_CONSOLE=y
15+
CONFIG_UART_CONSOLE=y
16+
17+
# Enable reset by default
18+
CONFIG_RESET=y
19+
20+
# Code partition needed to target the correct flash range
21+
CONFIG_USE_DT_CODE_PARTITION=y
22+
23+
# Output UF2 by default, native bootloader supports it.
24+
CONFIG_BUILD_OUTPUT_UF2=y
289 KB
Loading
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
.. _adafruit_kb2040:
2+
3+
Adafruit KB2040
4+
###############
5+
6+
Overview
7+
********
8+
9+
The Adafruit KB2040 is a small, low-cost, versatile board from
10+
Adafruit. It is equipped with an RP2040 SoC, an on-board RGB Neopixel,
11+
a USB connector, and a STEMMA QT connector. The USB bootloader allows
12+
it to be flashed without any adapter, in a drag-and-drop manner.
13+
14+
Hardware
15+
********
16+
- Dual core Arm Cortex-M0+ processor running up to 133MHz
17+
- 264KB on-chip SRAM
18+
- 8MB on-board QSPI flash with XIP capabilities
19+
- 18 GPIO pins
20+
- 4 Analog inputs
21+
- 1 UART peripherals
22+
- 1 SPI controllers
23+
- 2 I2C controllers (one via STEMMA QT connector)
24+
- 16 PWM channels
25+
- USB 1.1 controller (host/device)
26+
- 8 Programmable I/O (PIO) for custom peripherals
27+
- On-board RGB LED
28+
- 1 Watchdog timer peripheral
29+
30+
31+
.. figure:: img/kb2040.jpg
32+
:align: center
33+
:alt: Adafruit KB2040
34+
35+
Adafruit KB2040 (Image courtesy of Adafruit)
36+
37+
Supported Features
38+
==================
39+
40+
The adafruit_kb2040 board configuration supports the following
41+
hardware features:
42+
43+
.. list-table::
44+
:header-rows: 1
45+
46+
* - Peripheral
47+
- Kconfig option
48+
- Devicetree compatible
49+
* - NVIC
50+
- N/A
51+
- :dtcompatible:`arm,v6m-nvic`
52+
* - UART
53+
- :kconfig:option:`CONFIG_SERIAL`
54+
- :dtcompatible:`raspberrypi,pico-uart`
55+
* - GPIO
56+
- :kconfig:option:`CONFIG_GPIO`
57+
- :dtcompatible:`raspberrypi,pico-gpio`
58+
* - ADC
59+
- :kconfig:option:`CONFIG_ADC`
60+
- :dtcompatible:`raspberrypi,pico-adc`
61+
* - I2C
62+
- :kconfig:option:`CONFIG_I2C`
63+
- :dtcompatible:`snps,designware-i2c`
64+
* - SPI
65+
- :kconfig:option:`CONFIG_SPI`
66+
- :dtcompatible:`raspberrypi,pico-spi`
67+
* - USB Device
68+
- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
69+
- :dtcompatible:`raspberrypi,pico-usbd`
70+
* - HWINFO
71+
- :kconfig:option:`CONFIG_HWINFO`
72+
- N/A
73+
* - Watchdog Timer (WDT)
74+
- :kconfig:option:`CONFIG_WATCHDOG`
75+
- :dtcompatible:`raspberrypi,pico-watchdog`
76+
* - PWM
77+
- :kconfig:option:`CONFIG_PWM`
78+
- :dtcompatible:`raspberrypi,pico-pwm`
79+
80+
Pin Mapping
81+
===========
82+
83+
The peripherals of the RP2040 SoC can be routed to various pins on the board.
84+
The configuration of these routes can be modified through DTS. Please refer to
85+
the datasheet to see the possible routings for each peripheral.
86+
87+
Default Zephyr Peripheral Mapping:
88+
----------------------------------
89+
90+
.. rst-class:: rst-columns
91+
92+
- UART0_TX : P0
93+
- UART0_RX : P1
94+
- I2C1_SDA : P2
95+
- I2C1_SCL : P3
96+
- SPI0_RX : P20
97+
- SPI0_SCK : P18
98+
- SPI0_TX : P19
99+
100+
Programming and Debugging
101+
*************************
102+
103+
Flashing
104+
========
105+
106+
Using UF2
107+
---------
108+
109+
Since it doesn't expose the SWD pins, you must flash the Adafruit KB2040 with
110+
a UF2 file. By default, building an app for this board will generate a
111+
`build/zephyr/zephyr.uf2` file. If the KB2040 is powered on with the `BOOTSEL`
112+
button pressed, it will appear on the host as a mass storage device. The
113+
UF2 file should be drag-and-dropped to the device, which will flash the KB2040.
114+
115+
.. target-notes::
116+
117+
.. _Getting Started with Raspberry Pi Pico:
118+
https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf
119+
120+
.. _Primary Guide\: Adafruit KB2040:
121+
https://learn.adafruit.com/adafruit-kb2040
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright (c) 2020 Pete Johanson
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*/
6+
7+
/ {
8+
pro_micro: connector {
9+
compatible = "sparkfun,pro-micro";
10+
#gpio-cells = <2>;
11+
gpio-map-mask = <0xffffffff 0xffffffc0>;
12+
gpio-map-pass-thru = <0 0x3f>;
13+
gpio-map
14+
= <0 0 &gpio0 0 0> /* D0 */
15+
, <1 0 &gpio0 1 0> /* D1 */
16+
, <2 0 &gpio0 2 0> /* D2 */
17+
, <3 0 &gpio0 3 0> /* D3 */
18+
, <4 0 &gpio0 4 0> /* D4/A6 */
19+
, <5 0 &gpio0 5 0> /* D5 */
20+
, <6 0 &gpio0 6 0> /* D6/A7 */
21+
, <7 0 &gpio0 7 0> /* D7 */
22+
, <8 0 &gpio0 8 0> /* D8/A8 */
23+
, <9 0 &gpio0 9 0> /* D9/A9 */
24+
, <10 0 &gpio0 10 0> /* D10/A10 */
25+
, <16 0 &gpio0 19 0> /* D16 */
26+
, <14 0 &gpio0 20 0> /* D14 */
27+
, <15 0 &gpio0 18 0> /* D15 */
28+
, <18 0 &gpio0 26 0> /* D18/A0 */
29+
, <19 0 &gpio0 27 0> /* D19/A1 */
30+
, <20 0 &gpio0 28 0> /* D20/A2 */
31+
, <21 0 &gpio0 29 0> /* D21/A3 */
32+
;
33+
};
34+
35+
};
36+
37+
pro_micro_i2c: &i2c1 {};
38+
pro_micro_spi: &spi0 {};
39+
pro_micro_serial: &uart0 {};

0 commit comments

Comments
 (0)