From a754296a8a844f7e90446ff2baef8486d9906129 Mon Sep 17 00:00:00 2001 From: mfranck <57538883+y4m-y4m@users.noreply.github.com> Date: Sun, 13 Jun 2021 12:52:33 +0200 Subject: [PATCH 1/7] add makerdiary m60 keyboard (uses nrf52840_m2) --- src/boards/m60_keyboard/board.h | 71 +++++++++++++++++++++++++++++ src/boards/m60_keyboard/board.mk | 2 + src/boards/m60_keyboard/pinconfig.c | 19 ++++++++ 3 files changed, 92 insertions(+) create mode 100644 src/boards/m60_keyboard/board.h create mode 100644 src/boards/m60_keyboard/board.mk create mode 100644 src/boards/m60_keyboard/pinconfig.c diff --git a/src/boards/m60_keyboard/board.h b/src/boards/m60_keyboard/board.h new file mode 100644 index 0000000..e17f8b5 --- /dev/null +++ b/src/boards/m60_keyboard/board.h @@ -0,0 +1,71 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2020 Yihui Xiong for Makerdiary + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _MAKERDIARY_M60_KEYBOARD_H_ +#define _MAKERDIARY_M60_KEYBOARD_H_ + +#define _PINNUM(port, pin) ((port)*32 + (pin)) + +/*------------------------------------------------------------------*/ +/* LED + *------------------------------------------------------------------*/ +#define LEDS_NUMBER 1 +#define LED_PRIMARY_PIN _PINNUM(0, 30) // Red +#define LED_STATE_ON 0 + +#define LED_RGB_RED_PIN _PINNUM(0, 30) +#define LED_RGB_GREEN_PIN _PINNUM(0, 29) +#define LED_RGB_BLUE_PIN _PINNUM(0, 31) +#define BOARD_RGB_BRIGHTNESS 0x404040 +/*------------------------------------------------------------------*/ +/* BUTTON + *------------------------------------------------------------------*/ +#define BUTTONS_NUMBER 2 +#define BUTTON_1 _PINNUM(0, 27) +#define BUTTON_2 _PINNUM(1, 7) +#define BUTTON_PULL NRF_GPIO_PIN_PULLUP + +//--------------------------------------------------------------------+ +// BLE OTA +//--------------------------------------------------------------------+ +#define BLEDIS_MANUFACTURER "Makerdiary" +#define BLEDIS_MODEL "M60 Mechanical Keyboard" + +//--------------------------------------------------------------------+ +// USB +//--------------------------------------------------------------------+ +#define USB_DESC_VID 0x2886 +#define USB_DESC_UF2_PID 0xF00F +#define USB_DESC_CDC_ONLY_PID 0xF00F + +//--------------------------------------------------------------------+ +// UF2 +//--------------------------------------------------------------------+ +#define UF2_PRODUCT_NAME "MakerDiary M60 Mechanical Keyboard" +#define UF2_VOLUME_LABEL "M60KEYBOARD" +#define UF2_BOARD_ID "M60KEYBOARD" +#define UF2_INDEX_URL "https://wiki.makerdiary.com/m60/" + + +#endif /* _MAKERDIARY_M60_KEYBOARD_H_ */ diff --git a/src/boards/m60_keyboard/board.mk b/src/boards/m60_keyboard/board.mk new file mode 100644 index 0000000..bea74cc --- /dev/null +++ b/src/boards/m60_keyboard/board.mk @@ -0,0 +1,2 @@ +MCU_SUB_VARIANT = nrf52840 +USE_NFCT = yes diff --git a/src/boards/m60_keyboard/pinconfig.c b/src/boards/m60_keyboard/pinconfig.c new file mode 100644 index 0000000..a983e4a --- /dev/null +++ b/src/boards/m60_keyboard/pinconfig.c @@ -0,0 +1,19 @@ +#include "boards.h" +#include "uf2/configkeys.h" + +__attribute__((used, section(".bootloaderConfig"))) +const uint32_t bootloaderConfig[] = +{ + /* CF2 START */ + CFG_MAGIC0, CFG_MAGIC1, // magic + 5, 100, // used entries, total entries + + 204, 0x100000, // FLASH_BYTES = 0x100000 + 205, 0x40000, // RAM_BYTES = 0x40000 + 208, (USB_DESC_VID << 16) | USB_DESC_UF2_PID, // BOOTLOADER_BOARD_ID = USB VID+PID, used for verification when updating bootloader via uf2 + 209, 0xada52840, // UF2_FAMILY = 0xada52840 + 210, 0x20, // PINS_PORT_SIZE = PA_32 + + 0, 0, 0, 0, 0, 0, 0, 0 + /* CF2 END */ +}; From 627ce5d9a99c1481480143feb31cb7589c2ff87d Mon Sep 17 00:00:00 2001 From: mfranck <57538883+y4m-y4m@users.noreply.github.com> Date: Mon, 14 Jun 2021 11:40:53 +0200 Subject: [PATCH 2/7] add makerdiary m60 keyboard to ci --- .github/workflows/githubci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/githubci.yml b/.github/workflows/githubci.yml index 8e1df3a..695f9de 100644 --- a/.github/workflows/githubci.yml +++ b/.github/workflows/githubci.yml @@ -36,6 +36,7 @@ jobs: - 'ebyte_e73_tbb' - 'electronut_labs_papyr' - 'ikigaisense_vita' + - 'm60_keyboard' - 'mdk_nrf52840_dongle' - 'nice_nano' - 'nrf52840_m2' From 13118196d89ecd86e9f7cb34ef1594101867c4df Mon Sep 17 00:00:00 2001 From: hathach Date: Sat, 19 Jun 2021 14:26:35 +0700 Subject: [PATCH 3/7] update tinyusb to fix control race condition --- lib/tinyusb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tinyusb b/lib/tinyusb index 7cdeed5..df0cda2 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 7cdeed54e0dbd6f927020042dbdedf2d4d21cf97 +Subproject commit df0cda2d7ab7a061bcb28213273bcc3a8d8dbaec From 42d9d9fe9d1f4d9a00a05f87b95ee310dbb2f673 Mon Sep 17 00:00:00 2001 From: Ha Thach Date: Sat, 19 Jun 2021 14:37:25 +0700 Subject: [PATCH 4/7] Update changelog.md --- changelog.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog.md b/changelog.md index 2e7d4fe..b6d2844 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Adafruit nRF52 Bootloader Changelog +## 0.6.0 - 2021.06.19 + +- Update tinyusb to latest to fix the race condition with control transfer, which could cause failed to connect to DFU Serial occasionally. + ## 0.5.1 - 2021.06.02 - more boards support From b1e0d2fd723a5e0a27ac64fb03bc72e549ad1dbe Mon Sep 17 00:00:00 2001 From: dumam Date: Sat, 26 Jun 2021 16:53:59 +0200 Subject: [PATCH 5/7] GCC 11 Fixes --- lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c | 2 +- src/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c b/lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c index fd36ad9..ea716cb 100644 --- a/lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c +++ b/lib/sdk11/components/ble/ble_services/ble_dfu/ble_dfu.c @@ -463,7 +463,7 @@ uint32_t ble_dfu_init(ble_dfu_t * p_dfu, ble_dfu_init_t * p_dfu_init) p_dfu->conn_handle = BLE_CONN_HANDLE_INVALID; - ble_uuid_t service_uuid; + ble_uuid_t service_uuid = {0}; uint32_t err_code; const ble_uuid128_t base_uuid128 = diff --git a/src/main.c b/src/main.c index eed9ba6..36616ca 100644 --- a/src/main.c +++ b/src/main.c @@ -411,7 +411,7 @@ void assert_nrf_callback (uint16_t line_num, uint8_t const * p_file_name) // Process BLE event from SD uint32_t proc_ble(void) { - __ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ]; + __ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ] = {0}; uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX); // Get BLE Event @@ -448,7 +448,7 @@ uint32_t proc_ble(void) // process SOC event from SD uint32_t proc_soc(void) { - uint32_t soc_evt; + uint32_t soc_evt = 0; uint32_t err = sd_evt_get(&soc_evt); if (NRF_SUCCESS == err) From 6e33825e9f593fd34c3118b57cc6b13b370307fc Mon Sep 17 00:00:00 2001 From: dumam Date: Sun, 27 Jun 2021 14:29:12 +0200 Subject: [PATCH 6/7] Init header without init whole buffer --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.c b/src/main.c index 36616ca..052e3e7 100644 --- a/src/main.c +++ b/src/main.c @@ -411,17 +411,19 @@ void assert_nrf_callback (uint16_t line_num, uint8_t const * p_file_name) // Process BLE event from SD uint32_t proc_ble(void) { - __ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ] = {0}; + __ALIGN(4) uint8_t ev_buf[ BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX) ]; uint16_t ev_len = BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX); + // Init header + ble_evt_t* evt = (ble_evt_t*) ev_buf; + evt->header.evt_id = 0; + // Get BLE Event uint32_t err = sd_ble_evt_get(ev_buf, &ev_len); // Handle valid event, ignore error if( NRF_SUCCESS == err) { - ble_evt_t* evt = (ble_evt_t*) ev_buf; - switch (evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: From a7fe7c98a3b52a22631d6a16d601ad87072bbd6f Mon Sep 17 00:00:00 2001 From: dumam Date: Sun, 4 Jul 2021 21:12:15 +0200 Subject: [PATCH 7/7] Init header id with invalid value --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index 052e3e7..331ea21 100644 --- a/src/main.c +++ b/src/main.c @@ -416,7 +416,7 @@ uint32_t proc_ble(void) // Init header ble_evt_t* evt = (ble_evt_t*) ev_buf; - evt->header.evt_id = 0; + evt->header.evt_id = BLE_EVT_INVALID; // Get BLE Event uint32_t err = sd_ble_evt_get(ev_buf, &ev_len);