From 0e377ad3822eed59b332429b40dcb47d4ec7636f Mon Sep 17 00:00:00 2001 From: Maximilian Deubel Date: Thu, 24 Oct 2024 00:35:18 +0200 Subject: [PATCH] applications: connectivity_bridge: thingy91 debug Add the CMSIS-DAP feature of the thingy91x to the thingy91. Signed-off-by: Maximilian Deubel --- .../connectivity_bridge/boards/thingy91_nrf52840.conf | 11 +++++++++++ .../boards/thingy91_nrf52840_readme.txt | 1 + .../boards/thingy91x_nrf5340_cpuapp.conf | 2 ++ .../connectivity_bridge/src/modules/CMakeLists.txt | 7 ++++--- applications/connectivity_bridge/src/modules/Kconfig | 7 +++++++ .../src/modules/usb_bulk_interface.c | 6 +++++- 6 files changed, 30 insertions(+), 4 deletions(-) diff --git a/applications/connectivity_bridge/boards/thingy91_nrf52840.conf b/applications/connectivity_bridge/boards/thingy91_nrf52840.conf index 14db61ae52ea..4efb654d4314 100644 --- a/applications/connectivity_bridge/boards/thingy91_nrf52840.conf +++ b/applications/connectivity_bridge/boards/thingy91_nrf52840.conf @@ -28,3 +28,14 @@ CONFIG_USB_DEVICE_PRODUCT="Thingy:91 UART" CONFIG_USB_DEVICE_VID=0x1915 CONFIG_USB_DEVICE_PID=0x9100 + +CONFIG_USB_MAX_NUM_TRANSFERS=8 +CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y + +CONFIG_DAP=y +CONFIG_DP_DRIVER=y + +CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA" +CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91" + +CONFIG_USB_CDC_ACM_RINGBUF_SIZE=15360 diff --git a/applications/connectivity_bridge/boards/thingy91_nrf52840_readme.txt b/applications/connectivity_bridge/boards/thingy91_nrf52840_readme.txt index d2c11ca05be0..3fc3347fada8 100644 --- a/applications/connectivity_bridge/boards/thingy91_nrf52840_readme.txt +++ b/applications/connectivity_bridge/boards/thingy91_nrf52840_readme.txt @@ -8,6 +8,7 @@ https://nordicsemi.com/thingy91 This USB interface has the following functions: * Disk drive containing this file and others * COM ports for nRF91 debug, trace, and firmware update +* CMSIS-DAP 2.1 compliant debug probe interface for accessing the nRF91 SiP COM Ports ==================== diff --git a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf index 78bd70dd95ca..d0a53d3492c1 100644 --- a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf +++ b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf @@ -43,3 +43,5 @@ CONFIG_DP_DRIVER=y CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA" CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91" + +CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS=y diff --git a/applications/connectivity_bridge/src/modules/CMakeLists.txt b/applications/connectivity_bridge/src/modules/CMakeLists.txt index 6a9e15dff7a0..8cd5d777a074 100644 --- a/applications/connectivity_bridge/src/modules/CMakeLists.txt +++ b/applications/connectivity_bridge/src/modules/CMakeLists.txt @@ -20,6 +20,7 @@ target_sources_ifdef(CONFIG_BRIDGE_MSC_ENABLE app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/fs_handler.c) target_sources_ifdef(CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE - app PRIVATE - ${CMAKE_CURRENT_SOURCE_DIR}/usb_bulk_commands.c - ${CMAKE_CURRENT_SOURCE_DIR}/usb_bulk_interface.c) + app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/usb_bulk_interface.c) + +target_sources_ifdef(CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS + app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/usb_bulk_commands.c) diff --git a/applications/connectivity_bridge/src/modules/Kconfig b/applications/connectivity_bridge/src/modules/Kconfig index 171c29a3eb1f..bb0c7eccb529 100644 --- a/applications/connectivity_bridge/src/modules/Kconfig +++ b/applications/connectivity_bridge/src/modules/Kconfig @@ -29,6 +29,13 @@ config BRIDGE_CMSIS_DAP_BULK_ENABLE depends on USB_DEVICE_STACK select USB_DEVICE_BOS +config BRIDGE_CMSIS_DAP_NORDIC_COMMANDS + bool "Enable Nordic specific commands" + depends on BRIDGE_CMSIS_DAP_BULK_ENABLE + help + This option enables Nordic specific commands for CMSIS-DAP Bulk. + Currently, these are only relevant for the Thingy:91 X board. + if BRIDGE_CMSIS_DAP_BULK_ENABLE module = BRIDGE_BULK diff --git a/applications/connectivity_bridge/src/modules/usb_bulk_interface.c b/applications/connectivity_bridge/src/modules/usb_bulk_interface.c index ac86c946c3b8..64a395f91368 100644 --- a/applications/connectivity_bridge/src/modules/usb_bulk_interface.c +++ b/applications/connectivity_bridge/src/modules/usb_bulk_interface.c @@ -12,6 +12,7 @@ #include #include #include +#include #define MODULE bulk_interface #include "module_state_event.h" @@ -173,8 +174,11 @@ static int dap_usb_process(void) static uint8_t tx_buf[USB_BULK_PACKET_SIZE]; struct net_buf *buf = k_fifo_get(&dap_rx_queue, K_FOREVER); uint8_t ep = dapusb_config.endpoint[DAP_USB_EP_IN_IDX].ep_addr; - +#if defined(CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS) len = dap_execute_vendor_cmd(buf->data, tx_buf); +#else + len = dap_execute_cmd(buf->data, tx_buf); +#endif /* defined(CONFIG_BRIDGE_CMSIS_DAP_NORDIC_COMMANDS) */ LOG_DBG("response length %u, starting with [0x%02X, 0x%02X]", len, tx_buf[0], tx_buf[1]); net_buf_unref(buf);