Commit graph

42 commits

Author SHA1 Message Date
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
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 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
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 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
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
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
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
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 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
Anas Nashif 5d001f3e41 cleanup: include/: move misc/byteorder.h to sys/byteorder.h
move misc/byteorder.h to sys/byteorder.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Johann Fischer abaeaed2af usb: sort usb config data by section
USBD_CFG_DATA_DEFINE macro has not consider that a class
could have more than one set of usb_cfg_data struct.
If a class has more than one set of usb_cfg_data
then they should be sorted the same way like by
USBD_DEVICE_DESCR_DEFINE macro.

Fixes: #16240

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2019-06-27 12:18:05 +02:00
Andrei Emeltchenko 5970b66311 tests: usb: device: Refactor device api test
Refactor device api test using standard placement for descriptor table
and configuration data.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Aurelien Jarno 819e749ccd usb: move the request handler buffer to the USB device code
In order to unify the legacy and composite code, move the class and
vendor request handler buffer into the USB device code, just like in
composite mode. The option is renamed from USB_COMPOSITE_BUFFER_SIZE
into USB_REQUEST_BUFFER_SIZE and also replaces the USB_DFU_MAX_XFER_SIZE
and USB_HID_MAX_PAYLOAD_SIZE options.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-27 09:25:06 -04:00
Andrei Emeltchenko 6378e1e4a2 tests: usb: desc_sections: Fix coverity issue
Move increment out of zassert_*().

Fixes #15770

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-17 08:06:28 -07:00
Andrei Emeltchenko 875d5a2bf6 tests: usb: desc_sections: Fix coverity issue
Coverity thinks that zassert_*() is debug stuff so move out increment.

Fixes #16163

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-17 08:06:28 -07:00
Andrei Emeltchenko d05b260e9c tests: usb: desc_sections: Cleanup test
Strip loopback name from the structures. Fix bNumEndpoints.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 19:00:02 -04:00
Andrei Emeltchenko 4626a8cb51 tests: usb: desc_sections: Check EP assignment order
Check that endpoints are assigned in the right order.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 19:00:02 -04:00
Andrei Emeltchenko c840383c6a tests: usb: desc_sections: Use automatic endpoint assignment
Use automatic assignment defined in usb_descriptor.h

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-05-06 19:00:02 -04:00
Andrei Emeltchenko fbfe75c55e usb: tests: Add second IN endpoint to test
Demonstrate automatic endpoint assignment in tests for similar
endpoint types.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko 7c35a4e89a tests: usb: Add endpoint allocation verification test
Add verification that interface number and endpoint addresses are
correctly allocated.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-28 12:22:23 -04:00
Andrei Emeltchenko 69726bbccb usb: tests: Enable other boards for test
Enable other boards with USB device supported

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-04-18 12:16:05 -04:00
Anas Nashif 3ae52624ff license: cleanup: add SPDX Apache-2.0 license identifier
Update the files which contain no license information with the
'Apache-2.0' SPDX license identifier.  Many source files in the tree are
missing licensing information, which makes it harder for compliance
tools to determine the correct license.

By default all files without license information are under the default
license of Zephyr, which is Apache version 2.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-04-07 08:45:22 -04:00
Andrei Emeltchenko 030f06ae7b tests: usb: Use UTIL_LISTIFY macros
macros allows to define variable number of instances.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-12 07:49:04 -05:00
Andrei Emeltchenko 0c1f8eb28d teste: desc_sections: Add simple test
Add one more simple test.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-08 07:56:24 -05:00
Andrei Emeltchenko 5b3bd4e099 tests: usb: Include desc_sections test for native_posix
After including native_posix USB controller we can perform some simple
tests on native_posix.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-06 17:53:04 -05:00
Andrei Emeltchenko bf9c6d72e8 usb: Add instance parameter to descriptors definitions
This allows to place instances of the class one after another in the
linker section.

Fixes #12908

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:11:32 -05:00
Andrei Emeltchenko a49125ca90 tests: usb: Test USB data allocations in sections
USB relies on descriptors and configuration data allocations in
specific sections. This simple test verifies that at least size of the
data is correct.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2019-02-01 19:11:32 -05:00