Skip to content

Commit 16669ee

Browse files
committed
samples: debug: add CMSIS DAP sample using USB as interface
Add CMSIS DAP sample using USB as interface. Signed-off-by: Maximilian Deubel <[email protected]> Signed-off-by: Johann Fischer <[email protected]>
1 parent c851317 commit 16669ee

File tree

8 files changed

+504
-0
lines changed

8 files changed

+504
-0
lines changed

samples/subsys/dap/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2023 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(dap)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})

samples/subsys/dap/README.rst

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.. _dap-sample:
2+
3+
DAP Sample Application
4+
######################
5+
6+
Overview
7+
********
8+
9+
This sample app demonstrates use of a SWDP interface driver and CMSIS DAP
10+
controller through USB Bulk interface.
11+
12+
Requirements
13+
************
14+
15+
This sample supports multiple hardware configurations:
16+
17+
The simplest configuration would be to connect `SWDIO` to `dio`, `SWDCLK` to `clk`
18+
and optionally `nRESET` to `reset`. The optional `noe` pin is used to enable the port,
19+
e.g. if the SWD connections are multiplexed.
20+
21+
Building and Running
22+
********************
23+
24+
In order for our debug adapter to be recognized by pyOCD we need to change
25+
Zephyr's VID/PID to IDs known to pyOCD, this is up to the user.
26+
The following commands build and flash DAP sample.
27+
28+
.. zephyr-app-commands::
29+
:zephyr-app: samples/subsys/dap
30+
:board: nrf52840dk_nrf52840
31+
:goals: flash
32+
:compact:
33+
34+
Connect HIC to the target and try some pyOCD commands, for example:
35+
36+
.. code-block:: console
37+
38+
pyocd commander -t nrf52840
39+
40+
0029527 W Board ID FE5D is not recognized [mbed_board]
41+
Connected to NRF52840 [Sleeping]: FE5D244DFE1F33DB
42+
pyocd> read32 0x20004f18 32
43+
20004f18: 20001160 2000244c 00000000 0000e407 | ..` .$L........|
44+
20004f28: ffffffff ffffffff 00000000 aaaaaaaa |................|
45+
pyocd> halt
46+
Successfully halted device
47+
pyocd> reg
48+
general registers:
49+
lr: 0x00009cdd r7: 0x00000000 (0)
50+
pc: 0x000033ca r8: 0x00000000 (0)
51+
r0: 0x00000000 (0) r9: 0x00000000 (0)
52+
r1: 0x20002854 (536881236) r10: 0x00000000 (0)
53+
r2: 0x20000be4 (536873956) r11: 0x00000000 (0)
54+
r3: 0x00000000 (0) r12: 0x00000000 (0)
55+
r4: 0x200017e8 (536877032) sp: 0x20002898
56+
r5: 0x20001867 (536877159) xpsr: 0x61000000 (1627389952)
57+
r6: 0x00000000 (0)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
dp0 {
9+
compatible = "zephyr,swdp-gpio";
10+
status = "okay";
11+
clk-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */
12+
dio-gpios = <&arduino_header 8 GPIO_PULL_UP>; /* D2 */
13+
dout-gpios = <&arduino_header 9 GPIO_ACTIVE_HIGH>; /* D3 */
14+
dnoe-gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>; /* D6 */
15+
noe-gpios = <&arduino_header 11 GPIO_ACTIVE_HIGH>; /* D5 */
16+
reset-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
17+
port-write-cycles = <2>;
18+
};
19+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
2+
CONFIG_USB_MAX_POWER=250
3+
CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor"
4+
CONFIG_CMSIS_DAP_DEVICE_NAME="nrf9160_xxaa"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
dp0 {
9+
compatible = "zephyr,swdp-gpio";
10+
status = "okay";
11+
clk-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
12+
dio-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
13+
noe-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
14+
port-write-cycles = <2>;
15+
};
16+
};

samples/subsys/dap/prj.conf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CONFIG_STDOUT_CONSOLE=y
2+
CONFIG_USB_DEVICE_STACK=y
3+
CONFIG_USB_DEVICE_BOS=y
4+
CONFIG_SERIAL=y
5+
CONFIG_USB_DEVICE_PRODUCT="Zephyr CMSIS-DAP"
6+
CONFIG_USB_DEVICE_PID=0x0204
7+
CONFIG_UART_INTERRUPT_DRIVEN=y
8+
CONFIG_UART_LINE_CTRL=y
9+
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
10+
11+
CONFIG_LOG=y
12+
13+
CONFIG_USB_DRIVER_LOG_LEVEL_INF=y
14+
CONFIG_USB_DEVICE_LOG_LEVEL_INF=y
15+
CONFIG_DAP_LOG_LEVEL_INF=y
16+
CONFIG_DP_DRIVER_LOG_LEVEL_INF=y
17+
CONFIG_DAP=y
18+
CONFIG_GPIO=y
19+
CONFIG_NET_BUF=y

samples/subsys/dap/sample.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
sample:
2+
name: DAP USB
3+
tests:
4+
sample.dap.hid:
5+
build_only: true
6+
platform_allow: nrf52840dk_nrf52840
7+
integration_platforms:
8+
- nrf52840dk_nrf52840
9+
depends_on: usb_device
10+
tags: usb

0 commit comments

Comments
 (0)