Skip to content

Commit 2878753

Browse files
committed
samples: video: tcpserversink: ethernet over usb
Ethernet over USB support. Signed-off-by: Hugues Fruchet <[email protected]>
1 parent 5ffa36c commit 2878753

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

samples/drivers/video/tcpserversink/README.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ interface. Ethernet cable must be connected to RJ45 connector.
3131

3232
On :zephyr:board:`stm32n6570_dk`, the MB1854 IMX335 camera module must be plugged in
3333
the CSI-2 camera connector. A RJ45 ethernet cable must be plugged in the ethernet CN6
34-
connector.
34+
connector. When using ethernet over USB, plug an USB-C cable between CN8 USB1 connector
35+
and your host PC.
3536

3637
Building and Running
3738
********************
@@ -94,6 +95,16 @@ When using compression support, use this GStreamer command line:
9495
gst-launch-1.0 tcpclientsrc host=192.0.2.1 port=5000 \
9596
! queue ! decodebin ! queue ! fpsdisplaysink sync=false
9697
98+
When using ethernet over USB, set the ethernet interface through USB before
99+
starting the GStreamer command line:
100+
101+
.. code-block:: console
102+
sudo ifconfig enx00005e005301 192.0.2.2
103+
104+
To find the right interface, search for "enx" in dmesg
105+
.. code-block:: console
106+
[1316045.847337] cdc_ether 3-6.3.2:1.0 enx00005e005301: renamed from eth0
107+
97108
References
98109
**********
99110

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# USB Device settings
2+
CONFIG_USB_DEVICE_STACK=y
3+
4+
# Select USB Configurations
5+
CONFIG_USB_DEVICE_NETWORK_ECM=y
6+
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n
7+
8+
# Logging
9+
CONFIG_USB_DRIVER_LOG_LEVEL_INF=y
10+
CONFIG_USB_DEVICE_LOG_LEVEL_INF=y

samples/drivers/video/tcpserversink/prj.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,25 @@ CONFIG_NET_MAX_CONTEXTS=10
3535
# Network shell
3636
CONFIG_NET_SHELL=y
3737

38+
# Network management
39+
CONFIG_NET_MGMT=y
40+
CONFIG_NET_MGMT_EVENT=y
41+
CONFIG_NET_MGMT_EVENT_STACK_SIZE=800
42+
CONFIG_NET_MGMT_EVENT_QUEUE_SIZE=5
43+
CONFIG_NET_CONNECTION_MANAGER=y
44+
3845
# Network application options and configuration
46+
CONFIG_NET_CONFIG_INIT_TIMEOUT=1
47+
CONFIG_NET_CONFIG_AUTO_INIT=y
3948
CONFIG_NET_CONFIG_SETTINGS=y
4049
CONFIG_NET_CONFIG_MY_IPV4_ADDR="192.0.2.1"
50+
CONFIG_NET_CONFIG_PEER_IPV4_ADDR="192.0.2.2"
4151

4252
CONFIG_VIDEO=y
53+
54+
# USB Device settings
55+
CONFIG_USB_DEVICE_STACK=y
56+
57+
# Select USB Configurations
58+
CONFIG_USB_DEVICE_NETWORK_ECM=y
59+
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=y

samples/drivers/video/tcpserversink/src/main.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
#include <zephyr/drivers/video-controls.h>
1010
#include <zephyr/kernel.h>
1111
#include <zephyr/logging/log.h>
12+
#include <zephyr/net/net_config.h>
1213
#include <zephyr/net/socket.h>
14+
#include <zephyr/usb/usb_device.h>
1315

1416
LOG_MODULE_REGISTER(main, CONFIG_LOG_DEFAULT_LEVEL);
1517

@@ -31,6 +33,14 @@ static ssize_t sendall(int sock, const void *buf, size_t len)
3133
return 0;
3234
}
3335

36+
void usb_init(void)
37+
{
38+
if (usb_enable(NULL))
39+
printk("usb enable error\n");
40+
41+
(void)net_config_init_app(NULL, "Initializing network over USB");
42+
}
43+
3444
#if DT_HAS_CHOSEN(zephyr_videoenc)
3545
const struct device *encoder_dev = NULL;
3646

@@ -166,6 +176,8 @@ int main(void)
166176
}
167177

168178
/* Prepare Network */
179+
usb_init();
180+
169181
(void)memset(&addr, 0, sizeof(addr));
170182
addr.sin_family = AF_INET;
171183
addr.sin_port = htons(MY_PORT);

0 commit comments

Comments
 (0)