Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions boards/arm/adafruit_kb2040/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2022 Pete Johanson
# SPDX-License-Identifier: Apache-2.0

config BOARD_ADAFRUIT_KB2040
bool "Adafruit KB2040 Board"
depends on SOC_RP2040
12 changes: 12 additions & 0 deletions boards/arm/adafruit_kb2040/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright (c) 2022 Peter Johanson
# SPDX-License-Identifier: Apache-2.0

if BOARD_ADAFRUIT_KB2040

config BOARD
default "adafruit_kb2040"

config RP2_FLASH_W25Q080
default y

endif # BOARD_ADAFRUIT_KB2040
50 changes: 50 additions & 0 deletions boards/arm/adafruit_kb2040/adafruit_kb2040-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2021, Yonatan Schachter
* Copyright (c) 2022, Peter Johanson
* SPDX-License-Identifier: Apache-2.0
*/

#include <dt-bindings/pinctrl/rpi-pico-rp2040-pinctrl.h>

&pinctrl {
uart0_default: uart0_default {
group1 {
pinmux = <UART0_TX_P0>;
};
group2 {
pinmux = <UART0_RX_P1>;
input-enable;
};
};

i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_P2>;
input-enable;
};
group2 {
pinmux = <I2C1_SCL_P3>;
input-enable;
};
};

spi0_default: spi0_default {
group1 {
pinmux = <SPI0_TX_P19>;
};
group2 {
pinmux = <SPI0_RX_P20>;
input-enable;
};
group3 {
pinmux = <SPI0_SCK_P18>;
};
};

adc_default: adc_default {
group1 {
pinmux = <ADC_CH0_P26>, <ADC_CH1_P27>, <ADC_CH2_P28>, <ADC_CH3_P29>;
input-enable;
};
};
};
99 changes: 99 additions & 0 deletions boards/arm/adafruit_kb2040/adafruit_kb2040.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* Copyright (c) 2021 Yonatan Schachter
* Copyright (c) 2022 Peter Johanson
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

#include <rpi_pico/rp2040.dtsi>
#include "adafruit_kb2040-pinctrl.dtsi"
#include "sparkfun_pro_micro_connector.dtsi"
#include <freq.h>

/ {
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,code-partition = &code_partition;
};

aliases {
watchdog0 = &wdt0;
};

xtal_clk: xtal-clk {
compatible = "fixed-clock";
clock-frequency = <12000000>;
#clock-cells = <0>;
};
};

&flash0 {
reg = <0x10000000 DT_SIZE_M(8)>;

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

/* Reserved memory for the second stage bootloader */
second_stage_bootloader: partition@0 {
label = "second_stage_bootloader";
reg = <0x00000000 0x100>;
read-only;
};

/*
* Usable flash. Starts at 0x100, after the bootloader. The partition
* size is 8MB minus the 0x100 bytes taken by the bootloader.
*/
code_partition: partition@100 {
label = "code";
reg = <0x100 (DT_SIZE_M(8) - 0x100)>;
read-only;
};
};
};

&uart0 {
current-speed = <115200>;
status = "okay";
pinctrl-0 = <&uart0_default>;
pinctrl-names = "default";
};

&spi0 {
status = "okay";
pinctrl-0 = <&spi0_default>;
pinctrl-names = "default";
clock-frequency = <DT_FREQ_M(8)>;
};

&i2c1 {
status = "okay";
pinctrl-0 = <&i2c1_default>;
pinctrl-names = "default";
clock-frequency = <I2C_BITRATE_FAST>;
};

&gpio0 {
status = "okay";
};

&wdt0 {
status = "okay";
};

&adc {
status = "okay";
pinctrl-0 = <&adc_default>;
pinctrl-names = "default";
};

zephyr_udc0: &usbd {
status = "okay";
};
19 changes: 19 additions & 0 deletions boards/arm/adafruit_kb2040/adafruit_kb2040.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
identifier: adafruit_kb2040
name: Adafruit KB2040
type: mcu
arch: arm
flash: 8192
ram: 264
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- uart
- gpio
- adc
- i2c
- spi
- hwinfo
- watchdog
- pwm
24 changes: 24 additions & 0 deletions boards/arm/adafruit_kb2040/adafruit_kb2040_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_SOC_SERIES_RP2XXX=y
CONFIG_SOC_RP2040=y
CONFIG_BOARD_ADAFRUIT_KB2040=y

CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000

# enable uart driver
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y

# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

# Enable reset by default
CONFIG_RESET=y

# Code partition needed to target the correct flash range
CONFIG_USE_DT_CODE_PARTITION=y

# Output UF2 by default, native bootloader supports it.
CONFIG_BUILD_OUTPUT_UF2=y
Binary file added boards/arm/adafruit_kb2040/doc/img/kb2040.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
121 changes: 121 additions & 0 deletions boards/arm/adafruit_kb2040/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
.. _adafruit_kb2040:

Adafruit KB2040
###############

Overview
********

The Adafruit KB2040 is a small, low-cost, versatile board from
Adafruit. It is equipped with an RP2040 SoC, an on-board RGB Neopixel,
a USB connector, and a STEMMA QT connector. The USB bootloader allows
it to be flashed without any adapter, in a drag-and-drop manner.

Hardware
********
- Dual core Arm Cortex-M0+ processor running up to 133MHz
- 264KB on-chip SRAM
- 8MB on-board QSPI flash with XIP capabilities
- 18 GPIO pins
- 4 Analog inputs
- 1 UART peripherals
- 1 SPI controllers
- 2 I2C controllers (one via STEMMA QT connector)
- 16 PWM channels
- USB 1.1 controller (host/device)
- 8 Programmable I/O (PIO) for custom peripherals
- On-board RGB LED
- 1 Watchdog timer peripheral


.. figure:: img/kb2040.jpg
:align: center
:alt: Adafruit KB2040

Adafruit KB2040 (Image courtesy of Adafruit)

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

The adafruit_kb2040 board configuration supports the following
hardware features:

.. list-table::
:header-rows: 1

* - Peripheral
- Kconfig option
- Devicetree compatible
* - NVIC
- N/A
- :dtcompatible:`arm,v6m-nvic`
* - UART
- :kconfig:option:`CONFIG_SERIAL`
- :dtcompatible:`raspberrypi,pico-uart`
* - GPIO
- :kconfig:option:`CONFIG_GPIO`
- :dtcompatible:`raspberrypi,pico-gpio`
* - ADC
- :kconfig:option:`CONFIG_ADC`
- :dtcompatible:`raspberrypi,pico-adc`
* - I2C
- :kconfig:option:`CONFIG_I2C`
- :dtcompatible:`snps,designware-i2c`
* - SPI
- :kconfig:option:`CONFIG_SPI`
- :dtcompatible:`raspberrypi,pico-spi`
* - USB Device
- :kconfig:option:`CONFIG_USB_DEVICE_STACK`
- :dtcompatible:`raspberrypi,pico-usbd`
* - HWINFO
- :kconfig:option:`CONFIG_HWINFO`
- N/A
* - Watchdog Timer (WDT)
- :kconfig:option:`CONFIG_WATCHDOG`
- :dtcompatible:`raspberrypi,pico-watchdog`
* - PWM
- :kconfig:option:`CONFIG_PWM`
- :dtcompatible:`raspberrypi,pico-pwm`

Pin Mapping
===========

The peripherals of the RP2040 SoC 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.

Default Zephyr Peripheral Mapping:
----------------------------------

.. rst-class:: rst-columns

- UART0_TX : P0
- UART0_RX : P1
- I2C1_SDA : P2
- I2C1_SCL : P3
- SPI0_RX : P20
- SPI0_SCK : P18
- SPI0_TX : P19

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

Flashing
========

Using UF2
---------

Since it doesn't expose the SWD pins, you must flash the Adafruit KB2040 with
a UF2 file. By default, building an app for this board will generate a
`build/zephyr/zephyr.uf2` file. If the KB2040 is powered on with the `BOOTSEL`
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 KB2040.

.. target-notes::

.. _Getting Started with Raspberry Pi Pico:
https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf

.. _Primary Guide\: Adafruit KB2040:
https://learn.adafruit.com/adafruit-kb2040
39 changes: 39 additions & 0 deletions boards/arm/adafruit_kb2040/sparkfun_pro_micro_connector.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020 Pete Johanson
*
* SPDX-License-Identifier: MIT
*/

/ {
pro_micro: connector {
compatible = "sparkfun,pro-micro";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map
= <0 0 &gpio0 0 0> /* D0 */
, <1 0 &gpio0 1 0> /* D1 */
, <2 0 &gpio0 2 0> /* D2 */
, <3 0 &gpio0 3 0> /* D3 */
, <4 0 &gpio0 4 0> /* D4/A6 */
, <5 0 &gpio0 5 0> /* D5 */
, <6 0 &gpio0 6 0> /* D6/A7 */
, <7 0 &gpio0 7 0> /* D7 */
, <8 0 &gpio0 8 0> /* D8/A8 */
, <9 0 &gpio0 9 0> /* D9/A9 */
, <10 0 &gpio0 10 0> /* D10/A10 */
, <16 0 &gpio0 19 0> /* D16 */
, <14 0 &gpio0 20 0> /* D14 */
, <15 0 &gpio0 18 0> /* D15 */
, <18 0 &gpio0 26 0> /* D18/A0 */
, <19 0 &gpio0 27 0> /* D19/A1 */
, <20 0 &gpio0 28 0> /* D20/A2 */
, <21 0 &gpio0 29 0> /* D21/A3 */
;
};

};

pro_micro_i2c: &i2c1 {};
pro_micro_spi: &spi0 {};
pro_micro_serial: &uart0 {};
Loading