From 0b406aacb853bf1998eea3a39bf5f82e61bab046 Mon Sep 17 00:00:00 2001 From: Gleb Sabirzyanov Date: Sat, 15 Jul 2023 15:32:57 +0600 Subject: [PATCH] Add Waveshare RP2040 Zero --- .../arm/waveshare_rp2040_zero/Kconfig.board | 6 ++ .../waveshare_rp2040_zero/Kconfig.defconfig | 15 ++++ .../waveshare_rp2040_zero-pinctrl.dtsi | 37 +++++++++ .../waveshare_rp2040_zero.dts | 81 +++++++++++++++++++ .../waveshare_rp2040_zero.yaml | 12 +++ .../waveshare_rp2040_zero_defconfig | 23 ++++++ 6 files changed, 174 insertions(+) create mode 100644 app/boards/arm/waveshare_rp2040_zero/Kconfig.board create mode 100644 app/boards/arm/waveshare_rp2040_zero/Kconfig.defconfig create mode 100644 app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero-pinctrl.dtsi create mode 100644 app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.dts create mode 100644 app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.yaml create mode 100644 app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero_defconfig diff --git a/app/boards/arm/waveshare_rp2040_zero/Kconfig.board b/app/boards/arm/waveshare_rp2040_zero/Kconfig.board new file mode 100644 index 00000000..4d12ab31 --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/Kconfig.board @@ -0,0 +1,6 @@ +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_WAVESHARE_RP2040_ZERO + bool "Waveshare RP2040 Zero Board" + depends on SOC_RP2040 diff --git a/app/boards/arm/waveshare_rp2040_zero/Kconfig.defconfig b/app/boards/arm/waveshare_rp2040_zero/Kconfig.defconfig new file mode 100644 index 00000000..7d252206 --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/Kconfig.defconfig @@ -0,0 +1,15 @@ +# Copyright (c) 2023 The ZMK Contributors +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_WAVESHARE_RP2040_ZERO + +config BOARD + default "waveshare_rp2040_zero" + +config RP2_FLASH_W25Q080 + default y + +config ZMK_USB + default y + +endif # BOARD_WAVESHARE_RP2040_ZERO diff --git a/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero-pinctrl.dtsi b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero-pinctrl.dtsi new file mode 100644 index 00000000..4597ad74 --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero-pinctrl.dtsi @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2023 The ZMK Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +&pinctrl { + uart1_default: uart0_default { + group1 { + pinmux = ; + }; + group2 { + pinmux = ; + input-enable; + }; + }; + + i2c1_default: i2c1_default { + group1 { + pinmux = , ; + input-enable; + input-schmitt-enable; + }; + }; + + + spi0_default: spi0_default { + group1 { + pinmux = , ; + }; + group2 { + pinmux = ; + input-enable; + }; + }; +}; diff --git a/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.dts b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.dts new file mode 100644 index 00000000..da300a46 --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.dts @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2023 The ZMK Contributors + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; + +#include +#include "waveshare_rp2040_zero-pinctrl.dtsi" +#include + +/ { + chosen { + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &uart0; + zephyr,code-partition = &code_partition; + }; +}; + +&flash0 { + /* 2MB of flash minus the 0x100 used for + * the second stage bootloader + */ + reg = <0x10000000 DT_SIZE_M(2)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* + * Start at the beginning of usable flash, 8MB minus the + * second stage space and the 16 KiB reserved for settings + */ + code_partition: partition@100 { + label = "code"; + reg = <0x100 (DT_SIZE_M(2) - DT_SIZE_K(16))>; + read-only; + }; + + /* + * The final 16 KiB is reserved for the application. + * Storage partition may be used by FCB or LittleFS. + */ + storage_partition: partition@7fbe00 { + label = "storage"; + reg = <0x007fbe00 DT_SIZE_K(16)>; + }; + }; +}; + +&uart1 { + current-speed = <115200>; + status = "okay"; + pinctrl-0 = <&uart1_default>; + pinctrl-names = "default"; +}; + +&spi0 { + status = "okay"; + pinctrl-0 = <&spi0_default>; + pinctrl-names = "default"; + clock-frequency = ; +}; + +&i2c1 { + status = "okay"; + pinctrl-0 = <&i2c1_default>; + pinctrl-names = "default"; + clock-frequency = ; +}; + +&gpio0 { + status = "okay"; +}; + +zephyr_udc0: &usbd { + status = "okay"; +}; diff --git a/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.yaml b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.yaml new file mode 100644 index 00000000..15133860 --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.yaml @@ -0,0 +1,12 @@ +identifier: waveshare_rp2040_zero +name: RP2040-Zero +type: mcu +arch: arm +flash: 2048 +ram: 264 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - serial diff --git a/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero_defconfig b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero_defconfig new file mode 100644 index 00000000..cebecdcc --- /dev/null +++ b/app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero_defconfig @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_RP2XXX=y +CONFIG_SOC_RP2040=y +CONFIG_BOARD_WAVESHARE_RP2040_ZERO=y + +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=240000000 + +# Enable GPIO +CONFIG_GPIO=y + +# enable uart driver +CONFIG_SERIAL=n + +# enable console +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=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