Skip to content
Closed
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 = <NRF_PSEL(UART_TX, 0, 29)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 1, 4)>;
bias-pull-up;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 0, 29)>,
<NRF_PSEL(UART_RX, 1, 4)>;
low-power-enable;
};
};

uart1_default: uart1_default {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 8)>;
};
group2 {
psels = <NRF_PSEL(UART_RX, 1, 6)>;
bias-pull-up;
};
};

uart1_sleep: uart1_sleep {
group1 {
psels = <NRF_PSEL(UART_TX, 1, 8)>,
<NRF_PSEL(UART_RX, 1, 6)>;
low-power-enable;
};
};
};

&uicr {
nfct-pins-as-gpios;
};

&gpio_fwd {
status = "disabled";
};
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
====================
Expand Down
12 changes: 12 additions & 0 deletions applications/connectivity_bridge/src/disk/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <zephyr/drivers/gpio.h>
#include <dk_buttons_and_leds.h>

#include <cmsis_dap.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(bulk_commands, CONFIG_BRIDGE_BULK_LOG_LEVEL);

Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
/* needs to be included after defining logging config */
#include "usb_bulk_msosv2.h"

#include <cmsis_dap.h>

#define USB_BULK_PACKET_SIZE 64
#define USB_BULK_PACKET_COUNT 4

Expand All @@ -41,7 +43,7 @@
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"
Expand Down Expand Up @@ -172,7 +174,7 @@
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);

Expand All @@ -196,6 +198,8 @@
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);

Expand All @@ -210,6 +214,15 @@
/* 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) {

Check warning on line 222 in applications/connectivity_bridge/src/modules/usb_bulk_interface.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

LINE_SPACING

applications/connectivity_bridge/src/modules/usb_bulk_interface.c:222 Missing a blank line after declarations
LOG_ERR("Failed to initialize DAP controller, %d", ret);
}

/* tell the usb_cdc_handler we are done */
module_set_state(MODULE_STATE_STANDBY);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
&uicr {
nfct-pins-as-gpios;
};

&gpio_fwd {
status = "disabled";
};
3 changes: 3 additions & 0 deletions boards/nordic/thingy91x/board.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading