Commit 25b0212f authored by Johann Fischer's avatar Johann Fischer Committed by Kumar Gala
Browse files

subsys: usb: class: add loopback function



Add loopback function. This function can be used to test
USB device drivers and device stack connected to linux host
and has the similar interface as "Gadget Zero" [1] of the Linux
kernel.

Use modprobe usbtest to load the module, see also [2] for the
description of the tests and for Vendor and Product ID of the
"Gadget Zero". The userspace tool testusb [3] is needed to start
the tests.

[1] linux/drivers/usb/gadget/function/f_loopback.c
[2] linux/drivers/usb/misc/usbtest.c
[3] linux/tools/usb/testusb.c

Signed-off-by: default avatarJohann Fischer <j.fischer@phytec.de>
parent 3a471e32
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
project(NONE)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
+11 −0
Original line number Diff line number Diff line
CONFIG_STDOUT_CONSOLE=y
CONFIG_SYS_LOG=y
CONFIG_SYS_LOG_DEFAULT_LEVEL=1

#USB related configs
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr testusb sample"
CONFIG_SYS_LOG_USB_DRIVER_LEVEL=1
CONFIG_USB_DEVICE_LOOPBACK=y
CONFIG_SYS_LOG_USB_DEVICE_LEVEL=1
+6 −0
Original line number Diff line number Diff line
sample:
  name: USB loopback sample
tests:
  usb.loopback:
    depends_on: usb_device
    tags: usb
+14 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2018 Phytec Messtechnik GmbH
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr.h>
#include <logging/sys_log.h>

void main(void)
{
	SYS_LOG_INF("");
}
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ zephyr_sources_ifdef(CONFIG_USB_CDC_ACM cdc_acm.c)
zephyr_sources_ifdef(CONFIG_USB_MASS_STORAGE mass_storage.c)
zephyr_sources_ifdef(CONFIG_USB_DEVICE_BLUETOOTH bluetooth.c)
zephyr_sources_ifdef(CONFIG_USB_DFU_CLASS usb_dfu.c)
zephyr_sources_ifdef(CONFIG_USB_DEVICE_LOOPBACK loopback.c)

add_subdirectory_ifdef(CONFIG_USB_DEVICE_NETWORK netusb)
add_subdirectory_ifdef(CONFIG_USB_DEVICE_HID hid)
Loading