Fix some "All if ... else if constructs shall be terminated
with an else clause" (c:M23_112) issues reported by SonarQube.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
The API documentation for the disconnected() callback warns that
the listener can't assume that the corresponding connection object
has been freed and may me available to the application.
The recommendations given to still start a new connection
or connectable advertiser are outdated or misleading:
- "start connectable advertising": the options that "will attempt
to resume the advertiser under some conditions" are deprecated
since Zephyr 4.0 (BT_LE_ADV_OPT_CONNECTABLE and related)
- "using k_work_submit()": assuming everything will be fine
when the work is actually processed is not reliable
- "increase CONFIG_BT_MAX_CONN": setting BT_MAX_CONN to N+1
when planning N simultaneous connections is a work-around
that users may have gotten used to (despite its footprint),
but there is no longer any reason to advise it
Stop documenting creating new connections or restarting advertising
from the disconnected() callback and instead recommend relying
on recycled() for these use cases.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
The API documentation for the recycled() callback predates [1],
and still warns users to "treat this callback as an ISR",
although it now runs on the system workqueue thread,
as does disconnected().
"Making Bluetooth API calls" to "re-start connectable advertising or
scanning" should no longer be "strongly discouraged".
On the contrary, we can emphasize that this is the right event
to listen for to initiate operations that will try to re-allocate
a freed connection object.
Mention that BT_MAX_CONN configures the size of the connection pool.
Refs:
- [1] efb5d83: Bluetooth: Host: Defer `conn.recycled()` to the syswq
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
An assertion in bt_conn_unref() accesses the connection's state
after decrementing its reference count.
This is not consistent since, if we removed the last reference,
the Bluetooth Host stack may reuse the connection object
before the assertion is checked.
Instead, retrieve the connection property tested by the assertion
before decrementing the counter, as we do for other properties.
Simplify the code path by returning early when we did not remove
the last reference.
Remind that automatic advertiser resumption is deprecated.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
In bt_conn_unref(), a local variable is used as atomic target:
atomic_val_t old = atomic_dec(&conn->ref);
/* Prevent from accessing connection object */
bool deallocated = (atomic_get(&old) == 1);
Using atomic_get() to access a non-shared local variable
cannot prevent any data race on that variable,
and only causes confusion.
Moreover, this call to atomic_get() is incorrect: the API expects
an atomic_t* argument (target), not an atomic_val_t* (value).
This compiles and /works/ only because Zephyr defines both to be
the same integer type, and thus: atomic_get(&old) == old.
The equivalent C11 code, where _Atomic(T) and T are different types,
wouldn't compile.
Signed-off-by: Christophe Dufaza <chris@openmarl.org>
Product photo from https://learn.adafruit.com/assets/122469,
which has the CC BY-SA 3.0 license.
Tested with the command mentioned in the index.rst page.
Signed-off-by: Jonas Berg <jonas.s.t.berg@gmail.com>
Compiler property no_track_macro_expansion is controlled by
CONFIG_COMPILER_TRACK_MACRO_EXPANSION.
When that Kconfig is set to Y, clang fails with the following error
message:
unknown argument: '-ftrack-macro-expansion=0'
This commit modifies clang/compiler_flags.cmake so that there is a
proper clang compiler option for this flag.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The only reason to keep these would be to enable conditional compilation
of some parts of the code. However, we can't see enough benefit in doing
this, particularly since the flash driver itself will conditionally
handle certain paths depending on erase caps, so the options are
deprecated to reduce complexity.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
This fully decouples blob_io_flash from specific flash device details,
by not reading the write block size from a hard-coded device tree node,
instead pulling this from the actual flash device used.
The block write routine has been updated to be more generic and fix a
few bugs:
* The write buffer is now sized based on a KConfig option instead of
basing it off the device tree - this makes the module usable with
any flash device, not just the internal memory. The configured value
is checked during initialization, to ensure that the configured size
will fit the write block size required by the device passed to the
init function.
* The erase value used to fill the buffer when using a device with
explicit erase is now pulled from the flash parameters instead of
being hard-coded to `0xff`.
* An additional write block sized piece of buffer is allocated - the
previous buffer sizing with rounding up only worked if
`BLOB_RX_CHUNK_SIZE % WRITE_BLOCK_SIZE` was 0 or 1 (which
coincidentally worked in all testing because the chunk size defaults
to 161, and for internal flash w/write block size of 4,
`161 % 4 == 1`).
* The choice of whether to just write the chunk as-is or to
write-block align it is now based on the erase cap pulled from the
flash parameters, instead of checking the type of memory in the SOC.
This means the module dos _not_ currently support the case where
memory has to be written write-block aligned, but the memory does
_not_ use explicit erase. It uses a trick of filling the write
buffer with the erase value to avoid overwriting existing chunks,
which will not work in this case. This trick is required to support
random ordered chunks while still writing write-block aligned.
* The code has been cleaned up a bit in general.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
Only erase a page when starting the first block on that page.
This fixes a bug where, if the block size is smaller than the page size,
the entire page would be erased upon start of each block when writing,
meaning only the final block on each page would be retained. This works
because blocks are always received in order.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
This adds a Kconfig dependency on FLASH_PAGE_LAYOUT when using flash
with explicit erase, removing all code dependencies on flash
configuration from the erasure logic. This module already requires
FLASH_PAGE_LAYOUT to be set when using it with flash with explicit
erase, as a silent requirement. The current code does not work without
this option enabled except for the case where a BLOB has a size which is
a multiple of the page size (since, without it, trying to erase flash
space for the final block, which is of variable size, will fail). Also
cleans up the code a bit.
Signed-off-by: Ludvig Jordet <ludvig.jordet@nordicsemi.no>
Choose mt35xu01gbba for zephyr,flash-controller. This is needed for
building mcuboot or other application accessing flash.
Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
Add target for imx95-evk that runs code from the mt35xu01gbba external
flash connected through flexspi
Signed-off-by: Andre Heinemans <andre.heinemans@nxp.com>
Extract the user pipe setup and claim/release logic so that it can be
re-used by other software modules, if the AT shell is not used. Ideally
the chat instance would live within the `modem_at_user_pipe.c` and be
handed out by `modem_at_user_pipe_claim`, but the current chat API
doesn't make this possible.
Signed-off-by: Jordan Yates <jordan@embeint.com>
In case FIN packed also acknowledged most recently sent data, not all
ack-related TCP context variables were updated, resulting in invalid SEQ
number values sent in consecutive packets.
Fix this by refactoring the FIN handling in TCP_ESTABLISHED state.
Instead of having a separate block strictly for FIN packet processing,
let the packet be processed by common code responsible for regular
data/ack processing. This should be less error-prone for any future
modifications or not-yet-discovered issues. Only after the common
processing of data/ack is done, we check whether FIN flag was present in
the packet, and mark the connection for closing.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add a test case for a scenario where the final data sent by one peer is
acknowledged in the FIN,ACK response from the other peer. Verify that
the acknowledgment is handled correctly, and a consecutive sequence
number sent by the TCP stack in such case is set correctly.
This complements the other existing test for FIN packet handling, which
verified that data received in a FIN packet is handled correctly. With
those tests in place it should be safer to update any logic related to
FIN packet handling.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
When CONFIG_NET_IPV4 && CONFIG_NET_IPV4_MAPPING_TO_IPV6 are enabled,
allow IPV4 traffic to platform sockets by setting IPV6_ONLY to 0.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
just disable irq and not plush pending events,
so we don't loose them, when they are enabled
again.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
TCP context cannot operate w/o a TX packet for buffering transmitted
data. So far this net_pkt was allocated at runtime from the common
packet pool, but this created some not-obvious memory requirement on TCP
and could lead to TX packet starvation in case many TCP connections are
open in parallel. Therefore, allocate this packet structure statically,
as a part of the TCP context instead.
This increases the memory requirement of the TCP context by ~64 bytes,
however if that's a concern for the application, the maximum number of
TX packets can be lowered instead. In return, we get a clear separation
between the number of TCP connections opened, and the amount of packets
that can be transmitted.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add helper function to initialize externally allocated TX packet. It's
especially important to configure net_buf slab for the packet so that
net buffers are allocated from a correct pool for the packet.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Using net_pkt for TCP out-of-order recv queue was an overshot, as the
mechanism mostly used net_buf operations directly anyway. It can be
easily replaced with a direct net_buf pointer, so that it's not longer
needed to hog one net_pkt per TCP context anymore.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Changed 'remove' to 'omit' to clarify package instructions for
AArch64 systems. This improves clarity for users following the
Zephyr SDK setup guide.
Signed-off-by: Sheeba Babu <sheebakarickom@gmail.com>
on arc, the test fails with an MPU error instead of a stack
overflow because the priv stack is merged into the defined
stack.
Fixes#68682
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Tested with the commands mentioned in index.rst
The product photo is from
https://learn.adafruit.com/assets/137335
with the license CC BY-SA 3.0
Signed-off-by: Jonas Berg <jonas.s.t.berg@gmail.com>
Fixes
samples/drivers/pwm/capture/src/main.c:50:47: warning: implicit
conversion from 'floa' to 'double' when passing argument to function
[-Wdouble-promotion]
50 | (float)tim_clk_cycles / (float)period,
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
samples/drivers/pwm/capture/src/main.c:51:46: warning: implicit
conversion from 'floa' to 'double' when passing argument to function
[-Wdouble-promotion]
51 | (float)(width * 100) / (float)period);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
The dma has to be enabled on the platform in order for ASYNC API to
work. This can be indicated by whether or not any LPUART node has the
`dmas` property set.
Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
r_sdhi_wait_for_event requires input timeout as us but the current
implemetation using timeout_ms instead
Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
Switch to using the new NXP_ENABLE_WAKEUP_SIGNAL and
NXP_DISABLE_WAKEUP_SIGNAL macros to avoid adding
platform specific calls in the Zephyr drivers.
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
The SDK code to handle managing Wakeup IRQ's for low power mode
varies between SoC's.
Add a MACRO that can be called by the Zephyr drivers so we
can manage these variations without adding SoC specific code
to the drivers.
Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
To preserve the previous logic, the watchdog must be disabled by default
using the dedicated Kconfig option.
Signed-off-by: Alexandre Rey <alx.rey@icloud.com>
Using WDT_DISABLE_AT_BOOT instead of WDOG_ENABLE_AT_BOOT prevents the
definition of z_arm_watchdog_init, which is important because the COP
watchdog configuration register can only be configured once.
Signed-off-by: Alexandre Rey <alx.rey@icloud.com>