Commit graph

52 commits

Author SHA1 Message Date
Thomas Stranger ee923b538b tests: drivers: can: timing: enable all bitrates on stm32h5 boards
Enable testing of all CiA recommended bitrates on the nucleo_h563zi,
where I can test, and the stm32h573i_dk, which is the testing platform
for the stm32h5 series.

Signed-off-by: Thomas Stranger <thomas.stranger@outlook.com>
2024-06-13 05:33:06 -04:00
Henrik Brix Andersen 06f02eb384 tests: drivers: can: timing: enable full timing test on frdm_mcxn947
Enable the full range of CAN timing tests on the NXP FRDM-MCXN947 board.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-06-06 15:46:57 +01:00
Tomáš Juřena 2fe8e9853b tests: drivers: can: timing: enable all bitrates on STM32H745I-Disco
Enable testing of all CiA recommended bitrates on the STM32H745I.

Signed-off-by: Tomáš Juřena <jurenatomas@gmail.com>
2024-05-20 14:24:05 +03:00
Henrik Brix Andersen 1327ff92f5 tests: drivers: can: timing: reintroduce overlays for native 64 bit
Reintroduce the overlays for native_sim/native/64 and
native_posix/native/64 to verify all bitrates on those platforms.

These were removed in fddbd79cf7.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-04-24 14:54:45 -04:00
Alberto Escolar Piedras fddbd79cf7 tests/drivers/can/timing: Remove unused overlays
The native_{posix,sim}_64 boards are not anymore twister
targets, native_{posix,sim}/native/64 are, and those
default to just use the overlays for the non variant
version.
These 2 overlays were not used by anything.
Remove them.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-03-22 12:42:31 +00:00
Henrik Brix Andersen c6583e7672 tests: drivers: can: timing: enable all bitrates on select boards
Enable testing of all CiA recommended bitrates on the following boards:
  - stm32h735g_disco

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen a472870b6d tests: drivers: can: timing: enable all bitrates on simulators/emulators
Enable testing of all CiA recommended bitrates on the following
simulated/emulated boards:
- native_sim
- native_sim_64
- native_posix
- native_posix_64
- qemu_x86
- qemu_x86_64

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen cae4dd8e1a tests: drivers: can: timing: assert at least one bitrate test supported
Some CAN controllers may be unable to meet all bitrates due to timing
restrictions, but assert that at least one of the tested bitrates was
supported.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen 9f174ec452 tests: drivers: can: timing: add tests for all CiA recommended bitrates
Add tests for all CAN bitrates recommended by CAN in Automation (CiA). The
newly added bitrate tests are guarded by new, local Kconfig option
(CONFIG_TEST_ALL_BITRATES) to avoid breaking existing board tests.

Some boards may need adjustments to their CAN core clock in order to pass
the newly added tests. Once a board is confirmed to meet these additional
checks, this Kconfig can be enabled for that board to avoid future
regressions.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen f9dc6f7d13 tests: drivers: can: timing: do not test additional sample points
Remove tests for additional sample points as this does not provide any real
value.

The purpose of this test suite is to see if the selected CAN clock allows
meeting the standard bitrates and sample points used by Zephyr. Any
tweaking needed for a specific board or system design is left up to the
user and not something that can be covered by testing a few additional
sample point locations.

Change a few comments and remove an unneeded conditional while here.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen 675ce0d255 tests: drivers: can: timing: remove support for invalid test configs
Remove now unused support for specifying invalid timing test
configurations.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen d0ec48cb60 tests: drivers: can: move tests for invalid sample points to API test suite
Move the tests for using invalid sample points from the CAN timing tests to
the CAN API tests as these are validating basic API behavior.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen fa00a73e76 tests: drivers: can: move tests for too high bitrates to API test suite
Move the tests for setting a too high bitrate from the CAN timing tests to
the CAN API tests as these are validating basic API behavior.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen 8ccccbbb88 tests: drivers: can: move min/max timing tests to API test suite
Move the test for setting the minimum/maximum supported timing parameters
from the CAN timing tests to the CAN API tests as these are validating
basic API behavior.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-19 09:47:24 +01:00
Henrik Brix Andersen a0b4bf21b5 tests: drivers: can: timing: report unsupported bitrates
Enable testing of all bitrates for all drivers and report which bitrates
are not supported by the CAN controller under test.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-03-12 10:43:36 +01:00
Henrik Brix Andersen 5d5249d85b drivers: can: unify spelling of CAN Flexible Data-rate abbreviation
Unify spelling of CAN Flexible Data-rate abbreviation to "CAN FD" instead
of "CAN-FD". The former aligns with the CAN in Automation (CiA)
recommendation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-11-01 11:17:17 +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
Henrik Brix Andersen a9d3935fa0 drivers: can: solely use sjw from devicetree for initial timing
Update the CAN controller drivers to solely use the sjw and sjw-data
devicetree properties for setting the initial timing when devicetree timing
parameters are specified in Time Quanta (TQ).

Any timing set via the CAN timing APIs will contain either user-provided or
automatically calculated SJW values. This includes any timing parameters
calculated from bus-speed and bus-speed-data devicetree properties.

Update the CAN controller driver tests accordingly and remove the
CAN_SJW_NO_CHANGE definition as it has lost its meaning.

Fixes: #63033

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-09-28 16:28:56 +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
Henrik Brix Andersen 719ebb6a27 tests: drivers: can: timing: use recommended sample point
Use the recommended sample point of 75.0% for the data phase bitrate test @
1Mbit/s. This matches the default sample point calculated in
can_common.c:sample_point_for_bitrate().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-11 19:45:00 +01:00
Henrik Brix Andersen 332f326ab1 tests: drivers: can: timing: remove superfluous timing test
Remove test for attempting to set an arbitration bitrate of
8000001 bit/s. This test belongs in the data phase timing test, where
it already present as well.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-03-11 08:47:34 +02:00
Henrik Brix Andersen 55d0ffa874 drivers: can: remove CAN_HAS_CANFD Kconfig helper
Remove the CAN_HAS_CANFD Kconfig helper symbol in order to allow enabling
CAN-FD support in the API regardless of driver support.

Change default to CAN-FD support being disabled and have samples and tests
that require CAN-FD support turn it on. This aligns the default
configuration across CAN controller drivers regardless of their
capabilities.

The rationale behind this is that we are starting to see MCUs with multiple
CAN controllers, some CAN-FD compatible, some not (e.g. NXP i.MX RT1060 and
FPGAs). Automatically enabling CAN-FD support based on the presence of a
CAN-FD capable CAN controller leads to different application default
settings based on the CAN controller(s) in use.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-25 15:00:39 +00:00
Henrik Brix Andersen c6db73e93d tests: drivers: can: timing: use capabilities to skip tests
Use the CAN controller driver capabilities to determine if the CAN-FD
timing tests should be skipped or not. There is no need for special
handling of CONFIG_CAN_FD_MODE.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2023-01-25 15:00:39 +00:00
Martin Jäger 9cec058e8e boards: posix: native_posix: enable can_loopback0 by default
The .yaml file states that CAN is supported, but the basic sample
application samples/drivers/can/counter cannot be compiled without
additional configuration.

The loopback driver does not require any additional steps like the
linux SocketCAN driver, so it is safe to enable it by default and
get rid of the many overlay files in the tests.

ISO-TP tests and the counter sample are excluded via .yaml from
twister tests because of timing issues.

Signed-off-by: Martin Jäger <martin@libre.solar>
2022-10-03 10:17:12 +02:00
Gerard Marull-Paretas a202341958 devices: constify device pointers initialized at compile time
Many device pointers are initialized at compile and never changed. This
means that the device pointer can be constified (immutable).

Automated using:

```
perl -i -pe 's/const struct device \*(?!const)(.*)= DEVICE/const struct
device *const $1= DEVICE/g' **/*.c
```

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2022-08-22 17:08:26 +02:00
Henrik Brix Andersen b4033d25f6 tests: drivers: can: timing: convert to new ztest API
Convert the CAN controller timing test suite to use the new ztest API.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-08-12 13:23:00 +02: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
Henrik Brix Andersen b3f092a109 tests: drivers: can: timing: exclude 20kbit/s test for ESP32 TWAI
Exclude the 20kbit/s CAN timing test from running on the Espressif ESP32
TWAI driver. The TWAI does not support bitrates below 50kbit/s due to the
combination of CAN clock and prescaler range.

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2022-07-30 17:32:04 +01:00
Henrik Brix Andersen 2f7c01ba21 drivers: can: rename API functions from timing_*_data to timing_data_*
Rename the CAN data phase API functions to timing_data_* for consistency:
- can_get_timing_min_data() -> can_get_timing_data_min()
- can_get_timing_max_data() -> can_get_timing_data_max()
- .timing_min_data -> timing_data_min
- .timing_max_data -> timing_data_max

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +02:00
Henrik Brix Andersen 18890828b8 drivers: can: split CAN classic and CAN-FD syscalls
Split CAN classic and CAN-FD syscalls into two:
- can_set_timing() -> can_set_timing() + can_set_timing_data()
- can_set_bitrate() -> can_set_bitrate() + can_set_bitrate_data()

Fixes: #45303

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-05-11 10:47:54 +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
Henrik Brix Andersen 7a5116acb2 tests: drivers: can: timing: print core clock to aid in debugging
Print the CAN core clock frequency along with the device name to aid in
debugging CAN timing test case errors.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-21 13:00:20 +02:00
Henrik Brix Andersen 3b1527a8f9 tests: drivers: can: timing: tighten the sample point test criteria
Tighten the sample point test acceptance criteria from +/- 10.0% to +/-
5.0%. This is in line with the CAN sample point criteria used by the
Linux kernel.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen 5961ad2af8 tests: drivers: can: timing: test more bitrates
Extend the test with more CAN in Automation (CiA) 301 standard bitrates.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen ee63bc4a09 tests: drivers: can: timing: do not overwrite sample point error value
Do not overwrite the sample point error value as it is printed at the
very end of the test.

Fixes: 578454b78d

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-13 13:28:06 -07:00
Henrik Brix Andersen 5a4a15edcf tests: drivers: can: timing: test min/max timing can be set
Test that the minimum and maximum timing parameter values are accepted
by the driver.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 578454b78d tests: drivers: can: timing: test that calculated timings can be set
Test that each calculated set of timing values can be set.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 35a78fd034 tests: drivers: can: timing: adjust sample point locations
Adjust the sample point locations for the higher bitrates to match those
used in the Linux kernel. These sample points are much more likely to be
met for a wider set of CAN controllers and their timing parameter
boundaries.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-04-05 10:33:08 -07:00
Henrik Brix Andersen 29548dfb23 tests: drivers: can: timing: extend the test to cover data phase timing
Extend the CAN driver timing tests to cover data phase timing on CAN-FD
capable CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen df4297e2a0 tests: drivers: can: timing: extend verification to cover prescaler and sjw
Extend the CAN driver timing calculation test verification to cover the
sjw and prescaler values.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen f633f74e03 tests: drivers: can: timing: run CAN timing tests in userspace
Convert the CAN driver timing calculation tests to run in userspace
where available.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-29 17:05:56 -07:00
Henrik Brix Andersen 26e95fac28 tests: drivers: can: timing: convert to the new ztest framework
Convert the CAN timing test to the new ztest framework. Restructure the
tests a bit to improve code readability and add doxygen documentation.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-03-14 11:29:30 +01:00
Henrik Brix Andersen 323a98cd34 tests: drivers: can: filter out tests if zephyr,canbus not enabled
- Filter out the CAN controller driver tests if no zephyr,canbus chosen
  node is enabled in the devicetree.
- Rename the tests to follow the general test naming scheme.
- Remove the dedicated test selection for native_posix boards

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-02-24 07:12:54 -06:00
Flavio Ceolin 0c1950f7b0 tests: Fix drivers tests tag
By convention most tests are using "drivers" and not "driver".

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2022-02-02 09:21:07 -05:00
Henrik Brix Andersen 5d05d2e3c7 tests: drivers: can: timing: switch to DEVICE_DT_GET()
Switch from using device_get_binding() to DEVICE_DT_GET().

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-10 11:24:51 +01:00
Henrik Brix Andersen 2ff9de3741 tests: drivers: can: timing: enable loopback tests on native_posix
Enable the CAN timing tests on native_posix and native_posix_64.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-04 15:13:40 -06:00
Henrik Brix Andersen 99a310b29b drivers: can: loopback: convert the CAN loopback driver to dts
Convert the CAN loopback driver from being configured via Kconfig to
multi-instance configured via devicetree.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2022-01-04 15:13:40 -06:00
Henrik Brix Andersen 5bc0451f72 drivers: can: remove DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro
Remove the DT_CHOSEN_ZEPHYR_CANBUS_LABEL macro and replace it with
DEVICE_DT_GET(DT_CHOSEN(zephyr_canbus)) were possible.

Where both devicetree CAN controllers and Kconfig specified CAN loopback
controllers are supported, the macro is replaced with
DT_LABEL(DT_CHOSEN(zephyr_canbus)) for now.

This is the first pass for removing the requirement for devicetree
labels for CAN controllers.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-09 11:19:50 +01:00
Henrik Brix Andersen c817a09b0a canbus: rename zephyr,can-primary chosen property to zephyr,canbus
Rename the Zephyr chosen property for specifying the default CAN bus
controller from "zephyr,can-primary" to "zephyr,canbus".

The "zephyr,can-primary" property name was selected in antipation of
adding support for redundant CAN networks, which we have yet to
add. Meanwhile, the "primary" term causes confusion for non-redundant
CAN bus configurations (and the "can" term doesn't match the name of the
Zephyr CAN bus subsystem).

The CAN in Automation (CiA) 302-6, which deals with CANopen network
redundancy, uses the terms "default interface" and "redundant
interface". If/when we add support for redundant CAN networks, the
"zephyr,canbus" chosen property can be supplemented with a
"zephyr,canbus-redundant" chosen property.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2021-11-07 09:05:39 -05: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