Skip to content

Commit 1174308

Browse files
jfischer-nohenrikbrixandersen
authored andcommitted
tracing: port USB backend to the new USB device stack
Port USB backend to the new USB device stack. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent d52f76f commit 1174308

File tree

8 files changed

+244
-118
lines changed

8 files changed

+244
-118
lines changed

samples/subsys/tracing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif()
99
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
1010
project(tracing_tests)
1111

12+
include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)
1213
target_sources(app PRIVATE src/main.c)
1314
target_sources_ifdef(CONFIG_TRACING_GPIO app PRIVATE src/gpio_main.c)
1415
target_sources_ifdef(CONFIG_TRACING_USER app PRIVATE src/tracing_user.c)

samples/subsys/tracing/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Source common USB sample options used to initialize new experimental USB
5+
# device stack. The scope of these options is limited to USB samples in project
6+
# tree, you cannot use them in your own application.
7+
source "samples/subsys/usb/common/Kconfig.sample_usbd"
8+
9+
source "Kconfig.zephyr"

samples/subsys/tracing/README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Build a USB-tracing image with:
4646

4747
.. zephyr-app-commands::
4848
:zephyr-app: samples/subsys/tracing
49-
:board: sam_e70_xplained/same70q21
49+
:board: reel_board
5050
:conf: "prj_usb_ctf.conf"
5151
:goals: build
5252
:compact:
@@ -65,7 +65,7 @@ run the :zephyr_file:`scripts/tracing/trace_capture_usb.py` script on the host:
6565

6666
.. code-block:: console
6767
68-
sudo python3 trace_capture_usb.py -v 0x2FE9 -p 0x100 -o channel0_0
68+
sudo python3 trace_capture_usb.py -v 0x2FE3 -p 0x0001 -o channel0_0
6969
7070
The VID and PID of USB device can be configured, just adjusting it accordingly.
7171

samples/subsys/tracing/prj_usb_ctf.conf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
CONFIG_GPIO=y
2-
CONFIG_USB_DEVICE_STACK=y
3-
CONFIG_USB_DEVICE_VID=0x2FE9
4-
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
2+
CONFIG_USB_DEVICE_STACK_NEXT=y
53

64
CONFIG_TRACING=y
75
CONFIG_TRACING_CTF=y

samples/subsys/tracing/sample.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ tests:
5353
extra_args: CONF_FILE="prj_uart_ctf.conf"
5454
filter: dt_chosen_enabled("zephyr,tracing-uart")
5555
sample.tracing.transport.usb.ctf:
56-
platform_allow: sam_e70_xplained/same70q21
57-
depends_on: usb_device
56+
integration_platforms:
57+
- frdm_k64f
58+
depends_on: usbd
5859
extra_args: CONF_FILE="prj_usb_ctf.conf"
5960
sample.tracing.transport.native:
6061
platform_allow:

samples/subsys/tracing/src/main.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <zephyr/kernel.h>
99
#include <zephyr/sys/printk.h>
1010
#include <zephyr/logging/log.h>
11-
#include <zephyr/usb/usb_device.h>
11+
#include <sample_usbd.h>
1212
#include <zephyr/tracing/tracing.h>
1313

1414
/*
@@ -93,15 +93,19 @@ void threadA(void *dummy1, void *dummy2, void *dummy3)
9393
ARG_UNUSED(dummy2);
9494
ARG_UNUSED(dummy3);
9595

96-
#if defined(CONFIG_USB_DEVICE_STACK)
97-
int ret;
96+
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
97+
struct usbd_context *sample_usbd = sample_usbd_init_device(NULL);
9898

99-
ret = usb_enable(NULL);
100-
if (ret) {
99+
if (sample_usbd == NULL) {
100+
printk("Failed to initialize USB device");
101+
return;
102+
}
103+
104+
if (usbd_enable(sample_usbd)) {
101105
printk("usb backend enable failed");
102106
return;
103107
}
104-
#endif /* CONFIG_USB_DEVICE_STACK */
108+
#endif /* CONFIG_USB_DEVICE_STACK_NEXT */
105109

106110
/* spawn threadB */
107111
k_tid_t tid = k_thread_create(&threadB_data, threadB_stack_area,

subsys/tracing/Kconfig

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ config TRACING_BACKEND_UART
142142

143143
config TRACING_BACKEND_USB
144144
bool "USB backend"
145-
depends on USB_DEVICE_STACK
145+
depends on USB_DEVICE_STACK_NEXT
146146
depends on TRACING_ASYNC
147147
help
148148
Use USB to output tracing data.
@@ -178,13 +178,6 @@ config RAM_TRACING_BUFFER_SIZE
178178
Size of the RAM trace buffer. Trace will be discarded if the
179179
length is exceeded.
180180

181-
config TRACING_USB_MPS
182-
int "USB backend max packet size"
183-
default 64
184-
depends on TRACING_BACKEND_USB
185-
help
186-
USB tracing backend max packet size(endpoint MPS).
187-
188181
config TRACING_HANDLE_HOST_CMD
189182
bool "Host command handle"
190183
select UART_INTERRUPT_DRIVEN if TRACING_BACKEND_UART

0 commit comments

Comments
 (0)