From 4294b4873eb673b8ec2d88864eb90afc32e0a5af Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 12 Jun 2020 00:36:54 -0400 Subject: [PATCH 01/12] Initial basic work on nice!nano board support. --- app/boards/arm/nice_nano/Kconfig.board | 8 ++ app/boards/arm/nice_nano/Kconfig.defconfig | 28 ++++++ .../arm/nice_nano/arduino_pro_micro_pins.dtsi | 37 ++++++++ app/boards/arm/nice_nano/board.cmake | 5 ++ app/boards/arm/nice_nano/nice_nano.dts | 87 +++++++++++++++++++ app/boards/arm/nice_nano/nice_nano.yaml | 15 ++++ app/boards/arm/nice_nano/nice_nano_defconfig | 13 +++ 7 files changed, 193 insertions(+) create mode 100644 app/boards/arm/nice_nano/Kconfig.board create mode 100644 app/boards/arm/nice_nano/Kconfig.defconfig create mode 100644 app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi create mode 100644 app/boards/arm/nice_nano/board.cmake create mode 100644 app/boards/arm/nice_nano/nice_nano.dts create mode 100644 app/boards/arm/nice_nano/nice_nano.yaml create mode 100644 app/boards/arm/nice_nano/nice_nano_defconfig diff --git a/app/boards/arm/nice_nano/Kconfig.board b/app/boards/arm/nice_nano/Kconfig.board new file mode 100644 index 00000000..60ee58b5 --- /dev/null +++ b/app/boards/arm/nice_nano/Kconfig.board @@ -0,0 +1,8 @@ +# nice!nano board configuration + +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config BOARD_NICE_NANO + bool "nice!nano" + depends on SOC_NRF52840_QIAA diff --git a/app/boards/arm/nice_nano/Kconfig.defconfig b/app/boards/arm/nice_nano/Kconfig.defconfig new file mode 100644 index 00000000..cb4b52af --- /dev/null +++ b/app/boards/arm/nice_nano/Kconfig.defconfig @@ -0,0 +1,28 @@ +# Electronut Labs Papyr board configuration + +# Copyright (c) 2018 Electronut Labs +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_NICE_NANO + +config BOARD + default "nice_nano" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config IEEE802154_NRF5 + default y + depends on IEEE802154 + +config BT_CTLR + default BT + +endif # BOARD_NICE_NANO diff --git a/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi b/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi new file mode 100644 index 00000000..f11dcddf --- /dev/null +++ b/app/boards/arm/nice_nano/arduino_pro_micro_pins.dtsi @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +/ { + pro_micro_pins: connector { + compatible = "arduino-pro-micro"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = + <1 0 &gpio0 6 0>, /* D1 */ + <0 0 &gpio0 8 0>, /* D0 */ + <2 0 &gpio0 17 0>, /* D2 */ + <3 0 &gpio0 20 0>, /* D3 */ + <4 0 &gpio0 22 0>, /* D4/A6 */ + <5 0 &gpio0 24 0>, /* D5 */ + <6 0 &gpio1 0 0>, /* D6/A7 */ + <7 0 &gpio0 11 0>, /* D7 */ + <8 0 &gpio1 4 0>, /* D8/A8 */ + <9 0 &gpio1 6 0>, /* D9/A9 */ + <10 0 &gpio0 9 0>, /* D10/A10 */ + <16 0 &gpio0 10 0>, /* D16 */ + <14 0 &gpio1 11 0>, /* D14 */ + <15 0 &gpio1 13 0>, /* D15 */ + <18 0 &gpio1 15 0>, /* A0 */ + <19 0 &gpio0 2 0>, /* A1 */ + <20 0 &gpio0 29 0>, /* A2 */ + <21 0 &gpio0 31 0>; /* A3 */ + }; +}; + +pro_micro_i2c: &i2c1 {}; +pro_micro_spi: &spi1 {}; +pro_micro_serial: &uart1 {}; diff --git a/app/boards/arm/nice_nano/board.cmake b/app/boards/arm/nice_nano/board.cmake new file mode 100644 index 00000000..12a1d93b --- /dev/null +++ b/app/boards/arm/nice_nano/board.cmake @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts new file mode 100644 index 00000000..d2cd165f --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include +#include "arduino_pro_micro_pins.dtsi" + +/ { + model = "nice!nano"; + + chosen { + zephyr,code-partition = &code_partition; + //zephyr,bt-mon-uart = &uart0; + //zephyr,bt-c2h-uart = &uart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + blue_led: led_0 { + gpios = <&gpio0 15 GPIO_ACTIVE_LOW>; + label = "Blue LED"; + }; + }; + +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uart"; + current-speed = <115200>; + tx-pin = <6>; + rx-pin = <8>; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + sda-pin = <17>; + scl-pin = <20>; +}; + +&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>; + + boot_partition: partition@0 { + label = "adafruit_boot"; + reg = <0x000000000 0x0000C000>; + }; + code_partition: partition@26000 { + label = "code_partition"; + reg = <0x00026000 0x0001e000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; + diff --git a/app/boards/arm/nice_nano/nice_nano.yaml b/app/boards/arm/nice_nano/nice_nano.yaml new file mode 100644 index 00000000..1c367324 --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano.yaml @@ -0,0 +1,15 @@ +identifier: nice_nano +name: nice!nano +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - ble + - ieee802154 + - pwm + - watchdog diff --git a/app/boards/arm/nice_nano/nice_nano_defconfig b/app/boards/arm/nice_nano/nice_nano_defconfig new file mode 100644 index 00000000..f9be0ee8 --- /dev/null +++ b/app/boards/arm/nice_nano/nice_nano_defconfig @@ -0,0 +1,13 @@ +# SPDX-License-Identifier: MIT + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_NICE_NANO=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# enable GPIO +CONFIG_GPIO=y + +CONFIG_USE_DT_CODE_PARTITION=y From a5ade1f94776059ec7e367e2af81e53fa21be2f7 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 12 Jun 2020 15:03:54 -0400 Subject: [PATCH 02/12] Add missing `compatible` entry for the toplevel board. --- app/boards/arm/nice_nano/nice_nano.dts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index d2cd165f..79f3cb7c 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -10,6 +10,7 @@ / { model = "nice!nano"; + compatible = "nice,nano"; chosen { zephyr,code-partition = &code_partition; From 75b01869f04689f61c6238d1e68f39be81d5e96b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 12 Jun 2020 21:50:05 -0400 Subject: [PATCH 03/12] Add (untested) pins for SPI. --- app/boards/arm/nice_nano/nice_nano.dts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 79f3cb7c..638d3cbc 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -51,6 +51,16 @@ scl-pin = <20>; }; +/* TODO: Needs testing */ +&spi0 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + /* status = "okay"; */ + sck-pin = <13>; + mosi-pin = <10>; + miso-pin = <11>; +}; + &flash0 { /* * For more information, see: From 879ce6fa6bb35b630983e7b2579ea0aeb4e3f2e6 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 12 Jun 2020 23:44:58 -0400 Subject: [PATCH 04/12] Enable BLE by default as well. --- .../shields/petejohanson_proton_handwire/Kconfig.defconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig b/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig index 196c636e..1149c337 100644 --- a/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig +++ b/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig @@ -7,6 +7,9 @@ config ZMK_KEYBOARD_NAME config ZMK_USB default y +config ZMK_BLE + default y + config ZMK_ACTION_MOD_TAP default y From 557996bcd02f91e2e4b2f35b5a70685eed902b89 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 12 Jun 2020 22:03:11 -0400 Subject: [PATCH 05/12] Fixes for SPI pins for "P1" pins Co-authored-by: Nick Winans --- app/boards/arm/nice_nano/nice_nano.dts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 638d3cbc..04574619 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -56,9 +56,9 @@ compatible = "nordic,nrf-spi"; /* Cannot be used together with i2c0. */ /* status = "okay"; */ - sck-pin = <13>; + sck-pin = <45>; mosi-pin = <10>; - miso-pin = <11>; + miso-pin = <43>; }; &flash0 { @@ -95,4 +95,3 @@ }; }; }; - From 85e505e06e5236aebcb6ec385a97446323b70280 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 15 Jun 2020 23:00:35 -0400 Subject: [PATCH 06/12] Build UF2 image for nice!nano board as well. --- app/boards/arm/nice_nano/CMakeLists.txt | 7 +++++++ app/boards/arm/nice_nano/nice_nano.dts | 2 +- app/west.yml | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 app/boards/arm/nice_nano/CMakeLists.txt diff --git a/app/boards/arm/nice_nano/CMakeLists.txt b/app/boards/arm/nice_nano/CMakeLists.txt new file mode 100644 index 00000000..91d2dde0 --- /dev/null +++ b/app/boards/arm/nice_nano/CMakeLists.txt @@ -0,0 +1,7 @@ +set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py + -b 0x26000 + -f NRF52 + -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2 + ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} +) diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 04574619..21b60d38 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -77,7 +77,7 @@ }; code_partition: partition@26000 { label = "code_partition"; - reg = <0x00026000 0x0001e000>; + reg = <0x00026000 0x0002e000>; }; /* diff --git a/app/west.yml b/app/west.yml index c2151eb3..3784d97b 100644 --- a/app/west.yml +++ b/app/west.yml @@ -4,6 +4,8 @@ manifest: url-base: https://github.com/zephyrproject-rtos - name: petejohanson url-base: https://github.com/petejohanson + - name: microsoft + url-base: https://github.com/microsoft projects: - name: zephyr remote: petejohanson @@ -19,5 +21,8 @@ manifest: - hal_microchip - hal_nxp - hal_openisa + - name: uf2 + remote: microsoft + path: tools/uf2 self: path: zmk From a4885db2bf6c5f72c3235721668603860610e5e0 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 11:40:51 -0400 Subject: [PATCH 07/12] Use the correct family ID for the AdaFruit bootloader. --- app/boards/arm/nice_nano/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/boards/arm/nice_nano/CMakeLists.txt b/app/boards/arm/nice_nano/CMakeLists.txt index 91d2dde0..00952c30 100644 --- a/app/boards/arm/nice_nano/CMakeLists.txt +++ b/app/boards/arm/nice_nano/CMakeLists.txt @@ -1,7 +1,8 @@ set_property(GLOBAL APPEND PROPERTY extra_post_build_commands COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py + -c -b 0x26000 - -f NRF52 + -f 0xADA52840 -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2 - ${PROJECT_BINARY_DIR}/${KERNEL_BIN_NAME} + ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin ) From 8ee9a374988fdf5c0d6c28ff67a5c1cfaca49f66 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 22:35:29 -0400 Subject: [PATCH 08/12] Tweak the defconfigs for nice_nano and handwire. --- app/boards/arm/nice_nano/Kconfig.defconfig | 11 +++++------ .../petejohanson_proton_handwire/Kconfig.defconfig | 3 --- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/boards/arm/nice_nano/Kconfig.defconfig b/app/boards/arm/nice_nano/Kconfig.defconfig index cb4b52af..2c122ae0 100644 --- a/app/boards/arm/nice_nano/Kconfig.defconfig +++ b/app/boards/arm/nice_nano/Kconfig.defconfig @@ -1,7 +1,7 @@ # Electronut Labs Papyr board configuration -# Copyright (c) 2018 Electronut Labs -# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT if BOARD_NICE_NANO @@ -18,11 +18,10 @@ config USB_DEVICE_STACK endif # USB -config IEEE802154_NRF5 - default y - depends on IEEE802154 - config BT_CTLR default BT +config ZMK_BLE + default y + endif # BOARD_NICE_NANO diff --git a/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig b/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig index 1149c337..196c636e 100644 --- a/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig +++ b/app/boards/shields/petejohanson_proton_handwire/Kconfig.defconfig @@ -7,9 +7,6 @@ config ZMK_KEYBOARD_NAME config ZMK_USB default y -config ZMK_BLE - default y - config ZMK_ACTION_MOD_TAP default y From 05591ff37bad4701cdebe68e61b74ad4f4b45f26 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 22:40:47 -0400 Subject: [PATCH 09/12] Build matrix with nice_nano and proton_c boards. --- .github/workflows/build.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 11b9f390..a7036430 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,9 @@ jobs: build: runs-on: ubuntu-latest name: Build Test + strategy: + matrix: + board: [proton_c, nice_nano] steps: # To use this repository's private action, # you must check out the repository @@ -27,27 +30,27 @@ jobs: ${{ runner.os }}-build- ${{ runner.os }}- - name: West Init - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-init with: args: 'init "-l app"' - name: West Update - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-update with: - args: 'update' + args: "update" - name: West Config Zephyr Base - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-config with: args: 'config "--global zephyr.base-prefer configfile"' - name: West Zephyr Export - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-zephyr-export with: - args: 'zephyr-export' + args: "zephyr-export" - name: West Build - uses: 'docker://zmkfirmware/zephyr-west-action-arm:latest' + uses: "docker://zmkfirmware/zephyr-west-action-arm:latest" id: west-build with: - args: 'build "-s app -b proton_c -- -DSHIELD=petejohanson_proton_handwire"' + args: 'build "-s app -b ${{ matrix.board }} -- -DSHIELD=petejohanson_proton_handwire"' From 33795b99ca9ba2370a26a13784bd453fb5d9a558 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 22:57:20 -0400 Subject: [PATCH 10/12] Change the kernel bin name, upload built UF2. --- .github/workflows/build.yml | 6 ++++++ app/prj.conf | 1 + 2 files changed, 7 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a7036430..7f2b0ccb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -54,3 +54,9 @@ jobs: id: west-build with: args: 'build "-s app -b ${{ matrix.board }} -- -DSHIELD=petejohanson_proton_handwire"' + - name: Archive Build + uses: actions/upload-artifact@v2 + if: ${{ matrix.board == "nice_nano "}} + with: + name: zmk-uf2 + path: build/zephyr/zmk.uf2 diff --git a/app/prj.conf b/app/prj.conf index c4d6d352..f5b2d4a9 100644 --- a/app/prj.conf +++ b/app/prj.conf @@ -1,2 +1,3 @@ # CONFIG_LOG=y # CONFIG_ZMK_LOG_LEVEL_DBG=y +CONFIG_KERNEL_BIN_NAME="zmk" From d1daf0de067773b125e63a72fd0f356df190c42b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 22:59:20 -0400 Subject: [PATCH 11/12] Fix the string literal. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7f2b0ccb..f55d6b10 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,7 +56,7 @@ jobs: args: 'build "-s app -b ${{ matrix.board }} -- -DSHIELD=petejohanson_proton_handwire"' - name: Archive Build uses: actions/upload-artifact@v2 - if: ${{ matrix.board == "nice_nano "}} + if: ${{ matrix.board == 'nice_nano' }} with: name: zmk-uf2 path: build/zephyr/zmk.uf2 From a087a466e95565d7d8326f8435ea29baf6219e46 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 16 Jun 2020 23:03:15 -0400 Subject: [PATCH 12/12] Tweak the artifact name to include board. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f55d6b10..7b2aa0cd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -58,5 +58,5 @@ jobs: uses: actions/upload-artifact@v2 if: ${{ matrix.board == 'nice_nano' }} with: - name: zmk-uf2 + name: "${{ matrix.board }}-zmk-uf2" path: build/zephyr/zmk.uf2