Skip to content

Commit

Permalink
tests: add pkg_tinyusb_netdev for tinyUSB netdec
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Nov 15, 2022
1 parent e8688d8 commit ef78c85
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/pkg_tinyusb_netdev/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
BOARD ?= samr21-xpro

include ../Makefile.tests_common

USB_VID ?= $(USB_VID_TESTING)
USB_PID ?= $(USB_PID_TESTING)

CLASS ?= tinyusb_class_net_rndis

USEPKG += tinyusb

USEMODULE += auto_init_gnrc_netif
USEMODULE += gnrc_ipv6_router_default
USEMODULE += gnrc_icmpv6_echo
USEMODULE += shell
USEMODULE += shell_cmds_default
USEMODULE += ps
USEMODULE += tinyusb_netdev
USEMODULE += $(CLASS)

include $(RIOTBASE)/Makefile.include
3 changes: 3 additions & 0 deletions tests/pkg_tinyusb_netdev/Makefile.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BOARD_INSUFFICIENT_MEMORY := \
stm32f7508-dk \
#
54 changes: 54 additions & 0 deletions tests/pkg_tinyusb_netdev/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
Overview
========

This test application can be used to check the implementation of the tinyUSB
netdev driver. The implementation of the tinyUSB netdev driver uses Ethernet
over USB and supports the following protocols:

- CDC ECM (Ethernet Control Model)
- CDC NCM (Network Control Model)
- RNDIS (Microsoft Remote NDIS)

While Linux and macOS support all these protocols, Microsoft Windows only
supports RNDIS and since Windows version 11 also CDC NCM. Which protocol is
used is selected by the corresponding pseudomodules `tinyusb_class_net_cdc_ecm`,
`tinyusb_class_net_cdc_ncm` and `tinyusb_class_net_rndis`.

Configuration
=============
The test application use the protocol defined by the CLASS variable, which
defaults to the RNDIS protocol (`tinyusb_class_net_rndis`). This can be
changed by setting this variable in the make command line, for example:
```
CLASS=tinyusb_class_net_cdc_ecm BOARD=... make -C tests/pkg_tinyusb_netdev flash
```
The CDC ECM protocol (`tinyusb_class_net_cdc_ecm`) and the RNDIS protocol
(`tinyusb_class_net_rndis`) can be used simultaneously to support all operating
systems, for example :
```
CLASS='tinyusb_class_net_rndis tinyusb_class_net_cdc_ecm' \
BOARD=... make -C tests/pkg_tinyusb_netdev flash
```
In this case, the CDC ECM protocol is the default protocol and the RNDIS
protocol the alternative protocol defined as second device configuration.

The CDC NCM protocol cannot be used together with the CDC ECM or the RNDIS
protocol

Expected result
===============

Use the network related shell commands to verify the network link between the
board under test and the host computer. Ping to the link local address from and
to the host computer must work.

On the host computer, using tools such as `ethtool` must show the USB CDC ECM
interface as link detected:

```
# ethtool enp0s20u9u4
Settings for enp0s20u9u4:
Current message level: 0x00000007 (7)
drv probe link
Link detected: yes
```
48 changes: 48 additions & 0 deletions tests/pkg_tinyusb_netdev/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (C) 2019 Koen Zandberg <koen@bergzand.net>
* 2022 Gunar Schorcht <gunar@schorcht.net>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for the tinyUSB netdev
*
* @author Koen Zandberg <koen@bergzand.net>
* @author Gunar Schorcht <gunar@schorcht.net>
*
* @}
*/

#include <stdio.h>

#include "shell.h"
#include "msg.h"

#define MAIN_QUEUE_SIZE (8U)
static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];

int main(void)
{
/* we need a message queue for the thread running the shell in order to
* receive potentially fast incoming networking packets */
msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
puts("Test application for the tinyUSB net device interface\n");
puts("This test pulls in parts of the GNRC network stack, use the\n"
"provided shell commands (i.e. ifconfig, ping) to interact with\n"
"the tinyUSB based network interface.\n");

/* start shell */
puts("Starting the shell now...");
char line_buf[SHELL_DEFAULT_BUFSIZE];
shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE);

/* should be never reached */
return 0;
}

0 comments on commit ef78c85

Please sign in to comment.