Skip to content

Commit 120407e

Browse files
committed
samples: echo_server: use new USB device stack
Remove netusb code and use new USB device stack. Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
1 parent b57cea5 commit 120407e

File tree

7 files changed

+10
-50
lines changed

7 files changed

+10
-50
lines changed

samples/net/sockets/echo_server/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ target_sources_ifdef(CONFIG_NET_UDP app PRIVATE src/udp.c)
2323
target_sources_ifdef(CONFIG_NET_TCP app PRIVATE src/tcp.c)
2424
target_sources_ifdef(CONFIG_NET_L2_IPIP app PRIVATE src/tunnel.c)
2525

26-
if (CONFIG_USB_DEVICE_STACK)
27-
target_sources(app PRIVATE src/usb.c)
28-
endif()
29-
3026
if (CONFIG_USB_DEVICE_STACK_NEXT)
3127
target_sources(app PRIVATE src/usb.c)
3228
include(${ZEPHYR_BASE}/samples/subsys/usb/common/common.cmake)

samples/net/sockets/echo_server/overlay-netusb.conf

Lines changed: 0 additions & 10 deletions
This file was deleted.

samples/net/sockets/echo_server/overlay-usbd_next.conf renamed to samples/net/sockets/echo_server/overlay-usbd.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ CONFIG_LOG=y
44
CONFIG_USBD_LOG_LEVEL_WRN=y
55
CONFIG_UDC_DRIVER_LOG_LEVEL_WRN=y
66

7+
CONFIG_NET_L2_ETHERNET=y
8+
79
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

samples/net/sockets/echo_server/sample.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,15 @@ tests:
7575
sample.net.sockets.echo_server.b91_802154:
7676
extra_args: EXTRA_CONF_FILE="overlay-802154.conf"
7777
platform_allow: tlsr9518adk80d
78-
sample.net.sockets.echo_server.usbnet:
79-
depends_on: usb_device
78+
sample.net.sockets.echo_server.usbd_cdc_ncm:
79+
depends_on: usbd
8080
harness: net
81-
extra_args: EXTRA_CONF_FILE="overlay-netusb.conf"
81+
extra_args: EXTRA_CONF_FILE="overlay-usbd.conf"
82+
EXTRA_DTC_OVERLAY_FILE="usbd_cdc_ncm.overlay"
8283
tags:
8384
- net
8485
- usb
85-
# native_sim usb driver does not work with CONFIG_POSIX_API
86-
platform_exclude:
87-
- native_sim
88-
- native_sim/native/64
89-
sample.net.sockets.echo_server.openthread:
86+
sample.net.sockets.echo_server.nrf_openthread:
9087
extra_args: EXTRA_CONF_FILE="overlay-ot.conf"
9188
slow: true
9289
tags:

samples/net/sockets/echo_server/src/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static inline bool is_tunnel(struct net_if *iface)
9999
}
100100
#endif /* CONFIG_NET_L2_IPIP */
101101

102-
#if defined(CONFIG_USB_DEVICE_STACK) || defined(CONFIG_USB_DEVICE_STACK_NEXT)
102+
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
103103
int init_usb(void);
104104
#else
105105
static inline int init_usb(void)

samples/net/sockets/echo_server/src/usb.c

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,12 @@
77
#include <zephyr/logging/log.h>
88
LOG_MODULE_DECLARE(net_echo_server_sample, LOG_LEVEL_DBG);
99

10-
#include <zephyr/usb/usb_device.h>
11-
#include <zephyr/net/net_config.h>
12-
13-
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
1410
#include <sample_usbd.h>
11+
#include <zephyr/net/net_config.h>
1512

1613
static struct usbd_context *sample_usbd;
1714

18-
static int enable_usb_device_next(void)
15+
int init_usb(void)
1916
{
2017
int err;
2118

@@ -29,28 +26,6 @@ static int enable_usb_device_next(void)
2926
return err;
3027
}
3128

32-
return 0;
33-
}
34-
#endif /* CONFIG_USB_DEVICE_STACK_NEXT */
35-
36-
int init_usb(void)
37-
{
38-
#if defined(CONFIG_USB_DEVICE_STACK)
39-
int ret;
40-
41-
ret = usb_enable(NULL);
42-
if (ret != 0) {
43-
LOG_ERR("Cannot enable USB (%d)", ret);
44-
return ret;
45-
}
46-
#endif /* CONFIG_USB_DEVICE_STACK */
47-
48-
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
49-
if (enable_usb_device_next()) {
50-
return 0;
51-
}
52-
#endif /* CONFIG_USB_DEVICE_STACK_NEXT */
53-
5429
(void)net_config_init_app(NULL, "Initializing network");
5530

5631
return 0;

0 commit comments

Comments
 (0)