Fix nRF54Lx DTM implementation when using GRTC. The Radio
start needs to be offset by a maximum ISR latency value that
is less than inter-frame switching, plus minimum counter
compare offset that can be set, plus minimum CPU latency to
set the counter compare register.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 53d053359a)
Use clock startup time from devicetree.
Relates to commit 72dac165d8 ("Bluetooth: Controller: Use
OVERHEAD_XTAL_US from devicetree").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
(cherry picked from commit 5e2e989cdc)
Always verify the length in zcan_sendto_ctx().
Fixes: #104652
Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
(cherry picked from commit b439029296)
When receiving a DNS query, make sure that the packet contains
also query type and class fields before trying to access them.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 3a40c90b98)
Make sure to check packet length check before starting the
IPv6 fragmentation reassembly process. This way we can drop the
malformed packet without consuming resources.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
(cherry picked from commit 66812f66a7)
The 250745e198 OT stack upmerge pulled upstream commit 079852b67e9b
("[uptime] enforce `UPTIME` feature for MTD and FTD builds (#11354)")
which made `OPENTHREAD_CONFIG_UPTIME_ENABLE` mandatory for MTD builds.
Update the module configuration accordingly to fix a build failure with
CONFIG_OPENTHREAD_MTD=y.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
(cherry picked from commit 6cb019d0ab)
Add a new flash simulator test
`test_nvs_startup_full_sector_after_ate_power_loss`
to verify that NVS startup correctly handles a sector that becomes
logically full due to a power loss during the last ATE write.
The test simulates:
- Continuous data writes filling the sector.
- A corrupt ATE at the end of the data area (simulating power loss).
- Presence of a valid GC ATE and Close ATE.
- Verification that `nvs_mount()` succeeds despite the corrupt ATE.
This ensures NVS does not fail to mount in realistic power-loss
scenarios and that garbage collection is correctly triggered on
the next write.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
(cherry picked from commit 63bfb2d6ee)
NVS writes an entry by first programming the data area and then writing
the corresponding ATE. If a power loss occurs after the data has been
written but while the ATE is being programmed, and the remaining space
in the sector is only large enough for a single ATE, the ATE may end up
partially written.
1) Power loss while writing the last data ATE, leaving only space for
a delete ATE but no space for additional data entries:
[ data ][ data ][ erase ][ ATE ][ ATE ][ erase ] (sector end)
^^^
In this cases, nvs_startup() scans the sector and fails to find any
erased space usable for data writes, causing failed to mount.
[ data ][ data ][ erase ][ ATE (Invalid) ][ ATE ][ erase ]
^ ^
ate_wra
data_wra
The sector is logically exhausted andshould be closed and garbage
collected.
Detect this condition during startup. If no erased space exists after
the last ATE write, explicitly close the sector and trigger garbage
collection to restore a writable sector.
This completes the missing recovery path for power-loss scenarios
where a sector becomes effectively full due to ATE writes.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
(cherry picked from commit c200ff1eb4)
Explcitly zero the flags of the SQE obtained from `rtio_sqe_acquire`
when the `rtio_sqe_prep_*` helpers aren't used (the helpers memset the
entire struct to 0).
The flags must be reset to ensure the `RTIO_SQE_TRANSACTION` and
`RTIO_SQE_CHAINED` are not retained from a previous SQE.
Signed-off-by: Jordan Yates <jordan@embeint.com>
(cherry picked from commit 2c47b2d2a3)
Preprocessor evaluates CYC_PER_TICK as zero in condition
`(COUNTER_MAX / CYC_PER_TICK) == 1` when
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME is defined.
This commit skips the check when
CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME is defined.
Fixes: #100040
Signed-off-by: Ioannis Damigos <ioannis.damigos.uj@renesas.com>
(cherry picked from commit cc4bc45556)
The driver uses spinlocks for synchronization (due to strict timing
requirements) which makes it defacto incompatible with almost all SPI
backend drivers, as most of them use `k_sem_take` internally.
This change reworks the driver in the following way to solve this
problem:
- Replace driver locks with `k_mutex`
- Run the `load` functions on the system workqueue to execute them on
a cooperative priority
- Use additional local spinlock in the `bitbang` driver variant to ensure
precise timing
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
(cherry picked from commit 564cabce71)
The ICE40 driver uses a CS hack that effectively 'steals' the CS pin
from the SPI driver during `load` by setting the CS pin id to 0.
This triggered the newly introduced assert during gpio_set.
This change introduces a hotfix for this where, instead of setting the
CS pin to 0, it sets the entire CS to 'hardware based'.
It is still a hack and should be reworked at some point.
Signed-off-by: Martin Stumpf <finomnis@gmail.com>
(cherry picked from commit 097928d633)
Without this change, the fix introduced in commit 189fa5f4d8e ("modules:
silabs: Force sli_mv_m4_app_from_flash_to_ram() to be in RAM") is not
active.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
(cherry picked from commit df01f03c0c)
SiWx917 does not support concurrent read and write on the flash.
sli_mv_m4_app_from_flash_to_ram() ensure that requirement. Especially, it
disable the Zephyr scheduler. However, to guaranty the instruction cache
won't access to the flash, this function has to be located in RAM.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
(cherry picked from commit de64c007c2)
This patch is a workaround to a know issue when Bluetooth and pm
is activated.
We actually need to set the tx power to the Bluetooth controller
(network coprocessor) before sending power saving request to the
coprocessor.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit be4723c213)
Power profile property doesn't need to be defined in device three.
It is a configuration value that is defined if we want pm with
Bluetooth and/or Wifi .
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit e866da994f)
Removed conditional checks for device runtime put in DMA RX and
TX callbacks, ensuring that device runtime is always released
asynchronously.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit d02cdc734e)
This patch fix a reg write that needs to be done before calling the
callback. Since the user can start a new dma transfer in the callback,
it can miss the interrupt from the new transfer if the new transfer is
done before the interrupt bit is cleared.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit 8f4f1efc86)
Removed unnecessary power management state lock calls since the DMA is
on a power domain that already handles state locking.
It will now managed directly pm_device which will active power_domain
and then block pm_state.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit aa315948dc)
Added calls to pm_device_runtime_put() to ensure proper device runtime
management when configuration or DMA transceive operations fail.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit d5c45b10e5)
This patch is needed to block the pm_state "PM_STATE_SUSPEND_TO_IDLE"
when a device on the power domain (actually all the peripherals) is
active. Without this patch, cpu can decide to go to deep sleep while
a peripheral is active.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
(cherry picked from commit b78fe9f1aa)
Call HAL_ETH_SetMDIOClockRange to set back the MDIO clock range
as it is set to 0 during the software reset.
Signed-off-by: Julien Racki <julien.racki-ext@st.com>
(cherry picked from commit 8c6670cbd0)
As the TDTxR registers reset value is undefined they must be fully
initialized when used.
Without full initialization, the TGT bit might be inadvertently set,
causing the 16-bit timestamp to be sent as the last two data bytes
when CONFIG_CAN_RX_TIMESTAMP is enabled.
Fixes: #98768
Signed-off-by: Giuseppe Iellamo <giellamo@gmail.com>
(cherry picked from commit a90f749899)
The final call in the driver init should be pm_device_driver_init.
This ensures the device transitions to active when the driver starts.
Signed-off-by: Ryan Erickson <ryan.erickson@ezurio.com>
(cherry picked from commit 889b9cd3dc)
The QSPI delayed data sampling (SSHIFT) is enabled by default. This
feature is configurable in both XSPI and OSPI drivers. Align with
these drivers and make the feature configurable for QSPI too.
Signed-off-by: Adam Zotow <azo@trackunit.com>
(cherry picked from commit 40816a81a5)
With ssht-enable property introduced in STM32 QSPI driver the delayed
data sampling (SSHIFT) got disabled for both dual and non-dual flash
configurations. Set ssht-enable property for dual flash boards
to reenable delayed data sampling.
Signed-off-by: Adam Zotow <azo@trackunit.com>
(cherry picked from commit 54b0c9559c)
This property allows to enable QSPI delayed data sampling (SSHIFT).
Signed-off-by: Adam Zotow <azo@trackunit.com>
(cherry picked from commit e545887d17)
The workaround for missing the almost-empty interrupt when TX of very small
payloads needs to also be applied for the UART on MAX32655, so default on
that workaround symbol on that target.
Signed-off-by: Pete Johanson <pete.johanson@analog.com>
(cherry picked from commit 9a55353216)
Add an overlay to enable the adc_dt sample on the siwx917_rb4338a
board.
Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
(cherry picked from commit ef1bd9d2a9)
Instead of returning a converted ADC reading, return the
raw ADC sample. Conversion is left to the user based on
the selected ADC mode (single-ended or differential).
Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
(cherry picked from commit 78f47a362f)
The Siwx91x ADC reference voltage is configurable rather than fixed.
Expose `ref_internal` in the device API so the driver can retrieve the
reference voltage from the device tree instead of assuming a constant
value.
Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
(cherry picked from commit f4c152ab47)
Add a new test for enabling device runtime PM
for siwx917_rb4338a
Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
(cherry picked from commit a80855354c)
The watchdog timer on SiWx91x devices is designed to
pause during deep-sleep and resume after wakeup.
However, an incorrect check in`wdt_setup` was
preventing this intended behavior. This patch removes
the check, restoring the correct pause-in-sleep
functionality.
Signed-off-by: Sai Santhosh Malae <Santhosh.Malae@silabs.com>
(cherry picked from commit d83740f2d8)
When an async transfer finished quickly, the internal state of
the driver could come out of sync with the hardware. The tx/rx
enabled flag and PM lock was taken after starting the DMA
transaction, which caused issues if the DMA complete callback
was called before the flags were updated. Set the flag and take
the PM lock prior to starting the DMA transaction to avoid this.
Also release the PM rx lock upon successful completion of a
transfer. The lock was previously only released when the user
manually called `uart_rx_disable()`.
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
(cherry picked from commit 54bc3154e3)
Fixes this define leaking into all application source files when
the feature is not even enabled
Co-authored-by: Chris Friedt <cfriedt@tenstorrent.com>
Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
(cherry picked from commit d94ed7b316)
During configuration the base->ICR1 or base->ICR2 register is written
without an IRQ lock. This can result in unwanted side-effects if the status
bit isn't cleared, or the edge select still needs to be updated.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
(cherry picked from commit 8402a4f8e5)
The mdns_responder sample has a simple TCP echo server running, however
the accept() function errors were ignored, making the server defunct in
case server socket started to report errors (for example when network
went down).
Update the sample to restart the echo server in case of accept() errors
to make the sample more reliable.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 735f16f12f)
If the underlying listening TCP context reported an error, it's no
longer usable, therefore accept() call for such a socket should report
an error as well, otherwise it may block indefinitely.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 1a2d9f7b8f)
In case network interface goes down, all underlying TCP contexts are
being dereferenced, however they are not released until application
dereferences them as well (i.e. closed the socket). If the application
does not do so however timely, and network interface goes down again,
the TCP context would still be present on the active contexts list and
could've been dereferenced for the second time.
Fix this by checking the context state before dereferencing it on the
stack behalf. Non-listening TCP context are being set to CLOSED state
upon dereferencing. For the listening contexts, the TCP context has
only one ref from the application side, so use the `accept_cb` pointer
value as an indicator that the accept callback, indicating an error,
has already been called for the context.
Additionally, add a mutex lock when releasing listening context on
network down even, to avoid potential races with yet unprocessed
incoming packets.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
(cherry picked from commit 913fae5169)
MAX32657 NS does not have access to the flash peripheral, so ensure the
placeholder flash controller node is disabled, and update the "storage"
node in the evkit board definition to properly document its use for TFM.
Signed-off-by: Pete Johanson <pete.johanson@analog.com>
(cherry picked from commit 625a2c2c7c)
The tolower() function takes an int parameter. LLVM compilers generate a
warning if a char is passed instead.
Signed-off-by: Keith Short <keithshort@google.com>
A couple of tests were inconsistent with glibc and picolibc.
Significant rework done to the `fnmatch()` implementation which included
refreshing that and the `rangematch()` implementations from commit
0a3b2e376d150258c8294c12a85bec99546ab84b
in https://github.com/lattera/freebsd
Removed `match_posix_class()` and implemented that functionality as
`rangematch_cc()`, which uses 64-bit integer comparison for matching
`[:alnum:]` et al instead of string comparison. That likely only works
for the "C" locale.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Signed-off-by: Harun Spago <harun.spago.code@gmail.com>
(cherry picked from commit de2d0c9563)
A regression in 936d0278bd introduced a
subtle bug in the way that escaped expressions were handled.
The regression originated with the assumption that test data (originally
adapted from a 3rd-party testsuite) was correct when it was in fact
flawed.
Specifically, `fnmatch("[[?*\\]", "\\", 0)` should fail (`FNM_NOMATCH`),
since the "\\" sequence (a single backslash after compilation) escapes
the following ']' character, thus leaving the bracket expression
incomplete.
As @keith-packard has pointed out,
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/\
V3_chap02.html#tag_18_13_01 says that a bracket expression is only
interpreted as a bracket expression, when a proper bracket expression
is formed.
Therefore, the pattern is interpreted as the sequence
`'['`, `'['`, `'?'`, `*` (wildcard), `']'` and the call should return
`FNM_NOMATCH` to indicate failure rather than 0 to indicate success.
Added new test cases from #98827 and some commentary for subsequent
reviewers.
This change does not completely fix#55186 but is related to it.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
(cherry picked from commit 637080e7ec)
Add the functions below to the minimal libc ctype.h since they are
missing, and are required as of C89 (C99 for `isblank()`)
* `isblank()`
* `islower()`
* `ispunct()`
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
A review comment in the PR below requested that unnecessary casts were
removed from ctype.h in the PR below.
https://github.com/zephyrproject-rtos/zephyr/pull/99451
Tested with manual compilation in C and C++ mode with the arguments
```shell
gcc -Wconversion -Werror -Wall -Wextra -Wint-conversion
clang -Wconversion -Werror -Wall -Wextra -Wint-conversion
gcc -Wconversion -Werror -Wall -Wimplicit--Wextra
clang++ -Wconversion -Werror -Wall -Wextra
```
and also with `-- -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y`
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Based on review feedback, it was suggested to express ctype
character checks in a more direct fashion, rather than using
arithmetic, and allow the compiler to optimize as it sees fit.
https://github.com/zephyrproject-rtos/zephyr/pull/99451#\
discussion_r2530339430
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The "check warns" workflow in CI warned over the use of `unsigned` as a
shorthand for `unsigned int` in several locations in
`lib/libc/minimal/include/ctype.h`.
```
UNSPECIFIED_INT: Prefer 'unsigned int' to bare use of 'unsigned'
File:lib/libc/minimal/include/ctype.h
```
Adjust `unsigned` to `unsigned int` to avoid linter warnings.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Set Log Level to Info when the Telnet socket reports ENETDOWN,
instead of logging an error each time the network is down.
Signed-off-by: Joel Schaller <joel.schaller16@gmail.com>
(cherry picked from commit 8f6b216ec0)
zephyr,random-mac-address defaults to 0 or 1, which is always
available in generated code. so we can use the value itself.
Signed-off-by: Sven Ginka <s.ginka@sensry.de>
(cherry picked from commit c4a4d8aa87)