Commit graph

92 commits

Author SHA1 Message Date
Johann Fischer 4191602f11 usb: device_next: add helper to register all available class instances
Add helper to register/unregister all available class instances.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-06-14 19:17:13 +02:00
Tomasz Moń 6d5edf9255 tests: usb: fix build all test on qemu_cortex_m3
Reduce RAM disk size from 192 sectors down to 1 sector to solve linking
issue due to qemu_cortex_m3 target having too little RAM. The RAM disk
size does not really matter in this test case and should be as small as
possible.

Enable test random generator to solve missing sys_rand_get() required by
networking subsystem.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-06-13 12:01:31 -04:00
Johann Fischer 43c9176a3c tests: usb: remove feature usb_device dependency
The tests do not depend on the usb_device or usbd feature.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-06-11 11:38:09 +01:00
Johann Fischer 29003ff264 usb: bos: cleanup Binary Device Object Store header
We could reuse the BOS header, but there are parts that are only needed
in the legacy device support or used internally and the tests. Move this
parts to the appropriate places.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-17 16:25:02 +01:00
Johann Fischer 69e3e3a90d tests: usb: add usb_set_config() call to desc_sections test
With the previous changes, usb_set_config() is no longer called by
default at boot time, causing the test to fail.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-05-08 12:00:46 +02:00
Tomasz Moń 5144d0f65f usb: device_next: Introduce speed specific configurations
USB High-Speed devices must be able to operate at both High-Speed and
Full-Speed. The USB specification allows the device to have different
configurations depending on connection speed. Modify the API to reflect
USB Specification requirements on what can (e.g. configurations) and
what cannot (e.g. VID, PID) be speed dependent.

While the class configurations for different speeds are completely
independent, the actual class instances are shared between operating
speeds (because only one speed can be active at a time). Classes are
free to provide different number of interfaces and/or endpoints for
different speeds. The endpoints are assigned for all operating speeds
during initialization.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-04-22 06:51:22 -07:00
Tomasz Moń 52ce527c81 usb: device_next: uac2: add descriptor sets macros
Add necessary macros and convert UAC2 descriptor test from descriptor
blob to descriptor set. Currently there is only Full-Speed descriptor
set.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-04-22 06:51:22 -07:00
Johann Fischer fa5cfbd937 test: device_next: add overlays to build all functions
Add overlays and test case to build all USB device functions.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-04-19 17:04:00 +00:00
Alberto Escolar Piedras 8abdc49664 tests/subsys several: Use hwmv2 native targets identifiers
For the 64 bit targets, change identifiers to the new hwmv2 ones.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-15 16:13:12 +01:00
Tomasz Moń 3e7368829b usb: device_next: uac2: interface descriptor macros
Add macros to initialize full set of descriptors required for USB Audio
Class 2 instance. Descriptors start with Interface Association
Descriptor that binds together the AudioControl interface and all
AudioStreaming interfaces.

AudioStreaming interfaces have alternate setting 0 without any endpoints
and alternate setting 1 with isochronous endpoint with max packet size
calculated on maximum sample frequency, number of channels, subslot size
and clock synchronization (asynchronous endpoints require +1 sample).

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-12-15 14:24:44 +01:00
Tomasz Moń a825147d0c tests: usb: uac2: test descriptor macros
Compare devicetree generated class specific descriptors for headset
example against reference hex values.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-12-15 14:24:44 +01:00
Alberto Escolar Piedras 2231c3ab97 tests/subsys/usb/*: Enable for native_sim
Enable all these tests which run in native_posix in native_sim,
Switch from native_posix to native_sim as default test platform
And switch native_posix overlays to native_sim.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-11-27 16:06:42 +00:00
Anas Nashif 345735d0a8 tests: remove CONFIG_ZTEST_NEW_API in all tests
Remove all usage of CONFIG_ZTEST_NEW_API from tests and sample as this
is now enabled by default.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2023-10-20 15:04:29 +02:00
Johann Fischer ed7d56f04e tests: usb: add test for new USB device support
This is initial patch to add tests for new USB device support.
The test uses USB host support and virtual USB bus by default,
but should work on real hardware as well. For now, only the
Get Configuration and Set Interface requests are tested by default.
More tests will follow.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-10-01 09:26:07 +03:00
Johann Fischer 430818ecaa sample/tests: remove CONFIG_USB_COMPOSITE_DEVICE usage
This is no longer necessary, as this option is selected as a dependency
for class implementations where it is required.
Also remove redundant test cases.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2023-07-26 14:37:15 +02:00
Gerard Marull-Paretas dacb3dbfeb iterable_sections: move to specific header
Until now iterable sections APIs have been part of the toolchain
(common) headers. They are not strictly related to a toolchain, they
just rely on linker providing support for sections. Most files relied on
indirect includes to access the API, now, it is included as needed.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-22 10:42:30 +02:00
Gerard Marull-Paretas 93b63df762 samples, tests: convert string-based twister lists to YAML lists
Twister now supports using YAML lists for all fields that were written
as space-separated lists. Used twister_to_list.py script. Some artifacts
on string length are due to how ruamel dumps content.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2023-05-10 09:52:37 +02:00
Erwan Gouriou 66d4c64966 all: Fix "#if IS_ENABLED(CONFIG_FOO)" occurrences
Clean up occurrences of "#if IS_ENABLED(CONFIG_FOO)" an replace
with classical "#if defined(CONFIG_FOO)".

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2022-12-21 10:09:23 +01:00
Anas Nashif ba7d730e9b tests/samples: use integration_plaforms in more tests/samples
integration_platforms help us control what get built/executed in CI and
for each PR submitted. They do not filter out platforms, instead they
just minimize the amount of builds/testing for a particular
tests/sample.
Tests still run on all supported platforms when not in integration mode.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-11-29 16:03:23 +01:00
Zhao Shuai ca90a9f408 tests: subsys: usb: device: add zassert to judge whether USB enable
Change zassume to zassert to judge failure whether is due to failing
to enable USB.
Fix issue: 48665

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-09-02 11:23:31 +00:00
Fabio Baltieri def230187b test: fix more legacy #include paths
Add a bunch of missing "zephyr/" prefixes to #include statements in
various test and test framework files.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2022-08-02 16:41:41 +01:00
Zhao Shuai 88c53a4beb tests: subsys: usb: move os_desc to new ztest API
Move test os_desc to use new ztest API.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-07-27 18:45:16 +02:00
Zhao Shuai 610a657017 tests: subsys: usb: move device to new ztest API
Move test device to use new ztest API.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-07-27 18:45:16 +02:00
Zhao Shuai 8659267f41 tests: subsys: usb: move desc_sections to new ztest API
Move test desc_sections to use new ztest API.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-07-27 18:45:16 +02:00
Zhao Shuai 813158feb5 tests: subsys: usb: move bos to new ztest API
Move test bos to use new ztest API.

Signed-off-by: Zhao Shuai <shuai1x.zhao@intel.com>
2022-07-27 18:45:16 +02:00
Gerard Marull-Paretas ade7ccb918 tests: migrate includes to <zephyr/...>
In order to bring consistency in-tree, migrate all tests to the new
prefix <zephyr/...>. Note that the conversion has been scripted, refer
to #45388 for more details.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-05-06 20:02:14 +02:00
Johann Fischer 6be45c2a18 usb: move USB device stack code to own directory
Until now the whole USB device stack code is located
in the top subsys/usb directory. Move it to own directory
in preparation for upcoming extension and rework of USB support.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-03-31 18:30:14 +02:00
Nazar Kazakov f483b1bc4c everywhere: fix typos
Fix a lot of typos

Signed-off-by: Nazar Kazakov <nazar.kazakov.work@gmail.com>
2022-03-18 13:24:08 -04:00
Krzysztof Chruscinski 47ae656cc1 all: Deprecate UTIL_LISTIFY and replace with LISTIFY
UTIL_LISTIFY is deprecated. Replacing it with LISTIFY.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-03-08 11:03:30 +01:00
Johann Fischer 5296339fde usb: rework to use macro STRUCT_SECTION_FOREACH
Replace deprecated macro USBD_CFG_DATA_DEFINE by
USBD_DEFINE_CFG_DATA which places usb_cfg_data structures
in specific iterable section.

Replace __usb_data_start, __usb_data_end usage patterns
  size_t size = (__usb_data_end - __usb_data_start);
  for (size_t i = 0; i < size; i++) {...}
by
  STRUCT_SECTION_FOREACH(usb_cfg_data, ...) {...}

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-12-10 07:22:15 -06:00
Johann Fischer cf8d7764da usb: fix bulk endpoint configuration for high-speed capable device
In the current USB device support, the sizes of bulk endpoint
are mostly configure through Kconfig and do not care if a device
is high-speed capable. The information if a USB device controller
supports high-speed comes from devicetree. Add a Kconfig option to
map this information and configure bulk endpoint sizes
accordingly.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-11-24 12:28:02 +01:00
Torsten Rasmussen 1cccc8a8fe cmake: increase minimal required version to 3.20.0
Move to CMake 3.20.0.

At the Toolchain WG it was decided to move to CMake 3.20.0.

The main reason for increasing CMake version is better toolchain
support.

Better toolchain support is added in the following CMake versions:
- armclang, CMake 3.15
- Intel oneAPI, CMake 3.20
- IAR, CMake 3.15 and 3.20

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-20 09:47:34 +02:00
Johann Fischer 3240e0cc51 tests: remove USB configuration option
Remove USB configuration option, replace it where necessary
with USB_DEVICE_STACK.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:00:12 -04:00
Johann Fischer c0ea13ba85 tests: usb: use new USB framework header
Replace all macros with the new ones from usb/usb_ch9.h header.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 13:20:07 +02:00
Anas Nashif dca317c730 sanitycheck: inclusive language
change whitelist -> allow.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-08-27 07:04:07 -04:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Marc Herbert debade9121 tests: make find_package(Zephyr...) REQUIRED
... because it is (required).

This makes a difference when building with CMake and forgetting
ZEPHYR_BASE or not registering Zephyr in the CMake package registry.

In this particular case, REQUIRED turns this harmless looking log
statement:

-- Could NOT find Zephyr (missing: Zephyr_DIR)
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Check for working C compiler: /usr/bin/cc
-- ...
-- ...
-- ...
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:8 (target_sources):
  Cannot specify sources for target "app" which is not built by
  this project.

... into this louder, clearer, faster and (last but not least) final
error:

CMake Error at CMakeLists.txt:5 (find_package):
  Could not find a package configuration file provided by "Zephyr" with
  any of the following names:

    ZephyrConfig.cmake
    zephyr-config.cmake

  Add the installation prefix of "Zephyr" to CMAKE_PREFIX_PATH or set
  "Zephyr_DIR" to a directory containing one of the above files.  If
  "Zephyr" provides a separate development package or SDK, be sure it
  has been installed.

-- Configuring incomplete, errors occurred!

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-05-29 10:47:25 +02:00
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
Andrei Emeltchenko 484aeb3351 tests: usb: General cleanup
Remove unneeded headers and cleanups.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2020-01-07 21:05:44 +01:00
Andrei Emeltchenko b8ea41e9d9 tests: usb: Use hexdump logger helper for bos test
Remove hexdump helper using standard logger one.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2020-01-07 21:05:44 +01:00
Emil Obalski d65027d8c0 usb: samples: Application calling usb_enable by itself
User app is reponsible for issuing usb_enable and
making USB hardware operative.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-19 13:08:55 +01:00
Johann Fischer 1ac67d1559 tests: usb: adapt descriptor test to new Serial Number placeholder
Adapt descriptor test to new Serial Number placeholder.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-12-18 11:12:28 +01:00
Emil Obalski c1f5e11bb6 usb: Cleanup for multiplied defines
Some of defines are present in several header files.
Those defines are the same with value but with different naming.

Common defines are brought to usb_common.h

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2019-12-09 12:48:13 -05:00
Jan Van Winkel 7a70fa8488 usb: tests: Pass correct lengths to hexdump in usb bos test
Pass correct length to hexdump in usb bos test to prevent overun
of global data.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2019-09-16 15:33:10 -05:00
Peter A. Bigot 765c06376c Revert "sys/util.h: helper macro to perform pointer difference"
This reverts commit 755cc644cc.

This approach is problematic in several ways.  First, `intptr_t` could
cause undefined behavior in the subtraction when the pointer converts to
a negative value.  Except in weird cases where the sign of the pointer
identifies a memory domain (like kernel vs userspace) I'm unaware of any
valid use of `intptr_t`.

Second, this macro was created to address a special need that cannot
rely on defined behavior: i.e. to ensure that data definitions are
placed in contiguous space and access is provided through linker-defined
symbols, for which the language required alignment and continuity is not
guaranteed.

A macro that calculates the span between linker symbols has very
different semantics than one that calculates the difference between
pointers.  Replace the global PTR_DIFF with a documented local macro
that tests what's necessary without risking integer overflow.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-07-17 03:44:03 -04:00
Nicolas Pitre 6609c12516 tests: enable native_posix_64 testing
Whenever conditions are applied to native_posix, they should apply to
native_posix_64 too.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-16 10:41:11 -07:00
Nicolas Pitre 9fac66ca54 tests: usb: make 64-bit compatible
Let's use the PTR_DIFF() helper which performs pointer difference in a
64-bit compatible way, and use %zu for printing sizeof() results.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-12 17:39:43 -07:00
Nicolas Pitre 0aa796cbaa print format: adjust specifiers to be compatible with a 64-bit build
The size_t type is either compatible with an int on 32-bit target, or
a long on 64-bit targets. It could even be a long even on some 32-bit
targets. Let's use the z qualifier in the printf format to be compatible
with whatever flavor in use.

In case of pointers, let's just use %p with pointers directly and
avoid casts altogether.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-11 20:12:26 -07:00
Nicolas Pitre 6455ddbd4e test/usb: fix pointer type mismatch
The 4th argument of usb_dc_ep_write() should be a u32_t* not a size_t*.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2019-07-05 14:16:50 -04:00
Johann Fischer ab8bcd2044 tests: usb: do not set device address
Forced attempt to set the device address is unpredictable
and also should not be done during testing.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-07-04 21:36:07 +02:00