Skip to content

Emul backend API #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2,042 commits into
base: main
Choose a base branch
from
Open

Emul backend API #4

wants to merge 2,042 commits into from

Conversation

tristan-google
Copy link
Owner

For initial feedback

Copy link
Collaborator

@yperess yperess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, we need to have generic test that will replace this one and the ICM tests

* integer portion. Limit the value to the supported range.
*/

int16_t reg_val = CLAMP(value >> shift, AKM09918C_MAGN_MIN_MICRO_GAUSS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't always work, if shift is negative some architectures will do strange things, you need to check the sign and shift.

CLAMP(
    shift < 0 ? (value >> -shift) : (value << shift),
    AKM09918C_MAGN_MIN_MICRO_GAUSS,
    AKM09918C_MAGN_MAX_MICRO_GAUSS
);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this last time, but you're using uint8_t for the shift value, it's not unsigned. I think that's where the confusion is.

zassert_equal(SENSOR_CHAN_MAGN_X, channel);
zassert_ok(decoder->get_shift(buf, channel, &shift));

scaled_value = (int64_t)q << shift;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shift < 0 ? ((int64_t)q >> -shift) : ((int64_t)q << shift)

Comment on lines 159 to 162
zassert_within(expected_x,
FIELD_GET(GENMASK64(31 + shift, 31), scaled_value) * 1000000 +
((FIELD_GET(GENMASK64(30, 0), scaled_value) * 1000000) / INT32_MAX),
1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right, if the backend takes a q31_t and a shift, we should expect the result to be the same, so I would expect this assert to be:

zassert_equal(0, shift); // Since the call emul_sensor_backend_set_channel used a 0 shift
zassert_equal(expected_x, q);


zassert_ok(sensor_get_decoder(fixture->dev, &decoder));

/* Check X channel */
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we guarantee the order so another driver might not return the order you asked it in. Same here, if you change

iodev_akm09918c_channels[0] = SENSOR_CHAN_MAGN_Z;
iodev_akm09918c_channels[1] = SENSOR_CHAN_MAGN_Y;
iodev_akm09918c_channels[2] = SENSOR_CHAN_MAGN_X;

You'll still get X, Y, Z order. Its the natural register order that dictates the result order.

* integer portion. Limit the value to the supported range.
*/

int16_t reg_val = CLAMP(value >> shift, AKM09918C_MAGN_MIN_MICRO_GAUSS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice this last time, but you're using uint8_t for the shift value, it's not unsigned. I think that's where the confusion is.

* integer portion. Limit the value to the supported range.
*/

int16_t reg_val = CLAMP(arithmetic_shift_right(value, shift),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arithmetic_shift_right doesn't work here, you'll need to check if shift is negative and basically shift left if positive, shift right if negative. Since this is a test, you're welcome to use the zDSP library for this (the scale function will handle this for you) or you can manually do the check shift < 0 ? (value >> -shift) : (value << shift)

@yperess
Copy link
Collaborator

yperess commented Jun 14, 2023

The final step once this is finished is to figure out how to move this test out of the akm09918c specific test and run it on all sensors in an agnostic way. You can enable sensor info with Kconfig and that will allow you to iterate over the sensors, the one bit that's missing is that we also need a way to map a const struct device* to its corresponding const struct emul*. It's a bit costly, but I think it's fine since it's a test, each struct emul contains a pointer to the device it's emulating, so you can just go through the emul iterable section and find the emulator with emul->dev == dev.

@tristan-google tristan-google force-pushed the emul-backend-api branch 5 times, most recently from b94ecc3 to f5bd473 Compare July 18, 2023 19:26
@tristan-google tristan-google force-pushed the emul-backend-api branch 2 times, most recently from b6031b7 to 915986a Compare July 24, 2023 18:11
gdengi and others added 5 commits July 25, 2023 16:58
Each PSCI interface versions have different DT compatible strings
like arm,psci-0.2, arm,psci-1.1 and so on. However, the same driver
can be used for all the versions by adding #define DT_COMPAT for
required version and #undef DT_COMPAT for default version.

Add support for PSCI cold reset, warm reset and cpu-on function IDs.

Signed-off-by: Girisha Dengi <[email protected]>
Signed-off-by: Navinkumar Balabakthan <[email protected]>
The intent of this change is to add custom shell configurations for
intel_socfpga_agilex* based boards. As of now, configurations are
added for 'intel_socfpga_agilex5_socdk' board.

Signed-off-by: Girisha Dengi <[email protected]>
Code owners for all the required Intel Agilex5 platform drivers.

Signed-off-by: Girisha Dengi <[email protected]>
Add maintainer and collaborators for Intel Agilex platforms and
related drivers.

Signed-off-by: Girisha Dengi <[email protected]>
The correct paths are soc/xtensa/espressif_esp32
and soc/riscv/espressif_esp32, not soc/xtensa/esp32
and soc/riscv/esp32.

Signed-off-by: Bartosz Bilas <[email protected]>
fabiobaltieri and others added 14 commits July 25, 2023 18:49
The check currently only runs if the maintainers file itself is changed,
but that means that the check is going to miss every PR that moves
directory or delete files that can potentially trigger an error.

This check is cheap to run, just run it unconditionally.

Signed-off-by: Fabio Baltieri <[email protected]>
Fix various incorrect maintainer file entry for directories. These
are currently matching files, but would break few scripts if we were to
upgrade the CI image to Python 3.11 due to a change in behavior of
Path.glob().

Fixes various:

MAINTAINERS.yml: glob pattern '...' in 'files' in area '...' does not
match any files

on machines running Python 3.11 or newer.

Link: https://docs.python.org/3/library/pathlib.html#pathlib.Path.glob
Signed-off-by: Fabio Baltieri <[email protected]>
Some 64bit arch SoC happens to have 64bit registers.

Signed-off-by: Yong Cong Sin <[email protected]>
Add a shim driver for NXP's Data Co-Processor (DCP) driver.

Signed-off-by: Pieter De Gendt <[email protected]>
Add device tree entry for DCP driver support on i.MX RT10XX platforms.

Signed-off-by: Pieter De Gendt <[email protected]>
Use a default prj.conf to be used for all samples and use
EXTRA_CONF_FILE for specifics.

Signed-off-by: Pieter De Gendt <[email protected]>
Some drivers require the encryption key to be 4-byte aligned.

Signed-off-by: Pieter De Gendt <[email protected]>
Add a testcase for mimxrt1064_evk to be able to run the crypto
sample.

Signed-off-by: Pieter De Gendt <[email protected]>
Add initial version of Infineon CAT1 counter driver
Add initial version of binding file for Infineon
Add counters to psco6 dtsi
Add external trigger pin that runs counter

Signed-off-by: Pavlo Havrylyuk <[email protected]>
Variant of JSON_OBJ_DESCR_ARRAY_ARRAY that can be used when the
 structure and JSON field names differ.

Signed-off-by: Bartosz Bilas <[email protected]>
There are two different i2c node properites `zephyr,flash-buf-max-size`
and `zephyr,concat-buf-size`. In the end max value of that two is used
to define size of the message buffer.
It's redundant to store both values in device config structure.
Changed config structure to contain only bigger value.

Signed-off-by: Adam Wojasinski <[email protected]>
This commit aligns TWIM shim to utilize memory-region property.
The memory-region is not required property that enables user
to specify placement of dma buffers in memory region.
It is done by assigning to memory-region property,
phandle to node with zephyr,memory-region and mimo-sram compatible.

When memory-region property is not specified for given
instance, buffer is placed in default RAM region with other data.

Signed-off-by: Adam Wojasinski <[email protected]>
Add Kconfig RISCV_SOC_HAS_CUSTOM_SYS_IO symbol so that a riscv
SoC can set to specify that it has a custom implementation for
sys_io functions.

Signed-off-by: Yong Cong Sin <[email protected]>
The NXP S32 QSPI controller acts as an interface to up to two serial
flash memory devices, each with up to eight bidirectional data lines,
depending on the platform. It is based on a LUT enginee to interface
through commands with different memory types including flash NOR and
Hyperram.

This patch adds support for the QSPI in S32K344 which supports a single
memory device (side A) with up to four bidirectional data lines and SDR
only. Nevertheless, the memory controller is implemented flexible enough
to be extended to support more feature-rich QSPI blocks.

Signed-off-by: Manuel Argüelles <[email protected]>
ArekBalysNordic and others added 29 commits August 1, 2023 08:23
The psa_generate_random function requires the psa_crypto_init call
before the usage. This can be ensured by calling the psa_crypto_init
in otPlatCryptoRandomInitfunction.

Signed-off-by: Arkadiusz Balys <[email protected]>
This reverts commit f5eada5.

Fixes zephyrproject-rtos#57590.

In order to fix incorrect program headers with CMAKE_LINKER_GENERATOR,
issue zephyrproject-rtos#59064 needs to be addressed first. Until then, revert to the
status quo from several versions back.

Signed-off-by: Grzegorz Swiderski <[email protected]>
Refactor the function to make the execution flow in transceive()
clearer. In particular, return error codes directly, not through
spi_context_complete() which is unnecessary in this case.

Signed-off-by: Andrzej Głąbek <[email protected]>
Add option to use (by defining the `wake-gpios` devicetree properties)
an additional signal line between SPI master and SPI slave that allows
the latter to stay in low-power state and wake up only when a transfer
is to occur.

Signed-off-by: Andrzej Głąbek <[email protected]>
Introduce more specific ARM targets basing on enabled options in
Kconfig.

Signed-off-by: Patryk Duda <[email protected]>
Both Clang[1] and GCC[2] says that _Float16 type is defined by
ISO/IEC TS 18661-3:2015 not the IEEE 754-2008. Fix help message under
FP16 config option.

[1] https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point
[2] https://gcc.gnu.org/onlinedocs/gcc/Half-Precision.html

Signed-off-by: Patryk Duda <[email protected]>
Support for 16 bit floats is enabled by default in Clang [1].
The ARM alternative format is not supported, so __fp16 always uses
IEEE 754-2008 format [2].

[1] https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/ARM/ARMAsmPrinter.cpp#L750-L755
[2] https://clang.llvm.org/docs/LanguageExtensions.html#half-precision-floating-point

Fixes: zephyrproject-rtos#55562

Signed-off-by: Patryk Duda <[email protected]>
Clang provides runtime library `libclang_rt.builtins.<arch>.a` but
`libgcc.a` is also supported.

The compiler can provide full path to the selected library using the
`--print-libgcc-file-name` option, for example:
```
/usr/lib64/clang/17/lib/baremetal/libclang_rt.builtins-armv7m.a
```

If `--rtlib=libgcc` option is provided, clang will also provide
appropriate path.

This patch replaces hardcoded `libgcc` with library name extracted from
path, so we are compatible with both libraries.

Signed-off-by: Patryk Duda <[email protected]>
Clang/LLVM is natively a cross-compiler, so one set of applications can
compile code to all supported targets. The default target can be changed
using '--target' option.

CMake supports this type of compilers. To change compiling target, one
should set CMAKE_C_COMPILER_TARGET accorgindly.

The '--target' option has impact on the path to clang-rt library
returned by compiler when run with '--print-libgcc-file-name' option.
Without specifying target, Clang will return path to runtime library of
the host target (e.g. x86_64-pc-linux-gnu).

Signed-off-by: Patryk Duda <[email protected]>
This fixes setting invalid List_Item_Length in Current Calls List.
The fix complements 9c7ef8e.

Signed-off-by: Mariusz Skamra <[email protected]>
This removes code duplications by unifying GTBS and TBS service
definition macros.

Signed-off-by: Mariusz Skamra <[email protected]>
Fixes sensor drivers to consistently return -ENOTSUP when an unsupported
channel argument is passed to the sensor_channel_get function.

Signed-off-by: Maureen Helm <[email protected]>
In commit d537267, the check on thread abortion was moved from next_up
to z_get_next_switch_handle. However, next_up is also called from
z_swap_next_thread, so the check on thread abortion is now missing there.
This sometimes caused the thread to be stuck in ABORTING + PENDING state
during the test_smp_switch_torture in test/kernel/smp

To avoid such cases in the future, it is worth leaving the check in next_up

Signed-off-by: Vadim Shakirov <[email protected]>
Allow socket-loop to wake up immediately, if there are changes,
instead of waiting for zsock_poll() to timeout.
This change makes engine more reactive and removes
hard coded timeout from zsock_poll().

Signed-off-by: Seppo Takalo <[email protected]>
Engine now allows registering service callbacks that are
called only once on a given timestamp.
This allows tickless services to be developed.

Signed-off-by: Seppo Takalo <[email protected]>
Call RD client service only when there is state transitioning.
Remove periodic 500 ms timer.

Signed-off-by: Seppo Takalo <[email protected]>
Assign orphaned files related to NXP area.

Signed-off-by: Manuel Argüelles <[email protected]>
Make ethernet phys childs of the mdio device and move the mdio device up
a level on the tree. That makes the device hierarchy coherent with the
required initialization priority and allows keeping the sequence in
check with CHECK_INIT_PRIORITIES.

Signed-off-by: Fabio Baltieri <[email protected]>
Use 64bit timestamps from k_uptime_get() so they don't
roll over during the expected device lifetime.

Fixes zephyrproject-rtos#60826

Signed-off-by: Seppo Takalo <[email protected]>
CoAP fixes contain 64bit timer values.
LwM2M now supports tickless mode.

Signed-off-by: Seppo Takalo <[email protected]>
Explicitly setting the start of VMA can intefere if the memory
region was used in another section, for example indirectly via
zephyr_code_relocate().

Signed-off-by: Andriy Gelman <[email protected]>
For applications relocating big parts of the code with many sections,
builds were failing on Windows due to hitting the max command-line
length on that platform.
Fix this by using a file to store the dictionary passed to the python
script.

Fixes zephyrproject-rtos#60994.

Signed-off-by: Carles Cufi <[email protected]>
We know this is a test already.

Signed-off-by: Anas Nashif <[email protected]>
config_dir is part of cmake testsuite.

Signed-off-by: Anas Nashif <[email protected]>
coredump is part of debug subsystem, unify identifiers to have
everything in one bucket.

Signed-off-by: Anas Nashif <[email protected]>
Remove tests.subsys from identifier, fixed tag.

Signed-off-by: Anas Nashif <[email protected]>
Do no use misc as component for test identifier.

Signed-off-by: Anas Nashif <[email protected]>
Use mgmt as the component, the same we use in other related tests.

Signed-off-by: Anas Nashif <[email protected]>
Implement the backend emul API for the ICM42688 motion sensor so it can
be automatically tested by the generic sensor test (see zephyrproject-rtos#60394).
Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the
programmable full-scale accel and gyro ranges.

Also fixes an arithmetic bug in the driver that was causing a minor
error in the returned readings.

Signed-off-by: Tristan Honscheid <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.