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 support for Nucleo WB55CG board & Zephirum shield #938

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# STM32WB55CG Nucleo USB dongle configuration

# Copyright (c) 2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

config BOARD_NUCLEO_WB55CG_DONGLE
bool "Nucleo WB55CG USB Dongle"
depends on SOC_STM32WB55XX
33 changes: 33 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# STM32LWB55CG USB dongle configuration

# Copyright (c) 2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

if BOARD_NUCLEO_WB55CG_DONGLE

config BOARD
default "nucleo_wb55cg_dongle"

config CLOCK_STM32_LSE
Copy link
Contributor

Choose a reason for hiding this comment

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

This one was nixed in Zephyr 3.0.0 too.

default y

choice STM32_LPTIM_CLOCK
default STM32_LPTIM_CLOCK_LSE
depends on STM32_LPTIM_TIMER
endchoice

choice BT_HCI_BUS_TYPE
default BT_STM32_IPM
depends on BT
endchoice

config SYSTEM_WORKQUEUE_STACK_SIZE
default 2048

config ZMK_USB
default y

config ZMK_KSCAN_MATRIX_POLLING
default y

endif # BOARD_NUCLEO_WB55CG
10 changes: 10 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/README.md
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's appropriate to put shield-specific information in this readme when the board could be used by other shields.

Most "generic" boards don't have READMEs, so you could probably just omit this.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Nucleo WB55CG dongle support for [Zephirum](http://zephirum.tuxfamily.org)

Zephirum is an ergo monoblock angled keyboards powered by a Nucleo
WB55CG USB dongle.

## Building ZMK firmware

```
west build -b nucleo_wb55cg_dongle -- -DSHIELD=zephirum
```
6 changes: 6 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse")

include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake)
136 changes: 136 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/nucleo_wb55cg_dongle.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright (c) 2021 The ZMK Contributors
* SPDX-License-Identifier: MIT
*/

/dts-v1/;
#include <st/wb/stm32wb55Xg.dtsi>
#include <st/wb/stm32wb55cgux-pinctrl.dtsi>

/ {
model = "STMicroelectronics STM32WB55CG USB dongle";
compatible = "st,stm32wb55cg-dongle";

chosen {
zephyr,bt-mon-uart = &lpuart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};

leds {
compatible = "gpio-leds";
blue_led_1: led_0 {
gpios = <&gpioa 4 GPIO_ACTIVE_HIGH>;
label = "D1";
};
green_led_2: led_1 {
gpios = <&gpiob 0 GPIO_ACTIVE_HIGH>;
label = "D2";
};
red_led_3: led_2 {
gpios = <&gpiob 1 GPIO_ACTIVE_HIGH>;
label = "D3";
};
};

gpio_keys {
compatible = "gpio-keys";
user_button_1: button_0 {
label = "SW1";
gpios = <&gpioa 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
};
};

aliases {
led0 = &blue_led_1;
led1 = &green_led_2;
led2 = &red_led_3;
sw0 = &user_button_1;
};
};

&i2c1 {
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.

Suggested change
status = "okay";

Per a suggestion made on another board:

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

I'm only going to make the suggestion in one place, but this applies to a number of nodes.

clock-frequency = <I2C_BITRATE_FAST>;
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
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
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>;
pinctrl-names = "default";

Copy link
Contributor

Choose a reason for hiding this comment

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

pinctrl-names is now a required property. As above, this suggestion is applicable to a number of nodes.

...In truth, a chunk of this configuration should probably be pulled out into app/boards/arm/nucleo_wb55cg_dongle/nucleo_wb55cg_dongle.dtsi and #included in this file—in order to leverage the pinctrl system introduced with Zephyr 3.2.

};

&rtc {
status = "okay";
};

&spi1 {
pinctrl-0 = <&spi1_sck_pa5 &spi1_miso_pa6 &spi1_mosi_pa7>;
status = "okay";
};

&timers2 {
status = "okay";
pwm2: pwm {
status = "okay";
pinctrl-0 = <&tim2_ch1_pa0>;
};
};

&lpuart1 {
pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>;
current-speed = <115200>;
status = "okay";
};

&adc1 {
pinctrl-0 = <&adc1_in6_pa1>;
status = "okay";
};

&iwdg {
status = "okay";
};

&lptim1 {
status = "okay";
};

&usb {
status = "okay";
pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>;
};

&flash0 {
/*
* For more information, see:
* http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

/* Set all partitions with first 812K of flash */
/* last 212K are reseved for M0 usage */
/* Configure partitions to make use of the whole 812K */

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0xc000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x5c000>;
};
slot1_partition: partition@68000 {
label = "image-1";
reg = <0x00068000 0x5c000>;
};
scratch_partition: partition@c4000 {
label = "image-scratch";
reg = <0x000c4000 0x4000>;
};
storage_partition: partition@c8000 {
label = "storage";
reg = <0x000c8000 0x3000>;
};

};
};
19 changes: 19 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/nucleo_wb55cg_dongle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
identifier: nucleo_wb55cg_dongle
name: ST Nucleo WB55CG Dongle
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 96
flash: 1024
supported:
- gpio
- i2c
- counter
- spi
- pwm
- adc
- watchdog
- usb_device
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
file_format: "1"
id: nucleo_wb55cg_dongle
name: ST Nucleo WB55CG Dongle
type: board
arch: arm
outputs:
- usb
url: https://www.st.com/en/evaluation-tools/p-nucleo-wb55.html
exposes: [nucleo_wb55cg_dongle]
26 changes: 26 additions & 0 deletions app/boards/arm/nucleo_wb55cg_dongle/nucleo_wb55cg_dongle_defconfig
Copy link
Contributor

Choose a reason for hiding this comment

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

Per the Zephyr 3.0.0 changelog:

STM32 clock_control driver configuration was moved from Kconfig to devicetree. See the st,stm32-rcc devicetree binding for more information. As a consequence, [the] following Kconfig symbols were removed:

  • CONFIG_CLOCK_STM32_SYSCLK_SRC_HSE
  • CONFIG_CLOCK_STM32_APB1_PRESCALER
  • CONFIG_CLOCK_STM32_APB2_PRESCALER
  • CONFIG_CLOCK_STM32_CPU1_PRESCALER
  • CONFIG_CLOCK_STM32_CPU2_PRESCALER
  • CONFIG_CLOCK_STM32_AHB4_PRESCALER

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
CONFIG_SOC_SERIES_STM32WBX=y
CONFIG_SOC_STM32WB55XX=y
# 32MHz system clock
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000

# enable pinmux
CONFIG_PINMUX=y

# enable GPIO
CONFIG_GPIO=y

# clock configuration
CONFIG_CLOCK_CONTROL=y
# SYSCLK selection
# CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
CONFIG_CLOCK_STM32_SYSCLK_SRC_HSE=y
CONFIG_CLOCK_STM32_HSE_CLOCK=32000000

CONFIG_CLOCK_STM32_CPU1_PRESCALER=1
CONFIG_CLOCK_STM32_CPU2_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
CONFIG_CLOCK_STM32_AHB4_PRESCALER=1

# Enable MPU
CONFIG_ARM_MPU=y
45 changes: 45 additions & 0 deletions app/boards/shields/zephirum/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

if SHIELD_ZEPHIRUM

config ZMK_KEYBOARD_NAME
default "Zephirum"

if ZMK_DISPLAY

config I2C
default y

config SSD1306
default y

config SSD1306_REVERSE_MODE
default y

endif # ZMK_DISPLAY

if LVGL

config LVGL_HOR_RES_MAX
default 128

config LVGL_VER_RES_MAX
default 32

config LVGL_VDB_SIZE
default 64

config LVGL_DPI
default 148

config LVGL_BITS_PER_PIXEL
default 1

choice LVGL_COLOR_DEPTH
default LVGL_COLOR_DEPTH_1
Comment on lines +24 to +40
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 LVGL_HOR_RES_MAX
default 128
config LVGL_VER_RES_MAX
default 32
config LVGL_VDB_SIZE
default 64
config LVGL_DPI
default 148
config LVGL_BITS_PER_PIXEL
default 1
choice LVGL_COLOR_DEPTH
default LVGL_COLOR_DEPTH_1
config LV_Z_VDB_SIZE
default 64
config LV_Z_DPI
default 148
config LV_Z_BITS_PER_PIXEL
default 1
choice LV_COLOR_DEPTH
default LV_COLOR_DEPTH_1

Most of these changes were made as part of the upgrade to Zephyr 3.2, and I suspect setting the maximum horizontal and vertical resolution is not strictly necessary here.

endchoice

endif # LVGL

endif
8 changes: 8 additions & 0 deletions app/boards/shields/zephirum/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2021 The ZMK Contributors
#
# SPDX-License-Identifier: MIT
#

config SHIELD_ZEPHIRUM
def_bool $(shields_list_contains,zephirum)
27 changes: 27 additions & 0 deletions app/boards/shields/zephirum/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# [Zephirum](http://zephirum.tuxfamily.org)

## Description

Despite having a look similar to many other ergo monoblock angled
keyboards, this build has a couple of unique features:

- it has been designed with [LibrePCB](https://librepcb.org/). This EDA
tool deserves more love, so I published the project & library files
under CC0 1.0 licence.

- its MCU board is a Nucleo STM32WB55CG USB dongle (MB1293); it is
surface mounted on the top to showcase it ☺

Regarding the other features, they are more classic:

- it has been designed for Kailh Choc switches with MBK keycaps
(L=17.5mm × H=16.5mm)

- it is powered by ZMK; only USB HID is supported so far.

- it features an I²C 128x32 OLED screen (SSD1306)


## Resources

<https://git.tuxfamily.org/zephirum>
2 changes: 2 additions & 0 deletions app/boards/shields/zephirum/zephirum.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Uncomment the following line to enable OLED display.
# CONFIG_ZMK_DISPLAY=y
56 changes: 56 additions & 0 deletions app/boards/shields/zephirum/zephirum.keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2021 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>

#define BASE 0
#define SYMBOLS 1
#define NUM_NAV 2

#define COMPOSE CAPS

/ {
keymap {
compatible = "zmk,keymap";

default_layer {
label = "Base";

bindings = <
&kp COMPOSE &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp SQT
&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp ENTER
&sk LGUI &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp SLASH &kp MINUS
&sl SYMBOLS &kp BSPC &sk LCTRL &sl NUM_NAV
&none &sk LALT &kp SPACE &sk RSHIFT
>;
};

symbols_layer {
label = "Symbols";
bindings = <
&kp ESC &none &kp LT &kp EQUAL &kp GT &kp MINUS &kp TILDE &kp LBKT &kp UNDER &kp RBKT &none &none
&none &kp HASH &kp LPAR &kp DLLR &kp RPAR &kp EXCL &kp AT &kp LBRC &kp STAR &kp RBRC &kp COLON &trans
&trans &kp CARET &kp PRCNT &kp PIPE &kp BSLH &kp PLUS &kp AMPS &kp GRAVE &kp DQT &kp SQT &kp QMARK &none
&trans &kp DEL &trans &none
&none &trans &none &trans
>;
};

num_nav_layer {
label = "Num/Nav";
bindings = <
&kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &none
&none &none &kp HOME &kp PG_UP &kp END &none &none &kp LEFT &kp UP &kp RIGHT &none &trans
&trans &none &none &kp PG_DN &none &none &none &none &kp DOWN &trans &none &none
&none &none &trans &trans
&none &trans &trans &trans
>;
};
};
};
Loading