Skip to content
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

Add rp2040 zero #1871

Closed
wants to merge 5 commits into from
Closed
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 app/boards/arm/waveshare_rp2040_zero/Kconfig.board
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions app/boards/arm/waveshare_rp2040_zero/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2023 The ZMK Contributors
* SPDX-License-Identifier: Apache-2.0
*/

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

&pinctrl {
uart1_default: uart0_default {
group1 {
pinmux = <UART1_TX_P20>;
};
group2 {
pinmux = <UART1_RX_P5>;
input-enable;
};
};

i2c1_default: i2c1_default {
group1 {
pinmux = <I2C1_SDA_P22>, <I2C1_SCL_P23>;
input-enable;
input-schmitt-enable;
};
};


spi0_default: spi0_default {
group1 {
pinmux = <SPI0_TX_P3>, <SPI0_SCK_P6>;
};
group2 {
pinmux = <SPI0_RX_P4>;
input-enable;
};
};
};
88 changes: 88 additions & 0 deletions app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: Apache-2.0
*/

/dts-v1/;

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

/ {
chosen {
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,console = &uart0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For boards added to ZMK directly, we usually set the console to be the CDC ACM node added to the usb node. See https://github.com/zmkfirmware/zmk/blob/main/app/boards/arm/nice_nano/nice_nano.dtsi#L64 for an example node.

zephyr,code-partition = &code_partition;
};

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

};

&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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ZMK boards, don't enable the UART, SPI, etc by default. This is a bit different from the upstream Zephyr board approach.

pinctrl-0 = <&uart1_default>;
pinctrl-names = "default";
};

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

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

&gpio0 {
status = "okay";
};

zephyr_udc0: &usbd {
status = "okay";
};
12 changes: 12 additions & 0 deletions app/boards/arm/waveshare_rp2040_zero/waveshare_rp2040_zero.zmk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
identifier: waveshare_rp2040_zero
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This .zmk.yml file format is not the same as the Zephyr format. See existing ZMK boards for examples of the metadata we use.

name: RP2040-Zero
type: mcu
arch: arm
flash: 2048
ram: 264
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- serial
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2023 The ZMK Contributors
# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=240000000
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=125000000

I had to fix this in our other boards recently, they had the wrong sys clock frequency set.


# 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
2 changes: 2 additions & 0 deletions app/core-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ board:
- nice_nano_v2
- nrfmicro_13
- proton_c
- waveshare_rp2040_zero
shield:
- corne_left
- corne_right
Expand All @@ -11,6 +12,7 @@ shield:
include:
- board: bdn9_rev2
- board: nice60
- board: waveshare_rp2040_zero
- board: seeeduino_xiao_ble
shield: hummingbird
- board: nrf52840_m2
Expand Down