Commit graph

89328 commits

Author SHA1 Message Date
Rodrigo Peixoto 01981910ec samples: zbus: add priority boost sample to zbus
This sample illustrates how to properly use zbus priority boost feature.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Rodrigo Peixoto 2cfd28e5ca tests: zbus: add HLP priority boost tests
Add the dedicated tests for HLP priority boost.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Rodrigo Peixoto fb7515e27b samples: zbus: fix samples to work with priority boost
Adjust the sample to work with the priority boost. It illustrates zbus
being used inside an ISR instead of into the main function.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Rodrigo Peixoto 73f0bcc7fc tests: zbus: fix unit tests to work with priority boost
The test considers using zbus inside ISR.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Rodrigo Peixoto c992707251 zbus: add priority boost feature
Replace mutexes with semaphores to protect the channels in conjunction with
a priority boost algorithm based on the observers' priority.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-01-04 09:41:54 +01:00
Sebastian Bøe c25ac487af tests: crypto: rand32: Check return code of sys_csrand_get
Check the return code of sys_csrand_get when testing the function.

Ignoring it is bad practice and can also be a security issue if users
copy-paste this test code.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2024-01-03 23:57:13 -06:00
Christopher Friedt 67a74e4350 tests: posix: test_realtime: improve test reliability
Previously posix_apis.test_realtime was failing (very)
frequently in CI, and in particular, when running on Qemu,
POSIX, or SMP targets.

We are using CLOCK_REALTIME for this test, which incurs an
additional syscall overhead above CLOCK_MONOTONIC. The act
of sleeping itself also incurs a syscall overhead.

The latency from one iteration to the next of the internal
loop is a bit of a random process due to scheduler or clock
noise (although the noise itself is still bounded).

In order to make this test robust against such noise, assert
only on the average time from one iteration to the next,
rather than the instantaneous time.

Rather than calculating a sample mean, use a running average
(aka Cumulative Moving Average) to save some bytes.

Report results, including low and high watermarks before
asserting that the average iteration time within expected
range.

==============================================================
START - test_realtime
I: n: 20, sleep: 100, margin: 10, lo: 110, avg: 110, hi: 110
 PASS - test_realtime in 2.198 seconds
==============================================================

Expect to see the low and high watermarks change more on
Qemu and POSIX platforms when running several jobs in parallel
with twister (such as in CI).

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Christopher Friedt 95a22b1217 posix: clock: clock_gettime() should not be a syscall
We try to implement Zephyr's POSIX API as regular library
functions, so remove the __syscall annotation from
clock_gettime() and implement the syscall portion of it under
the hood.

This also adds a bit of a micro-optimization in that
we can do a lot of processing outside of the system call.

In fact, processing CLOCK_MONOTONIC likely does not
require any syscall other than k_uptime_ticks().

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Christopher Friedt e0383a6f9d posix: clock: check for invalid ns in clock_settime()
The clock_settime() function should not accept an input timespec
with nanosecond values < 0 or >= NSEC_PER_SEC.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Christopher Friedt 1695b5a0b2 tests: unit: util: add array for-each tests
Add tests for the following two macros

* ARRAY_FOR_EACH(array, idx_var)
* ARRAY_FOR_EACH_PTR(array, ptr_var)

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Christopher Friedt 42335036b7 include: util: add array for-each macros
AFAIK, we do not have array for-each loops. Seemed like an
obvious gap to fill, so introduce two variants:

* ARRAY_FOR_EACH(array, idx_var)
* ARRAY_FOR_EACH_PTR(array, ptr_var)

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2024-01-04 08:27:29 +09:00
Maciej Baczmanski 11613e08e7 net: openthread: increase TCAT stack size
Running TCAT with PSA crypto API  causes stack overflow.
Increased stack size.

Signed-off-by: Maciej Baczmanski <maciej.baczmanski@nordicsemi.no>
2024-01-03 19:01:05 +00:00
Torsten Rasmussen 9981e69b91 cmake: update description of board_runner_args() function
Update description of board_runner_args() function so that it is
described that app_set_runner_args macro must be defined before the call
to `find_package(Zephyr)`.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-01-03 19:00:49 +00:00
Jukka Rissanen fa0e04e2ed tests: net: dhcpv6: Adjust the source address of test pkt
We would drop the received packet if the source address is our
address so tweak the test and make source address different.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 19:00:33 +00:00
Jukka Rissanen 155e2149f2 tests: net: ipv6: Adjust the source address of test pkt
We would drop the received packet if the source address is our
address so tweak the test and make source address different.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 19:00:33 +00:00
Jukka Rissanen 8d3d48e057 net: ipv6: Check that received src address is not mine
Drop received packet if the source address is the same as
the device address.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 19:00:33 +00:00
Robert Lubos 48601fde96 tests: net: socket: tls: Make sure sockets are closed on test failure
Add after() function for the test suite, which does cleanup on still
open sockets. Otherwise, an individual test case failure affects all
other test cases, blurring the test suite results.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos f70715eeb3 tests: net: socket: tls: Add more tests covering poll()
Add new test cases, covering TLS/DTLS socket poll() functionality.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 898aa9ed9a net: sockets: tls: Align DTLS connect() behavior with regular TLS
DTLS socket is not really connection-less as UDP, as it required the
DTLS handshake to take place before the socket is usable. Therefore,
align the DTLS connect() behavior with regular TLS.
The change is backward compatible. connect() call is still optional for
DTLS socket (the handshake can still take place from send()/recv()) and
a socket option was provided to disable DTLS handshake on connect().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos c0d5d2fbd5 net: sockets: tls: Allow handshake during poll()
When using DTLS socket, the application may choose to monitor socket
with poll() before handshake has been complete. This could lead to
potential crash (as the TLS context may have been left uninitialized)
and unexpected POLLIN reports (while handshake was still not complete).
This commit fixes the above - POLLIN will only be reported once
handshake is complete and data is available

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 0a1bee48bf net: sockets: tls: Improve POLLERR error reporting
In case a socket error was caused by TLS layer, it was not reported with
POLLERR. This commit fixes this.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 5b3b462eed net: sockets: tls: Add flag indicating that session is closed
In case TLS session is closed at the TLS level (and thus recv() reports
0 to the application) a certain race occurs between consecutive recv()
call, and TCP session teardown. As mbedtls_ssl_read() only reports
session close upon receiving CLOSE alert, consecutive non-blocking
recv() calls would report EAGAIN instead of connection closed, if called
before underlying TCP connection was closed.

Fix this, by storing the information that TLS session has ended at TLS
socket level. The new flag will be checked before attempting further
mbed TLS actions, so that connection status is reported correctly.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Robert Lubos 1dc9028316 net: sockets: tls: Add function to obtain underlying ssl context
For test purposes only. Should not be used in regular applications.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-01-03 19:00:15 +00:00
Tomasz Lissowski 61cb7d4358 adsp: hda: accept 16 byte alignment for HDA buffer size
HDA DMA driver uses an excessive value of 128 bytes as required alignment
for DMA buffer size. This may result in the correct buffer size (e.g.
32-byte aligned, which is DT-compliant) being silently truncated before
writing it into DGBS register. This patch changes the requirement to the
value implied by DGBS register format (effectively reduces to 16 bytes).

Signed-off-by: Tomasz Lissowski <tomasz.lissowski@intel.com>
2024-01-03 18:59:55 +00:00
Ryan McClelland 4d9ad941d7 manifest: zscilib: update revision for double promotion fix
Update zscilib, this is needed for the double promotion fix

Signed-off-by: Ryan McClelland <ryanmcclelland@meta.com>
2024-01-03 18:59:32 +00:00
Andy Sinclair b3fdb7477b drivers: regulator: fixed: Removed pin state setting from init
The setting of initial state in handled by the common driver,
which calls the enable function for any regulator that has
regulator-boot-on set, and is not already enabled.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2024-01-03 18:59:12 +00:00
Bjarki Arge Andreasen 48fa603da3 modem: cmux: Patch resync mechanism
The CMUX resync mechanism can get stuck between states
MODEM_CMUX_RECEIVE_STATE_RESYNC_0 and
MODEM_CMUX_RECEIVE_STATE_RESYNC_1 if the resync flags, which are
sent only once in state MODEM_CMUX_RECEIVE_STATE_SOF, are not
responded to, or the response is lost.

This patch ensures resync flags are sent from states
MODEM_CMUX_RECEIVE_STATE_SOF, MODEM_CMUX_RECEIVE_STATE_RESYNC_1
and MODEM_CMUX_RECEIVE_STATE_RESYNC_2 if its determined that the
resync flags are not being responded to.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 18:58:39 +00:00
Bjarki Arge Andreasen 3ebe814294 modem: chat: Patch invalid dereference
The chat module contains an array of three lists of matches,
one of which are static, two of which are contained within the
currently running script. The current match, which is an
object stored in one of the three lists, is stored in its own
pointer in the chat module context.

A memory error occurs when the script is stopped, while the
chat module is using one of the matches stored withing the
script. This commit clears the match pointer when the script
is stopped if the match is stored within the script.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 18:57:55 +00:00
Bjarki Arge Andreasen ed8578d566 pm: device_runtime: Add missing include to header
The device_runtime header includes references to struct device
and k_timeout_t, but only zephyr/device.h is included. k_timeout_t
is in zephyr/kernel, so it must also be included.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 17:24:42 +00:00
Fabian Pflug 3c0a6058b5 drivers: pwm: stm32: Catch overflows in 2-channel capture
When not using 4 channel capture, overflows were never reported
to the application, because the check was in the
four_channel_capture_support branch.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-01-03 12:55:50 +01:00
Jukka Rissanen ec42d825ec net: context: Fix the v4 mapped address handling in sendto
If we receive a IPv4 packet to v4 mapped address, the relevant
net_context is bound to IPv6. This causes issues if we try
to get the family from the context struct in sendto.
Fix this by checking if the destination address is IPv4 but
the socket is bound to IPv6 and v4 mapping is enabled.
If all these criterias are set, then set the family of the
packet separately and do not get it from net_context.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 12:55:14 +01:00
Jan Müller 8f0abaf87f Doc: Clearify bt_conn_set_security documentation
Clearify the sec parameter in the documentation of bt_conn_set_security.

This should make the API documentation easier to understand.

Signed-off-by: Jan Müller <jan.mueller@nordicsemi.no>
2024-01-03 10:21:48 +01:00
Henrik Brix Andersen bc2826c1cb drivers: gpio: pca953x: check return values from I2C API functions
Check the return values from the I2C API functions called in init() and
fail driver initialization if unsuccessful.

Fixes: #66827

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-03 10:21:28 +01:00
Bjarki Arge Andreasen 1ee092673a modem: modem_cellular.c: Remove non standard QCCID handler
The QCCID handler is Quectel specific and as such may not be part
of the modem cellular driver which only supports commands defined
in 3GPP TS 27.007

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen 572c5e6d5a modem: modem_cellular: Rework cellular_get_signal implementation
The modem_cellular.c driver now uses a common script to get
signal strenght, which is run on demand. This is more efficient
than polling it, and simpler since every modem doesn't have to
define their own variant of the script.

Additionally, the CSQ handler now stores the "raw" rssi value
returned from AT+CSQ to be parsed by the cellular_modem_get_signal
implementation.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen f9491034be modem: modem_cellular: Update driver to implement cellular API
Move the implementations of the cellular API in modem_cellular.c
to an cellular_driver_structure, and implement this API structure
withing the device drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen 6f55309659 modem: cellular: Restructure cellular API to fit device driver model
The current cellular API header is not written to conform with
the device driver model. This commit fixes that.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Chun-Chieh Li 173e4983fd drivers: wifi: esp_at: fix last rx data loss in Passive Receive mode
In Passive Receive mode, ESP modem will buffer rx data.
This fix makes the data still available to user,
even though the peer has closed the socket.
Otherwise, user will fail to get the last rx data,
when the socket is closed by the peer.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2024-01-03 10:21:09 +01:00
Junfan Song 4ae558c505 kernel: work: Fix race in workqueue thread
After a call to k_work_flush returns the sync variable
may still be modified by the workq.  This is because
the work queue thread continues to modify the flag in
sync even after k_work_flush returns.  This commit adds
K_WORK_FLUSHING_BIT, and with this bit, we moved the
logic of waking up the caller from handle_flush to the
finalize_flush_locked in workq, so that after waking up
the caller, the workqueue will no longer operate on sync.

Fixes: #64530

Signed-off-by: Junfan Song <sjf221100@gmail.com>
2024-01-03 10:20:19 +01:00
Pisit Sawangvonganan b8184ca3b7 lib: crc: address absence of crc4, crc4_ti in crc_types array
Added CRC4 and CRC4_TI to the supported crc_types[] array.
On some SoCs, like ESP32-S3, missing values can cause hardfaults
due to attempts to access the zero address.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-03 10:20:14 +01:00
Jukka Rissanen 8f97c1c2ee net: lib: sockets: Initialize iovec to 0 at start of func
Make sure iovec is initialized to a value so that there
is no possibility that it is accessed uninitialized.

Fixes: #66838
Coverity-CID: 334911

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:50 +01:00
Jukka Rissanen 4e5ef76b15 net: lib: mdns_responder: Fix interface count check
The original idea was to check that we have enough network
interfaces in the system. The check needs to verify max IPv4
and IPv6 supported interfaces instead of always checking
IPv6 one.

Fixes: #66843
Coverity-CID: 334899

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-01-03 10:19:38 +01:00
Jamie McCrae 5f8dabf44c boards: deprecated: Remove boards deprecated pre-Zephyr 2.7
Removes deprecated boards that were added in/before September
2021, which would be prior to the release of Zephyr 2.7.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-01-03 10:19:06 +01:00
Jędrzej Ciupis 57ee911891 modules: hal_nordic: new nrf_802154 configuration option
This commit adds a new Kconfig for the nRF 802.15.4 radio driver that
allows the user to specify the number of encryption keys the driver can
simultaneously store.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-03 10:18:56 +01:00
Jędrzej Ciupis 054353a75d modules: hal_nordic: reorganize nrf_802154 Kconfig
There are multiple Kconfig symbols that are only available when the
radio hardware is present. As a result, the nRF 802.15.4 radio driver
is more difficult to configure on multicore architectures. Also, such
solution goes against the principle of hiding the details of the
platform behind the driver's interface.

This commit moves all the Kconfig options that correspond to settings
present in common nRF 802.15.4 configuration header so that they're
available no matter if the API is serialized.

Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-03 10:18:56 +01:00
TOKITA Hiroshi 89982b711b drivers: serial: ra: minor cleanups
- Corrected indentation with clang-format

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi e6486bf598 drivers: interrupt_controller: ra_icu: minor cleanups
- Corrected indentation with clang-format

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi b1172d812d drivers: serial: ra: adding support interrupt driven mode
Add support interrupt driven mode for Renesas RA UART driver.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi 2de161ce4e drivers: interrupt_controller: ra_icu: Don't enable on irq connecting
Don't execute `irq_enable` in process of the `ra_icu_irq_connect_dynamic`.

The caller of `ra_icu_irq_connect_dynamic` is only `gpio_ra_pin_configure`
at this time. `gpio_ra_pin_configure` calls `irq_enable` just after called
`ra_icu_irq_connect_dynamic`.
So removing 'irq_enable' from 'ra_icu_irq_connect_dynamic' has no effect
on behavior.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi bccd281b3d drivers: interrupt_controller: ra_icu: Adding disconnect_dynamic
Adding `ra_icu_irq_disconnect_dynamic()` corresponds with
`ra_icu_irq_connect_dynamic()`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00