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

feat(boards): Update for mikoto board definition #1946

Open
wants to merge 12 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
6 changes: 3 additions & 3 deletions app/boards/arm/mikoto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on (BOARD_MIKOTO_520)
depends on (BOARD_MIKOTO)

choice BOARD_MIKOTO_CHARGER_CURRENT
prompt "Charge current to supply to attached batteries"
depends on (BOARD_MIKOTO_520)
depends on (BOARD_MIKOTO)

config BOARD_MIKOTO_CHARGER_CURRENT_40MA
bool "40mA charge current, for battery capacity 40mAh or higher"
Expand All @@ -26,4 +26,4 @@ config BOARD_MIKOTO_CHARGER_CURRENT_350MA
config BOARD_MIKOTO_CHARGER_CURRENT_NONE
bool "Disable charge current"

endchoice
endchoice
4 changes: 2 additions & 2 deletions app/boards/arm/mikoto/Kconfig.board
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT

config BOARD_MIKOTO_520
bool "mikoto_520"
config BOARD_MIKOTO
bool "mikoto"
depends on SOC_NRF52840_QIAA
4 changes: 2 additions & 2 deletions app/boards/arm/mikoto/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT

if BOARD_MIKOTO_520
if BOARD_MIKOTO

config BOARD
default "mikoto"
Expand All @@ -25,4 +25,4 @@ choice BOARD_MIKOTO_CHARGER_CURRENT
default BOARD_MIKOTO_CHARGER_CURRENT_100MA
endchoice

endif # BOARD_MIKOTO_520
endif # BOARD_MIKOTO
59 changes: 59 additions & 0 deletions app/boards/arm/mikoto/arduino_pro_micro_pins_v6.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (c) 2020 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/


/ {
pro_micro: connector {
compatible = "arduino-pro-micro";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map
= <0 0 &gpio0 4 0> /* D0 */
, <1 0 &gpio0 8 0> /* D1 */
, <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 8 0> /* D6/A7 */
, <7 0 &gpio1 2 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 13 0> /* D14 */
, <15 0 &gpio0 2 0> /* D15 */
, <18 0 &gpio0 29 0> /* D18/A0 */
, <19 0 &gpio0 31 0> /* D19/A1 */
, <20 0 &gpio0 25 0> /* D20/A2 */
, <21 0 &gpio0 11 0> /* D21/A3 */
;
};

pro_micro_a: connector_a {
compatible = "arduino-pro-micro";
#gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>;
gpio-map
= <0 0 &gpio0 29 0> /* D18/A0 */
, <1 0 &gpio0 31 0> /* D19/A1 */
, <2 0 &gpio0 25 0> /* D20/A2 */
, <3 0 &gpio0 11 0> /* D21/A3 */
, <6 0 &gpio0 22 0> /* D4/A6 */
, <7 0 &gpio1 8 0> /* D6/A7 */
, <8 0 &gpio1 4 0> /* D8/A8 */
, <9 0 &gpio1 6 0> /* D9/A9 */
, <10 0 &gpio0 9 0> /* D10/A10 */
;
};
};


pro_micro_d: &pro_micro {};
pro_micro_i2c: &i2c0 {};
pro_micro_spi: &spi0 {};
pro_micro_serial: &uart0 {};
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 4)>,
<NRF_PSEL(UART_TX, 0, 8)>;
<NRF_PSEL(UART_TX, 0, 8)>;
low-power-enable;
};
};

i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
<NRF_PSEL(TWIM_SCL, 0, 20)>;
};
};

i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
<NRF_PSEL(TWIM_SCL, 0, 20)>;
low-power-enable;
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

/dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi>
#include "arduino_pro_micro_pins.dtsi"
#include "mikoto_520-pinctrl.dtsi"

/ {
model = "mikoto";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
identifier: mikoto_520
name: mikoto_520
identifier: mikoto
name: mikoto
type: mcu
zhiayang marked this conversation as resolved.
Show resolved Hide resolved
arch: arm
toolchain:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
file_format: "1"
id: mikoto_520
name: Mikoto 5.20
id: mikoto
name: Mikoto
type: board
arch: arm
outputs:
- usb
- ble
url: https://github.com/zhiayang/mikoto
exposes: [pro_micro]
revisions:
- "5.20"
- "7.1"
- "7.3"
default_revision: "5.20"
8 changes: 8 additions & 0 deletions app/boards/arm/mikoto/mikoto_5_20_0.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

#include "mikoto-pinctrl.dtsi"
#include "arduino_pro_micro_pins_v5.dtsi"
8 changes: 8 additions & 0 deletions app/boards/arm/mikoto/mikoto_6_1_0.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

#include "mikoto-pinctrl.dtsi"
#include "arduino_pro_micro_pins_v6.dtsi"
2 changes: 2 additions & 0 deletions app/boards/arm/mikoto/mikoto_7_1_0.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_I2C=y
CONFIG_ZMK_MAX17048=y
45 changes: 45 additions & 0 deletions app/boards/arm/mikoto/mikoto_7_1_0.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

#include "mikoto-pinctrl.dtsi"
#include "arduino_pro_micro_pins_v6.dtsi"

&pinctrl {
i2c1_default: i2c1_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 23)>,
<NRF_PSEL(TWIM_SCL, 0, 19)>;
};
};

i2c1_sleep: i2c1_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 23)>,
<NRF_PSEL(TWIM_SCL, 0, 19)>;
low-power-enable;
};
};
};

&i2c1 {
status = "okay";
compatible = "nordic,nrf-twi";
pinctrl-0 = <&i2c1_default>;
pinctrl-1 = <&i2c1_sleep>;
pinctrl-names = "default", "sleep";

builtin_fuel_gauge: max17048@36 {
compatible = "zmk,maxim-max17048";
status = "okay";
reg = <0x36>;
};
};

/ {
chosen {
zmk,battery = &builtin_fuel_gauge;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_MIKOTO_520=y
CONFIG_BOARD_MIKOTO=y

# Enable MPU
CONFIG_ARM_MPU=y

CONFIG_PINCTRL=y

# enable GPIO
Expand Down
2 changes: 1 addition & 1 deletion app/boards/arm/mikoto/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

static int pinmux_mikoto_init(void) {

#if CONFIG_BOARD_MIKOTO_520
#if CONFIG_BOARD_MIKOTO
const struct device *p0 = DEVICE_DT_GET(DT_NODELABEL(gpio0));
const struct device *p1 = DEVICE_DT_GET(DT_NODELABEL(gpio1));
#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_40MA
Expand Down
7 changes: 7 additions & 0 deletions app/boards/arm/mikoto/revision.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
board_check_revision(FORMAT MAJOR.MINOR.PATCH
DEFAULT_REVISION 5.20.0
VALID_REVISIONS
5.20.0 # first public release
6.1.0 6.3.0 # incompatible pinout change from v5+
7.1.0 # addition of MAX17048; compatible pinout with v6+
)
20 changes: 20 additions & 0 deletions app/build.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this commit efa9134 included these three files (build.sh, uf2s) by accident.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, you're right. I'll clean this up after #2157 gets merged, thanks!

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

pristine=""
if [ $# -gt 0 ] && [ "$1" = "-p" -o "$1" = "--pristine" ]; then
pristine="--pristine"
fi

COMMON_ARGS=(
"-DZEPHYR_TOOLCHAIN_VARIANT=zephyr"
"-DZEPHYR_SDK_INSTALL_DIR=/opt/pacman/opt/zephyr-sdk"
"-DZMK_CONFIG=$(pwd)/../../zmk-config/config"
"-Wno-dev"
)

set -x

west build -d build/left -b mikoto_520 ${pristine} -- -DSHIELD=misaka_left "${COMMON_ARGS[@]}" && mv build/left/zephyr/zmk.uf2 ./left.uf2
west build -d build/right -b mikoto_520 ${pristine} -- -DSHIELD=misaka_right "${COMMON_ARGS[@]}" && mv build/right/zephyr/zmk.uf2 ./right.uf2


Binary file added app/left.uf2
Binary file not shown.
Binary file added app/right.uf2
Binary file not shown.
31 changes: 31 additions & 0 deletions docs/src/templates/setup.sh.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ if [ "$keyboard_shield" == "y" ]; then
board_ids=({{#boards}}"{{id}}" {{/boards}})
boards_usb_only=({{#boards}}"{{#usb_only}}y{{/usb_only}}{{^usb_only}}n{{/usb_only}}" {{/boards}})

boards_revisions=({{#boards}}"{{#revisions}}{{.}} {{/revisions}}" {{/boards}})
boards_default_revision=({{#boards}}"{{{default_revision}}}" {{/boards}})

echo ""
echo "MCU Board Selection:"
PS3="$prompt "
Expand Down Expand Up @@ -151,6 +154,34 @@ if [ "$keyboard_shield" == "y" ]; then

esac
done

if [ -n "${boards_revisions[$board_index]}" ]; then
read -a _valid_revisions <<< "${boards_revisions[$board_index]}"
for (( _i=0; _i<${#_valid_revisions}; _i++ )); do
if [ "${boards_default_revision[board_index]}" = "${_valid_revisions[_i]}" ]; then
_valid_revisions[_i]+=" (default)"
fi
done

echo ""
echo "MCU Board Revision:"
select opt in "${_valid_revisions[@]}" "Quit"; do
''|*[!0-9]*) echo "Invalid option. Try another one."; continue;;

$(( ${#_valid_revisions[@]}+1 )) ) echo "Goodbye!"; exit 1;;
*)
if [ $REPLY -gt $(( ${#_valid_revisions[@]}+1 )) ] || [ $REPLY -lt 0 ]; then
echo "Invalid option. Try another one."
continue
fi

_rev_index=$(( $REPLY-1 ))
board="${board_ids[$board_index]}@${_valid_revisions[_rev_index]}"
boards=( "${board}" )
break
;;
done
fi
else
board=${keyboard}
boards=$keyboard_siblings
Expand Down
15 changes: 14 additions & 1 deletion schema/hardware-metadata.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
"$defs": {
"id": {
"type": "string",
"pattern": "^[a-z0-9_]+$"
"pattern": "^[a-z0-9_]+(@([A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})))?$"
},
"revision": {
"type": "string",
"pattern": "[A-Z]|[0-9]+|([0-9]+(\\.[0-9]+){1,2})"
},
"keyboard_siblings": {
"type": "array",
Expand Down Expand Up @@ -202,6 +206,15 @@
},
"exposes": {
"$ref": "#/$defs/interconnects"
},
"revisions": {
"type": "array",
"items": {
"$ref": "#/$defs/revision"
}
},
"default_revision": {
"$ref": "#/$defs/revision"
}
}
},
Expand Down
Loading