diff --git a/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.conf b/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 000000000000..b00690fd67e8 --- /dev/null +++ b/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,30 @@ +CONFIG_RETENTION_BOOT_MODE=y + +CONFIG_USB_MAX_POWER=250 +CONFIG_USB_DEVICE_PRODUCT="Connectivity Bridge" + +CONFIG_USB_DEVICE_VID=0x1915 +CONFIG_USB_DEVICE_PID=0x910A + +CONFIG_USB_MAX_NUM_TRANSFERS=8 +CONFIG_BRIDGE_CMSIS_DAP_BULK_ENABLE=y +CONFIG_RETENTION_BOOT_MODE=y +CONFIG_REBOOT=y +CONFIG_GPIO=y + +CONFIG_DK_LIBRARY=y +CONFIG_DAP=y +CONFIG_DP_DRIVER=y + +CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA" + +CONFIG_NET_BUF=y + +CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y + +CONFIG_BOARD_ENABLE_DCDC_APP=n +CONFIG_BOARD_ENABLE_DCDC_NET=n +CONFIG_BOARD_ENABLE_DCDC_HV=n + +CONFIG_NFCT_PINS_AS_GPIOS=y +CONFIG_SOC_ENABLE_LFXO=n diff --git a/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.overlay b/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 000000000000..e6d158ff79a2 --- /dev/null +++ b/applications/connectivity_bridge/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,147 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + + +/ { + dp0 { + compatible = "zephyr,swdp-gpio"; + status = "okay"; + /* SWD0 + clk-gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; + dio-gpios = <&gpio1 14 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + */ + /* SWD1 + clk-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>; + dio-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; + */ + /* SWD2 + clk-gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>; + dio-gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>; + */ + /* SWD3 */ + clk-gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>; + dio-gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; + reset-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; + port-write-cycles = <12>; + }; + + zephyr,user { + reset-gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; + }; + + chosen { + zephyr,console = &rtt0; + zephyr,shell-uart = &rtt0; + zephyr,uart-mcumgr = &rtt0; + zephyr,bt-mon-uart = &rtt0; + zephyr,bt-c2h-uart = &rtt0; + }; + + ramdisk0 { + compatible = "zephyr,ram-disk"; + disk-name = "RAM"; + sector-size = <512>; + sector-count = <128>; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>; + label = "Red LED"; + }; + led1: led_1 { + gpios = <&gpio0 26 GPIO_ACTIVE_HIGH>; + label = "Green LED"; + }; + led2: led_2 { + gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; + label = "Blue LED"; + }; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + gpios = <&gpio0 24 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Button 2"; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&uart1 { + status = "okay"; +}; + + +&zephyr_udc0 { + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; + + cdc_acm_uart1: cdc_acm_uart1 { + compatible = "zephyr,cdc-acm-uart"; + }; + + rtt0: rtt_chan0 { + compatible = "segger,rtt-uart"; + status = "okay"; + }; +}; + + +&pinctrl { + uart0_default: uart0_default { + group1 { + psels = ; + }; + group2 { + psels = ; + bias-pull-up; + }; + }; + + uart0_sleep: uart0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + uart1_default: uart1_default { + group1 { + psels = ; + }; + group2 { + psels = ; + bias-pull-up; + }; + }; + + uart1_sleep: uart1_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; + +&uicr { + nfct-pins-as-gpios; +}; + +&gpio_fwd { + status = "disabled"; +}; diff --git a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf index c59f3dc49430..4b0f6234f2c8 100644 --- a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf +++ b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.conf @@ -34,3 +34,8 @@ CONFIG_REBOOT=y CONFIG_GPIO=y CONFIG_DK_LIBRARY=y +CONFIG_DAP=y +CONFIG_DP_DRIVER=y + +CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor ASA" +CONFIG_CMSIS_DAP_DEVICE_NAME="nrf91" diff --git a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.overlay b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.overlay index 79263b90b033..5efee746b0d4 100644 --- a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.overlay +++ b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp.overlay @@ -12,7 +12,7 @@ clk-gpios = <&gpio0 25 GPIO_ACTIVE_HIGH>; dio-gpios = <&gpio0 27 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpio1 7 GPIO_ACTIVE_HIGH>; - port-write-cycles = <2>; + port-write-cycles = <12>; }; zephyr,user { diff --git a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp_readme.txt b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp_readme.txt index a3fa4e224f03..e4458f6c9185 100644 --- a/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp_readme.txt +++ b/applications/connectivity_bridge/boards/thingy91x_nrf5340_cpuapp_readme.txt @@ -5,6 +5,7 @@ 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/src/disk/config.c b/applications/connectivity_bridge/src/disk/config.c index dffb1fbb2f53..b5f31fb9d0e0 100644 --- a/applications/connectivity_bridge/src/disk/config.c +++ b/applications/connectivity_bridge/src/disk/config.c @@ -43,10 +43,22 @@ LOG_MODULE_REGISTER(MODULE, CONFIG_BRIDGE_MSC_LOG_LEVEL); * * Format: (_key, _presentation_name, _size, _default, _callback, _enabled) */ + +#if defined(CONFIG_BT_DEVICE_NAME) + #define CONFIG_LIST \ X(ble_enable, BLE_ENABLED, 1, "0", ble_enable_opt_cb, (IS_ENABLED(CONFIG_BRIDGE_BLE_ENABLE) && !IS_ENABLED(CONFIG_BRIDGE_BLE_ALWAYS_ON))) \ X(ble_name, BLE_NAME, CONFIG_BT_DEVICE_NAME_MAX, CONFIG_BT_DEVICE_NAME, ble_name_opt_cb, IS_ENABLED(CONFIG_BT_DEVICE_NAME_DYNAMIC)) +#else + +#define CONFIG_LIST + +#define CONFIG_BT_DEVICE_NAME_MAX 8 + +#endif + + struct cfg_option { const char *display_name; const char *settings_key; diff --git a/applications/connectivity_bridge/src/modules/usb_bulk_commands.c b/applications/connectivity_bridge/src/modules/usb_bulk_commands.c index 55367dc403ba..63b84e1bbdb0 100644 --- a/applications/connectivity_bridge/src/modules/usb_bulk_commands.c +++ b/applications/connectivity_bridge/src/modules/usb_bulk_commands.c @@ -9,6 +9,8 @@ #include #include +#include + #include LOG_MODULE_REGISTER(bulk_commands, CONFIG_BRIDGE_BULK_LOG_LEVEL); @@ -93,12 +95,17 @@ static void nrf53_reset_work_handler(struct k_work *work) /* This is a placeholder implementation until proper CMSIS-DAP support is available. * Only custom vendor commands are supported. */ -size_t dap_execute_cmd(uint8_t *in, uint8_t *out) +size_t dap_execute_vendor_cmd(uint8_t *in, uint8_t *out) { LOG_DBG("got command 0x%02X", in[0]); - int ret; + + if (in[0] < ID_DAP_VENDOR0) { + return dap_execute_cmd(in, out); + } #if IS_ENABLED(CONFIG_RETENTION_BOOT_MODE) + int ret; + if (in[0] == ID_DAP_VENDOR_NRF53_BOOTLOADER) { ret = bootmode_set(BOOT_MODE_TYPE_BOOTLOADER); if (ret) { diff --git a/applications/connectivity_bridge/src/modules/usb_bulk_interface.c b/applications/connectivity_bridge/src/modules/usb_bulk_interface.c index cc2157e6b073..44c39436b910 100644 --- a/applications/connectivity_bridge/src/modules/usb_bulk_interface.c +++ b/applications/connectivity_bridge/src/modules/usb_bulk_interface.c @@ -23,6 +23,8 @@ LOG_MODULE_REGISTER(MODULE, CONFIG_BRIDGE_BULK_LOG_LEVEL); /* needs to be included after defining logging config */ #include "usb_bulk_msosv2.h" +#include + #define USB_BULK_PACKET_SIZE 64 #define USB_BULK_PACKET_COUNT 4 @@ -41,7 +43,7 @@ static K_FIFO_DEFINE(dap_rx_queue); NET_BUF_POOL_FIXED_DEFINE(dapusb_rx_pool, USB_BULK_PACKET_COUNT, USB_BULK_PACKET_SIZE, 0, NULL); /* Execute CMSIS-DAP command and write reply into output buffer */ -size_t dap_execute_cmd(uint8_t *in, uint8_t *out); +size_t dap_execute_vendor_cmd(uint8_t *in, uint8_t *out); /* string descriptor for the interface */ #define DAP_IFACE_STR_DESC "CMSIS-DAP v2" @@ -172,7 +174,7 @@ static int dap_usb_process(void) 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; - len = dap_execute_cmd(buf->data, tx_buf); + len = dap_execute_vendor_cmd(buf->data, tx_buf); LOG_DBG("response length %u, starting with [0x%02X, 0x%02X]", len, tx_buf[0], tx_buf[1]); net_buf_unref(buf); @@ -196,6 +198,8 @@ static int dap_usb_thread_fn(const struct device *dev) return 0; } +const struct device *const swd_dev = DEVICE_DT_GET_ONE(zephyr_swdp_gpio); + K_THREAD_DEFINE(dap_usb_thread, CONFIG_BULK_USB_THREAD_STACK_SIZE, dap_usb_thread_fn, NULL, NULL, NULL, 5, 0, 0); @@ -210,6 +214,15 @@ static bool app_event_handler(const struct app_event_header *aeh) /* Point interface index to string descriptor */ iface_string_desc_init(&dapusb_config); + if (!device_is_ready(swd_dev)) { + LOG_ERR("SWD device is not ready"); + } + + int ret = dap_setup(swd_dev); + if (ret) { + LOG_ERR("Failed to initialize DAP controller, %d", ret); + } + /* tell the usb_cdc_handler we are done */ module_set_state(MODULE_STATE_STANDBY); } diff --git a/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf b/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf new file mode 100644 index 000000000000..3d280ef50270 --- /dev/null +++ b/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.conf @@ -0,0 +1,22 @@ +# +# Copyright (c) 2021 Nordic Semiconductor ASA +# +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause +# + +# CC3xx is currently not used for nrf53 +CONFIG_HW_CC3XX=n +CONFIG_NRF_CC3XX_PLATFORM=n + +# Required for kernel operation +CONFIG_CLOCK_CONTROL=y +CONFIG_SYS_CLOCK_EXISTS=y + +CONFIG_CLOCK_CONTROL_NRF_K32SRC_SYNTH=y + +CONFIG_BOARD_ENABLE_DCDC_APP=n +CONFIG_BOARD_ENABLE_DCDC_NET=n +CONFIG_BOARD_ENABLE_DCDC_HV=n + +CONFIG_NFCT_PINS_AS_GPIOS=y +CONFIG_SOC_ENABLE_LFXO=n diff --git a/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay b/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay new file mode 100644 index 000000000000..15ffb4c032ff --- /dev/null +++ b/applications/connectivity_bridge/sysbuild/mcuboot/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -0,0 +1,7 @@ +&uicr { + nfct-pins-as-gpios; +}; + +&gpio_fwd { + status = "disabled"; +}; diff --git a/boards/nordic/thingy91x/board.cmake b/boards/nordic/thingy91x/board.cmake index 518feb3571cb..2d1dff6c60cb 100644 --- a/boards/nordic/thingy91x/board.cmake +++ b/boards/nordic/thingy91x/board.cmake @@ -5,6 +5,9 @@ if(CONFIG_BOARD_THINGY91X_NRF9151 OR CONFIG_BOARD_THINGY91X_NRF9151_NS) board_runner_args(nrfjprog) board_runner_args(nrfutil "--nrf-family=NRF91") board_runner_args(jlink "--device=nRF9160_xxAA" "--speed=4000") + # for the nRF91, the onboard CMSIS-DAP probe can be used + board_runner_args(pyocd "--target=nrf91" "--frequency=4000000") + include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) elseif(BOARD_THINGY91X_NRF5340_CPUAPP OR BOARD_THINGY91X_NRF5340_CPUAPP_NS) board_runner_args(nrfjprog) board_runner_args(nrfutil "--nrf-family=NRF53") diff --git a/west.yml b/west.yml index 1ba26136665b..a280be63a1d4 100644 --- a/west.yml +++ b/west.yml @@ -72,7 +72,7 @@ manifest: # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/guides/modules.html - name: zephyr repo-path: sdk-zephyr - revision: 5bb7bb0af17cbdbd13c06ed5ea1268ec9b9358fc + revision: pull/1823/head import: # In addition to the zephyr repository itself, NCS also # imports the contents of zephyr/west.yml at the above