-
Notifications
You must be signed in to change notification settings - Fork 8.2k
boards: arm: Add adafruit_kb2040 board #51098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carlescufi
merged 4 commits into
zephyrproject-rtos:main
from
petejohanson:boards/adafruit-kb2040-upstream
Nov 3, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e84004c
dts: bindings: vendor-prefixes: add SparkFun
petejohanson a40a1c8
dts: bindings: gpio: Add SparkFun Pro Micro header
petejohanson aa93ecb
boards: arm: Add adafruit_kb2040 board
petejohanson de7223a
drivers: adc: Fix ADC tests for new RP2040 board.
petejohanson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| }; | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| /* | ||
| * Copyright (c) 2021 Yonatan Schachter | ||
yonsch marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * 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"; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
soburi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .. _Primary Guide\: Adafruit KB2040: | ||
| https://learn.adafruit.com/adafruit-kb2040 | ||
39 changes: 39 additions & 0 deletions
39
boards/arm/adafruit_kb2040/sparkfun_pro_micro_connector.dtsi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 {}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.