Commit graph

18700 commits

Author SHA1 Message Date
Michał Barnaś 0b4365ef29 usbc: add support for TCPC control of vbus sourcing
Adds calls to the set_src_ctrl of TCPC driver to enable and disable
the VBUS sourcing. If the TCPC doesn't support these functions,
no errors should be printed.

Signed-off-by: Michał Barnaś <mb@semihalf.com>
2024-06-12 18:17:17 -04:00
Andries Kruithof a435dd3ee0 Bluetooth: Audio: CAP broadcast reception start bugfix
When validating the parameters for broadcast reception start some
return statements were missing, they have been added, as well as
proper initialisation of a variable

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2024-06-12 18:15:38 -04:00
Emil Gydesen 4c31e4b337 Bluetooth: BAP: Fix missing len increment when merging non-LC3 data
If we are merging subgroup and BIS codec configuration data
for a codec other than LC3, then we just append them, but
did not properly update the length.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-12 17:15:00 -05:00
Emil Gydesen be307f8ad9 Bluetooth: Audio: Change lang to 3-byte value from uint32_t
The 3-byte value suits the assigned number much better,
and also allows for less memory copies when getting and
setting the values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-12 12:54:16 -04:00
Emil Gydesen f08bc644a1 Bluetooth: Audio: Rename stream_lang to lang
Remove the "stream" part of the value and functions to
better fit with the name in the assigned numbers document.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-12 12:54:16 -04:00
Jonathan Rico 9b3f41de55 Bluetooth: host: don't pull data if no view bufs
View buffers are now also a limited resource. Acquire them before
attempting to pull data. `CONFIG_BT_CONN_FRAG_COUNT` should be tuned on
a per-application basis to avoid this.

A possible optimization, that was present before, is to not create a
frag when the original buffer fits the controller's HCI size.

I prefer deferring this optimization to a future patchset.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 5a7ef422bb Bluetooth: host: use __maybe_unused for convenience variables
In order to suppress compiler warnings w/o using void/ifdef.

Suggested in #72854

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico b6cdf10310 Bluetooth: L2CAP: remove seg_pool
We can get rid of the view pool for SDU segments :)
We have to make the code slightly more complex :'(

The basic idea is always giving the original SDU buffer to `conn.c` for it
to pull ACL fragments from.

In order to do this, we need to add the PDU headers just-in-time.
`bt_l2cap_send_pdu()` does not add them before putting the PDU on the queue
anymore. They are added by `l2cap_data_pull()` right before the data leaves
`l2cap.c` for `conn.c`.

We also have to inform `conn.c` "out of band" of the real L2CAP PDU size so
it doesn't fragment across segment boundaries. This oob is the new `length`
parameter to the `.pull()` method.

This is the added complexity mentioned above.

Since SDU segmentation concerns only LE-L2CAP, ISO and Classic L2CAP don't
need this extra logic.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 28be8909a6 Bluetooth: host: remove TX thread
We don't need the TX thread anymore.

Generalizing the pull-based architecture (ie. `tx_processor`) to HCI
commands makes it possible to run the whole TX path from the the system
workqueue, or any workqueue really.

There is an edge-case, where we call `bt_hci_cmd_send_sync()` from the
syswq, stalling the system. The proposed mitigation is to attempt to drain
the command queue from within `bt_hci_cmd_send_sync()`.

My spidey sense tingles however, and it would be better to just remove the
capability of calling this fn from the syswq. But doing this requires
refactoring a bunch of synchronous procedures in the stack (e.g. stack
init, connection establishment, address setting etc), dragging in more
work. I will do it, but in a later patch.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 48d1cffb4d Bluetooth: L2CAP: remove CONFIG_BT_L2CAP_RESCHED_MS
We don't need it thanks to the new TX architecture.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 38820efd8d Bluetooth: L2CAP: Make bt_l2cap_send_pdu()
This API replaces `bt_l2cap_send()` and `bt_l2cap_send_cb()`.

The difference is that it takes the `struct bt_l2cap_le_chan` object
directly instead of a connection + CID.

We need the channel object in order to put the PDU on the TX queue. It
is inefficient to do a search for every PDU when the caller knows the
channel object's address and can just pass it down.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 28535fe2f2 Bluetooth: host: Change TX pattern (push -> pull)
The current TX pattern in the host is to try to push a buffer through all
the layers up until it is ingested by the controller.

Since sending can fail at any layer, we need error-handling and separate
retry logic on pretty much all layers. That logic obscures the "happy path"
for people trying ot understand the code.

This commit inverts the control, in a way that doesn't require changing the
host or HCI driver API (yet):

Layers don't send buffers synchronously, they instead put their buffer in a
private queue of their own and raise a TX flag on the lower layer. Think of
it as a `READY` interrupt line that has to be serviced by the lower layer.

Sending is now non-blocking, rate depends on the size of buffer pools.

There is a single TX processing function. This can be thought as the
Interrupt Service Routine that will handle the `READY` interrupt from the
layers above.

That `tx_processor()` will then attempt to allocate enough resources in
order to send the buffer through to the controller. This allocation logic
does not block.

After acquiring all the resources, the TX processor will attempt to pull
data from the upper layer. The upper layer has to figure out which buffer
to pass to the controller. This is a good spot to put scheduling or QoS
logic in the upper layer.

Notes:

- user-facing API for tuning QoS will be implemented in a future patch

- this scheme could (and probably will) be extended to upper layers (e.g.
  ATT, L2CAP CoC segmentation).

- this patch removes the `pending_no_cb()` memory optimization for
  clarity/correctness. It might get re-implemented after a stabilization
  period. Hopefully with more documentation.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Jonathan Rico 1c8cae30a8 Bluetooth: host: Introduce "view" buffer concept
Instead of allocating segments/fragments and copying data into them, we
allocate segments as "views" (or slices) into the original buffer.

The view also gives access to the headroom of the original buffer, allowing
lower layers to push their headers.

We choose not to allow multiple views into the same buffer as the headroom
of a view would overlap with the data of the previous view.

We mark a buffer as locked (or "in-view") by temporarily setting its
headroom to zero. This effectively stops create_view because the requested
headroom is not available.

Each layer that does some kind of fragmentation and wants to use views for
that needs to maintain a buffer pool (bufsize 0, count = max views) and a
metadata array (size = max views) for the view mechanism to work.

Maximum number of views: number of parallel buffers from the upper layer,
e.g. number of L2CAP channels for L2CAP segmentation or number of ACL
connections for HCI fragmentation.

Reason for the change:
1. prevent deadlocks or (ATT/SMP) requests timing out
2. save time (zero-copy)
3. save memory (gets rid of frag pools)

L2CAP CoC: would either allocate from the `alloc_seg` application callback,
or worse _steal_ from the same pool, or allocate from the global ACL pool.

Conn/HCI: would either allocate from `frag_pool` or the global ACL pool.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Aleksander Wasaznik 52dc64f0d9 Bluetooth: conn: Allocate TX context JIT
`bt_conn_send_cb` used to allocate a TX context (K_FOREVER).
Instead, we now put the context in the userdata of the buffer.

This means that now this fn will never block and always succeed since the
tx_queue is a FIFO (infinite size). It just puts the buf on the queue.

The metadata is stored safely in there until we have acquired all the
necessary resources to send it to the controller without failing: TX
context and controller buffer.

I.e. when `bt_conn_process_tx` is called, that's when a TX context is
try-allocated and the contents of `buf->userdata` is moved into it.
The buffer is now ready to be sent to the lower layer.

`bt_conn_process_tx` will return -EWOULDBLOCK if it's not able to acquire a
TX context, this PR modifies `bt_conn_prepare_events` to respond to this by
also waiting on the TX context pool.

Unfortunately, this increases the required userdata size for any buffers
handed to `bt_conn_send_cb`. This will be fixed in a later commit.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2024-06-12 18:51:34 +02:00
Seppo Takalo 441d970417 net: lwm2m: Bypass send_queue when sending empty Ack
In case we want to immediately send empty Ack to server,
we should bypass all send queues.

This is required when we try to send Ack from callbacks
that happen from socket-loop context. On those cases
the Ack would have not been send because the callback
might be blocking the socket-loop while processing
a request (like write callbacks).

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-12 12:50:46 -04:00
Martí Bolívar b93fe6ad2d shell: device_service: print DT metadata
Example output on qemu_cortex_m3:

  devices:
  - uart@4000e000 (READY)
    DT node labels: uart2
  - uart@4000d000 (READY)
    DT node labels: uart1
  - uart@4000c000 (READY)
    DT node labels: uart0
  - gpio@40026000 (READY)
    DT node labels: gpio6
  - gpio@40025000 (READY)
    DT node labels: gpio5
  - gpio@40024000 (READY)
    DT node labels: gpio4
  - gpio@40007000 (READY)
    DT node labels: gpio3
  - gpio@40006000 (READY)
    DT node labels: gpio2
  - gpio@40005000 (READY)
    DT node labels: gpio1
  - gpio@40004000 (READY)
    DT node labels: gpio0

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
2024-06-12 18:49:54 +02:00
Yong Cong Sin 131e6bf494 logging: allow OOT backend to enable LOG_BACKEND_FORMAT_TIMESTAMP
The `LOG_BACKEND_FORMAT_TIMESTAMP` Kconfig currently depends on
a list of hardcoded backends.

Let's modify it to depend on an intermediary Kconfig
`LOG_BACKEND_SUPPORTS_FORMAT_TIMESTAMP` instead, which can be
selected by a OOT log backend.

Updated all exisitng supported backends to select this new
Kconfig.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-12 12:49:32 -04:00
Roman Studenikin fdd81f87c2 testsuite: coverage: Add CONFIG_ZTEST_COVERAGE_RESET_BEFORE_TESTS
Add an option to reset gcov counters before running tests.
This ensures that only code lines triggered by test itself are counted in
the coverage report and all the board initialization code and pre-test
bootstrap is not counted. This is useful when, for example, you are
testing code that is also executed during bootup

Test Plan:
west build -p always -b qemu_x86_64 tests/ztest/base/ -- \
-DCONFIG_COVERAGE=y -DCONFIG_COVERAGE_GCOV=y -DCONFIG_COVERAGE_DUMP=y \
-DCONFIG_ZTEST_COVERAGE_RESET_BEFORE_TESTS=y
ninja -Cbuild run | tee log.log

Signed-off-by: Roman Studenikin <srv@meta.com>
2024-06-12 14:32:04 +03:00
Roman Studenikin 179585e54b testsuite: coveerage: support counters reset
Ability to reset gcov counters allows better isolation of tests
coverage. Specifically it allows to:
1. Not include counters for any code that was executed prior running the
   test, which includes all the code executed during the board boot.
2. Run multiple tests without firmware reload by resetting counters
   between each.

Signed-off-by: Roman Studenikin <srv@meta.com>
2024-06-12 14:32:04 +03:00
Johann Fischer ed8c99977f usb: device: allow uneven SN to be obtained from HWINFO
If the length of the string literal reserved for the serial number
descriptor is odd, the string is not used because its length is always
even and therefore one character longer. Fix this by using the shortest
length for the copy.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-06-12 14:31:11 +03:00
frei tycho 5d1be67e83 shell: change controlling expressions in while to Boolean
Use `do { ... } while (false)` instead of `do { ... } while (0)`.

Signed-off-by: frei tycho <tfrei@baumer.com>
2024-06-12 14:22:36 +03:00
Johan Hedberg bf363d7c3e Bluetooth: Host: Avoid processing "no change" encryption changes
If the new encryption state is the same as the old one, there's no point in
doing additional processing or callbacks. Simply log a warning and ignore
the HCI event in such a case.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2024-06-11 19:45:09 -04:00
Johan Hedberg af750cd5a6 Bluetooth: Use device tree to indicate vendor exension support
Introduce a new bt-hci-vs-ext device tree boolean property to indicate
device tree support.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg 589b92baaf Bluetooth: Kconfig: Remove BT_NO_DRIVER
There are no actual users in the main tree anymore, so just remove this
option.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg 97c3a1e4be Bluetooth: drivers: hci: Get rid of Kconfig choice
The drivers should be independent after the move to the new HCI driver
API. Having them as a choice also has unexpected consequences with some
drivers being unexpectedly enabled.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg f8befbd67a Bluetooth: host: hci_raw: Use existing H4 defines from hci_types.h
Use existing defines instead of redefining our own.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg 44e0f5fee3 Bluetooth: controller: Update to new HCI driver API
Update the native controller to the new HCI driver API. The devicetree
node is placed under existing `radio` nodes, which seemed like the most
intuitive option.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
Johan Hedberg dcff0be792 Bluetooth: host: Add support for new-style HCI drivers
Add support for HCI drivers which use the newly defined HCI driver API.
Since Zephyr (currently) only supports a single HCI driver instance,
boards are expected to indicate the instance using a new devicetree
chosen property `zephyr,bt_hci`.

In order to maintain compatibility with not-yet-converted drivers the
code has been placed behind `#if DT_HAS_CHOSEN(zephyr_bt_hci)`
conditionals.

Signed-off-by: Johan Hedberg <johan.hedberg@gmail.com>
2024-06-11 19:42:49 -04:00
frei tycho 382670690c net: change controlling expressions in while to Boolean
Use `do { ... } while (false)` instead of `do { ... } while (0)`.

Signed-off-by: frei tycho <tfrei@baumer.com>
2024-06-11 20:03:16 +03:00
frei tycho ac8620c791 tracing: change controlling expressions in while to Boolean
Use `do { ... } while (false)` instead of `do { ... } while (0)`.

Signed-off-by: frei tycho <tfrei@baumer.com>
2024-06-11 20:02:40 +03:00
Rubin Gerritsen 9cf6839b18 Bluetooth: Host: Allow conn create timeout longer than RPA timeout
https://github.com/zephyrproject-rtos/zephyr/pull/72674 fixed
a bug where this configuration did not work.

Now that this configuration is tested, we should mark it
as supported.

The timeout check that was present in the code before
was useless and was not working because the check was
run before a default timeout of 0 was converted to a timeout.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-11 16:17:46 +02:00
Troels Nilsson bed717e2a5 Bluetooth: Controller: Refactor of ull_adv_sync_pdu_set_clear()
ull_adv_sync_pdu_set_clear does pretty much everything, causing
it to be very complex and awkward to use. In addition, it only handles
a single PDU, meaning callers have to handle the chain.
It has been replaced with simpler, more complete functions for handling
the relevant operations

Fixed issues include:

- Fragmentation of adv data over HCI is now decoupled from PDU
  fragmentation, fixing HCI/DDI/BI-13-C, LL/DDI/ADV/BV-26-C and
  LL/DDI/ADV/BV-55-C
- Adding BigInfo now preserves the PDU chain
- Enabling periodic advertising with ADI on would sometimes fail
  due to insufficient space in a single PDU to add ADI

Signed-off-by: Troels Nilsson <trnn@demant.com>
2024-06-11 16:38:05 +03:00
Alberto Escolar Piedras e34f29f9ea subsys/portability/CMSIS: Do not redefine TRUE & FALSE
These macros tend to be defined by too many headers.
Let's guard these definition with ifdefs to avoid
redefining them to practically the same.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-11 16:29:22 +03:00
Lucas Romero cad56e8005 lorawan: services: frag decoder: add lowmem implementation
that utilizes the fact that the ldpc recovery matrix is triangular and only
stores the half with non-zero values.

This implementation is hopefully going to make forward error correction
usable on lower memory devices.

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-06-11 16:09:23 +03:00
Lucas Romero 69c5ef9665 lorawan: services: frag transport: prepare for pluggable decoder
by wrapping decoder implementation specific bits in #ifdefs

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-06-11 16:09:23 +03:00
Lucas Romero ff906974b8 lorawan: services: frag transport: refactor status
to no longer be a long-lived status variable because we already map it into
is_active and this reduces the number of states the transport can be in.

It also helps us prepare for being able to plug in more decoders by
removing implementation specific bits from the general transport interface.

Signed-off-by: Lucas Romero <luqasn@gmail.com>
2024-06-11 16:09:23 +03:00
Rubin Gerritsen a35d5e7851 ztest: Add macros for comparing strings
These macros allows us to compare strings in a simpler way.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-11 11:39:36 +01:00
Bjarki Arge Andreasen 1f7d0b6cb0 modem: add modem_pipelink module
Add modem pipelink module which exposes modem pipes globally.
The pipelink module implements a callback to inform when a
pipe becomes available to use by whichever modem is attached
to it. This could be a shell, or a network interface.

The module aims to allow modem drivers to be split into modules,
and allowing applications to implement their own custom logic
without altering the modem drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-06-10 15:12:34 -05:00
Jukka Rissanen 7bb4013d8e net: tracing: Add socket tracing support
If network socket tracing is enabled, then the system will track
various socket API calls for usage.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-10 15:03:20 -05:00
Fin Maaß 54cb89b8d7 tracing: fix k_realloc trace functions
fix wrong amount of arguments for
k_realloc trace functions.

fixes #73996

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-06-10 14:54:49 -05:00
Daniel Nejezchleb d6ed91795d net: tcp: Fix context leak during connect
Replaced tcp_out() with tcp_out_ext() when sending
SYN during tcp connect, so we can intercept error value,
beacuse in such case the packet would not be sent at all
and the stack would not trigger any mechanism to flush
this context so it ends up leaking. These scenarios can
arise when the underlaying interface is not properly
configured or is disconnected. The conn is marked to be
closed and is closed before exiting tcp_in().
Since we can now identify this case we can also exit
early in the net_tcp_connect() function and not wait
for any timeout.

Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
2024-06-10 16:56:39 +03:00
Piotr Koziar e66b382639 ipc: fix return code of icbmsg backend send operation.
This commit fixes the issue where a serialization
error was reported after properly sending a data with 'icbmsg' backend.

The icbmsg send function's return code is set to
the sent data's len as in other backends.
The related docs were fixed and updated.

Signed-off-by: Piotr Koziar <piotr.koziar@nordicsemi.no>
2024-06-10 15:00:01 +03:00
Georges Oates_Larsen 7fa6b53ac3 net: shell: Add IPv4 and IPv6 connectivity events
Add descriptions for recently introduced IPv4 and IPv6
connectivity events to the net event monitor.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Georges Oates_Larsen 85c4cb9265 net: conn_mgr: Add IPv4 and IPv6 tracking
conn_mgr now fires:

- NET_EVENT_L4_IPV4_CONNECTED
- NET_EVENT_L4_IPV4_DISCONNECTED
- NET_EVENT_L4_IPV6_CONNECTED
- NET_EVENT_L4_IPV6_DISCONNECTED

These events track whether there are any ready ifaces offering
specifically IPv4 or specifically IPv6 connectivity.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Georges Oates_Larsen 32ae816d0b net: conn_mgr: Simplify blame handling
Don't track up/down blame separately.
Instead, track a single last-blame iface.

Don't track blame iface inside set_ready.
Instead, track directly inside handle_update.

These two changes will simplify the addition
of blame for IPv4- and IPv6-specific events.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Georges Oates_Larsen 875755fbb2 net: conn_mgr: Track ready count ephemerally
Instead of incrementing and decrementing global counter,
just recompute the ready-count from scratch every time
conn_mgr_mon_handle_update is called.

This will simplify the introduction of additional ready count types.

This should have no externally observable impact on the behavior of
conn_mgr.

Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
2024-06-10 00:59:34 -07:00
Robert Lubos 3501d6e6d4 net: shell: ipv4: Add information about ACD
Print information in IPv4 shell whether address conflict detection is
enabled or not.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos c0161c8052 net: l2: ethernet: arp: Simplify ACD case
In case of ACD Probe/Announcement, all we need is to generate ARP
packet, we don't really want any cache entries to be created or searched
for. There was a bug, that a cache entry was created for the
Announcement sent, resulting in skipped ARP packet generation and
malformed packet being sent by the ACD module.

Therefore, simplify all this, by simply returning early in case of
conflict detection packets.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos cc53826cc9 net: ipv4: autoconf: Integrate with the ACD module
The autoconf module can now reuse generic address conflict detection,
which was added for all address types.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 80339ac4ee net: dhcpv4: Add support for conflict detection
In case a conflict was detected on a DHCP-assigned address, send a
Decline message to the server and start over.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 7352aaa841 net: config: Add support for IPv4 ACD
In case IPv4 conflict detection is enabled, monitor network events to
determine whether IPv4 address is ready to use or not, so that the
library returns only after the network setup is fully complete.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos c281db0f7e net: conn_mgr: Add support for ACD events
Connection manager needs to monitor ACD events as well to determine
whether a preferred IPv4 address is available.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos a89dd1a6f6 net: shell: Add ACD events to the event monitor
Include new ACD events in the shell event monitor.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Robert Lubos 0a95423421 net: ipv4: Implement IPv4 address conflict detection
Add support for IPv4 conflict detection, as specified in RFC 5227.
The new feature is optional and disabled by default.

Address conflict detection was implemented as a part of the IPv4
autoconf feature can be generalized to be available for all address
types.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-06-10 00:59:28 -07:00
Rodrigo Peixoto 453ab8a9a3 zbus: vded: msg_sub: Improve channel ref copy
The VDED was adding the channel information per clone. But it could be
done in the original buffer. This commit fixes that by adding the
channel information to the original buffer and not for each clone. As a
result, we have a more straightforward VDED execution with fewer copies.

Signed-off-by: Rodrigo Peixoto <rodrigopex@gmail.com>
2024-06-09 09:07:21 -05:00
Flavio Ceolin 73b755d817 pm: Add a symbol for device power state constraints
Add a symbol to enable device power state constraints this
saves resources when this feature is not needed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-07 19:06:23 -04:00
Flavio Ceolin 02a14d75fc pm: Declare pm state constraints for a device
Declare power state constraints for a device in devicetree.
It allows a map between device instances and power states that disable
their power. This information is used by a new API
(pm_policy_device_power_lock_put/get) that automically set/release
pm state constraints.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-07 19:06:23 -04:00
Daniel DeGrasse 7981ea0056 fs: fat_fs: make IOCTL call to de-initialize disk in fatfs_unmount()
Make call to de-initialize disk in fatfs_unmount(). This will permit the
disk to be reinitialized when it is mounted with fatfs_mount().

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse d18cbb60b2 drivers: disk: add DISK_IOCTL_CTRL_DEINIT command to supported IOCTLs
Add DISK_IOCTL_CTRL_DEINIT ioctl command to disk subsystem. When
disk_access_ioctl() is called with this command, the disk will be
de-initialized. After this IOCTL completes, the disk can safely be
reinitialized.

Fixes #60628

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse fb2d5c338b drivers: disk: add DISK_IOCTL_CTRL_INIT macro to initialize a disk
Add DISK_IOCTL_CTRL_INIT IOCTL to initialize a disk. This IOCTL is
intended to replace disk_access_init() for new applications, but
disk_access_init() is kept for legacy compatibility. The INIT IOCTL is
added to better match the path that will be used for disk
de-initialization. Like the disk_access_init() calls,
DISK_IOCTL_CTRL_INIT calls are reference counted

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Daniel DeGrasse 3386a43a51 disk_access: reference count initialization calls for disks
Reference count initialization calls for disks. This changes the
behavior of the disk_access_init() function, such that disks will no
longer be initialized again if the first disk access init call
succeeds.

Disk access is reference counted in preparation for supporting disk
de-initialization, where a balanced number of disk de-initialization
calls with disk initialization calls will de-initialize the disk.

Also, remove code in disk drivers that was already checking against
duplicate disk_access_init() calls.

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-06-07 18:16:01 +01:00
Krzysztof Chruściński 8f3989412f testsuite: ztest: ztress: Add missing static keywords
Add static to local timers definition.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-06-07 18:08:22 +01:00
Luca Burelli 1a2f6ae381 llext: refact: move ELF loading and linking to separate files
This commit moves ELF loading and linking code to separate files. This
is done to make the code more manageable and to make it easier to add
new features in the future.

No functional changes are introduced by this commit, except for a few
static functions now made public to allow this file split to occur.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli 9c5412f79e llext: refact: move memory code to llext_mem.c
Move all memory management code to a separate file, llext_mem.c, to
allow for better separation of concerns and to make the code more
readable.

No functional changes are introduced by this commit.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli 35ef089cb1 llext: move basic ELF checks to llext_load_elf_data()
This patch moves the initial checks performed on the ELF file, that were
split between llext_load() and do_llext_load(), to the newly defined
llext_load_elf_data() function.

This way:

- only one function deals with ELF internal data checks;
- do_llext_load() is reduced to a list of tasks;
- llext_load() only focuses on the extension management.

One totally misplaced line initializing the number of symbols has been
moved to llext_count_export_syms().

No functional change except that the `struct llext` allocation may be
performed unnecessarily if the ELF file is not valid.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Luca Burelli cefeae0048 llext: add llext heap management functions
Add llext_alloc(), llext_aligned_alloc() and llext_free() wrapper
functions to manage memory allocation and deallocation from the llext
heap. Also add a helper to free all memory regions allocated by an
extension.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-07 18:07:53 +01:00
Alberto Escolar Piedras 510e1ba6af Bluetooth: Controller: Treat nrf54l15bsim like a real platform
Use the compatible kconfig option so that for the simulated
nRF54L15 we build the same code as for the real platform.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Alberto Escolar Piedras a3218b0de5 Bluetooth: Controller: Fix BT_CTLR_DATA_LEN_UPDATE_SUPPORT selection
For the Nordic HW, the BT_CTLR_DATA_LEN_UPDATE_SUPPORT
does not require CCM HW enabled, hence support Data Length
Update if Encryption Support is disabled.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Alberto Escolar Piedras 35773882c2 Bluetooth: Controller: Use HAL to modify renamed registers in nRF54
In some nRF54 devices, DATAWHITEIV was renamed to
DATAWHITE,
and the CRCCNF SKIADDR field was renamed OFFSET.
The nrf HAL hid this change internally,
so let's use it so we don't need to ifdef these
in the Bluetooth Controller HAL code.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada f59c3fafe8 Bluetooth: Controller: Preliminary support for nRF54L15 SoC
Add preliminary support for nRF54L15 SoC. This commit does
not support Controller Random Number Generation and
Controller Cryptography (AES-128 encryption) commands, nor
does it support encrypted connections.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 0bbbef3a8c Bluetooth: Controller: Use NRF_RTC and RADIO_SHORTS_TRX_END_DISABLE_Msk
Use NRF_RTC and NRF_RADIO_SHORTS_TRX_END_DISABLE_Msk instead
to prepare towards using configurable use of RTC and Radio
hardware defines.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada d6f2bc9669 Bluetooth: Controller: Add explicit LLCP error code check
Add unit tests to cover explicit LLCP error code check and
cover the same in the Controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 78466c8f52 Bluetooth: Controller: Use BT_HCI_ERR_UNSPECIFIED as needed
A Host shall consider any error code that it does not
explicitly understand equivalent to the error code
Unspecified Error (0x1F).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada fe205a598e Bluetooth: Controller: Refactor BT_CTLR_LE_ENC implementation
Refactor reused function in BT_CTLR_LE_ENC feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 2d49080cb8 Bluetooth: Controller: Fix BT_CTLR_LE_ENC conditional compilation
Fix BT_CTLR_LE_ENC conditional compilation when feature is
disabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada a66baa1101 Bluetooth: Controller: Introduce BT_CTLR_CRYPTO_SUPPORT
Introduce BT_CTLR_CRYPTO_SUPPORT so that preliminary port to
support nRF54L15 SoC can be upstreamed without encryption
support.

ENTROPY_GENERATOR now selected when BT_CTLR_CRYPTO enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Vinayak Kariappa Chettimada 073e627e3b Bluetooth: Controller: Fix ENTROPY_NRF5_RNG conditional compile
Fix ENTROPY_NRF5_RNG conditional compile when not enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-06-07 18:07:48 +01:00
Fin Maaß e1246ccb65 mgmt: hawkbit: some Kconfig improvements
some hawkbit Kconfig improvements.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-06-07 18:06:45 +01:00
Siddharth Chandrasekaran 45085ba647 mgmt/osdp: cp: disallow unexpected SC responses
When CP has a secure channel active, it should never receive a
REPLY_CCRYPT or REPLY_RMAC_I. Since these responses change the SC state,
let's also make sure that they are accepted only when they are
expected: in response to commands CMD_CHLNG and CMD_SCRYPT respectively.

Reported-by: Eran Jacob <eran.jacob@otorio.com>
Signed-off-by: Siddharth Chandrasekaran <sidcha.dev@gmail.com>
2024-06-07 16:47:55 +03:00
Sean Madigan 0b327db097 Bluetooth: Add support for Path Loss Monitoring feature
This commit adds host support for the Path Loss Monitoring
feature see Bluetooth Core specification, Version 5.4,
Vol 6, Part B, Section 4.6.32.

Limited logic is required, just adding a wrapper around the
HCI command and callback for HCI event.

Add new zone - BT_CONN_LE_PATH_LOSS_ZONE_UNAVAILABLE, to
convert 0xFF path loss to a useful zone.

Add new Kconfigs and functionality to the bt shell.

Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
2024-06-07 15:04:11 +02:00
Emil Gydesen 5c9032019c Bluetooth: CAP: Fix linker issue in cap_stream.c for x86
The existing code in the cap_stream.c that handled the
check before calling CAP initiator unicast functions
seemingly did not work for x86 targets such as native_sim
or native_posix.

Modified the check so that IS_ENABLED is used directly.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-07 13:01:13 +02:00
Pisit Sawangvonganan aca97a0bef fs: fcb: refactor fcb_get_len() for improved readability
Introduced temporary variables `buf0_xor` and `buf1_xor` to store
XOR results and added an explicit cast to `uint16_t` for
the `*len` variable.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-07 09:53:56 +02:00
Pisit Sawangvonganan 06177833d8 fs: fcb: correct FCB_MAX_LEN boundary condition
Correct the boundary condition in `fcb_put_len` function to
properly include `FCB_MAX_LEN` and change the #define to address
the potential flaw where `CHAR_MAX` might be treated as unsigned by
the compiler flag `-funsigned-char`, which would yield `FCB_MAX_LEN`
to 0x7fff instead of 0x3fff.

Fixes #73868

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-06-07 09:53:56 +02:00
Tom Burdick 87fc25afc1 sensing: Fix build warning on invalid array index
The assert was verifying that the current sensor address was greater
or equal than the start of the iterable section - 1 which isn't quite
right as the start is inclusive.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-07 09:52:09 +02:00
Jordan Yates dc5f27395f testsuite: add dependency to COVERAGE_GCOV_HEAP_SIZE
Add missing dependency on `COVERAGE_GCOV` to prevent the symbol from
appearing in every application.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-06 20:07:20 -04:00
Tom Burdick d95caa51a4 sys: Add a lockfree mpsc and spsc queues
Moves the rtio_ prefixed lockfree queues to sys alongside existing
mpsc/spsc pbuf, ringbuf, and similar queue-like data structures.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2024-06-06 00:42:29 -07:00
Balaji Srinivasan 16fc8f5295 task_wdt: Feed hardware watchdog only when its started
Previously the schedule_next_timeout() function was feeding the hardware
watchdog irrespective of whether or not it was started. This is now
fixed.

Signed-off-by: Balaji Srinivasan <balaji.srinivasan@nordicsemi.no>
2024-06-06 00:40:53 -07:00
Anas Nashif 584a99f6ab tracing: add missing calls for k_wakeup/k_thread_user_mode_enter
Add missing hooks for k_wakeup/k_thread_user_mode_enter to CTF backend.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2024-06-05 17:38:22 -05:00
Alberto Escolar Piedras c9491a818f Bluetooth: Controller: Correct power levels for bsim targets
The simulated targets support the same power levels as the
real targets. Let's correct the kconfig dependencies
accordingly.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-06-05 17:36:57 -05:00
Seppo Takalo d3081e2f30 net: lwm2m: On write, use server selected block size
When we receive CoAP packets, it is in input buffer
that is size of NET_IPV6_MTU.
So in reality, we can handle bigger Block-Wise writes
than CONFIG_LWM2M_COAP_BLOCK_SIZE.

So if parsing of CoAP packet has passed, continue
with the same block-size instead of going to default.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-05 14:43:14 +01:00
Yong Cong Sin 3cb2c04fc1 subsys/debug: relocate symtab Kconfig
Move the symtab Kcofig into the symtab folder.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 22:36:51 -04:00
Yong Cong Sin 9d9576b442 subsys/debug: relocate gdbstub stuff into its folder
Move the gdbstub files into the gdbstub folder, and relocated
its Kconfig as well.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 22:36:51 -04:00
Flavio Ceolin 1c2e988021 pm: device: De-couple device pm from system pm
PM_DEVICE is not attached to system managed device power management.
It is a very common use case targets with device runtime power
management that don't want system device power management enabled.

We introduce a new symbol (PM_DEVICE_SYSTEM_MANAGED) to explicit
control whether or not system device power management should be
globally enabled.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin c65be0cfb9 pm: Exclude device pm path when it is not needed
Remove device pm path when there is no is no power state in DT with
device pm enabled. This basically does the same thing that was done
by PM_DEVICE_RUNTIME_EXCLUSIVE.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin 2f99ff51cc pm: Disable device pm per power state
Make it possible to disble device power management individually per
power state.  This allows targets tuning which states should
(and which should not) trigger device power management.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Flavio Ceolin 94af630b22 pm: Deprecate PM_DEVICE_RUNTIME_EXCLUSIVE
That is option has shown confusing on it is attempt to prevent
system pm doing device power management. Lets address this
problem properly.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2024-06-04 19:13:53 -04:00
Chris Friedt 0fa97326c7 posix: create kconfig options for pse51, pse52, pse53
Create Kconfig "shortcuts" for PSE51, PSE52, and PSE53.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 487a8756c3 posix: eventfd: fix dependency cycle between net and posix
Until recently, the posix api was purely a consumer of the
network subsystem. However, a dependency cycle was added as
a stop-gap solution for challenges with the native platform.

Specifically,

1. eventfd symbols conflict with those of the host
2. eventfd was excluded from native libc builds via cmake

If any part of the posix were then to select the network
subsystem (which is a legitimate use case, given that networking
is a part of the posix api), we would get a build error due to
the Kconfig dependency cycle.

As usual, with dependency cycles, the cycle can be broken
via a third, mutual dependency.

What is the third mutual dependency? Naturally, it is ZVFS
which was planned some time ago. ZVFS will be where we
collect file-descriptor and FILE-pointer APIs so that we can
ensure consistency for Zephyr users.

This change deprecates EVENTFD_MAX in favour of
ZVFS_EVENTFD_MAX.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 2bc722a97e posix: deprecate POSIX_FNMATCH GETOPT GETENTROPY
The functions fnmatch(), getopt(), getentropy()
and others are grouped into the standard Option Group
POSIX_C_LIB_EXT.

The getentropy() function is currently in-draft for
Issue 8 as of 2021.

https://www.opengroup.org/austin/docs/austin_1110.pdf

Not surprisingly, the POSIX_C_LIB_EXT Option Group
also includes the highly debated strnlen() function.

Moving that function will be deferred until later.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt bc4374b5fe posix: deprecate POSIX_MAX_FDS and add POSIX_DEVICE_IO
The POSIX_MAX_FDS option does not correspond to any standard
POSIX option. It was used to define the size of the file
descriptor table, which is by no means exclusively used by
POSIX (also net, fs, ...).

POSIX_MAX_FDS is being deprecated in order to ensure that
Zephyr's POSIX Kconfig variables correspond to those defined in
the specification, as of IEEE 1003.1-2017. Namely,
POSIX_OPEN_MAX. CONFIG_POSIX_MAX_OPEN_FILES is being deprecated
for the same reason.

To mitigate any possible layering violations, that option is
not user selectable. It tracks the newly added
CONFIG_ZVFS_OPEN_MAX option, which is native to Zephyr.

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_DEVICE_IO

Similarly, with this deprecation, we introduce the following
Kconfig options that map directly to standard POSIX Options by
simply removing "CONFIG":

* CONFIG_POSIX_OPEN_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options.

* CONFIG_POSIX_DEVICE_IO_ALIAS_CLOSE
* CONFIG_POSIX_DEVICE_IO_ALIAS_OPEN
* CONFIG_POSIX_DEVICE_IO_ALIAS_READ
* CONFIG_POSIX_DEVICE_IO_ALIAS_WRITE

Gate open(), close(), read(), and write() via the
CONFIG_POSIX_DEVICE_IO Kconfig option and move
implementations into device_io.c, to be conformant with the
spec.

Lastly, stage function names for upcoming ZVFS work, to be
completed as part of the LTSv3 Roadmap (e.g. zvfs_open(), ..).

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Chris Friedt 4a5c4e5f73 posix: timers: deprecate CONFIG_POSIX_CLOCK and TIMER
The POSIX_CLOCK option does not correspond to any standard
option. It was used to active features of several distinct
POSIX Options and Option Groups, which complicated API and
application configuration as a result.

POSIX_CLOCK is being deprecated in order to ensure that Zephyr's
POSIX Kconfig variables correspond to those defined in the
specification, as of IEEE 1003.1-2017.

Additionally, CONFIG_TIMER is being deprecated because it does
not match the corresponding POSIX Option (_POSIX_TIMERS).

With this deprecation, we introduce the following Kconfig
options that map directly to standard POSIX Option Groups by
simply removing "CONFIG_":

* CONFIG_POSIX_TIMERS

Similarly, we introduce the following Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_POSIX_CLOCK_SELECTION
* CONFIG_POSIX_CPUTIME
* CONFIG_POSIX_DELAYTIMER_MAX
* CONFIG_POSIX_MONOTONIC_CLOCK
* CONFIG_POSIX_TIMEOUTS
* CONFIG_POSIX_TIMER_MAX

In order to maintain parity with the current feature set, we
introduce the following Kconfig options that map directly to
standard POSIX Option Groups by simply removing "CONFIG_":

* CONFIG_POSIX_MULTI_PROCESS - sleep()

Similarly, in order to maintain parity with the current feature
set, we introduce the following additional Kconfig options that
map directly to standard POSIX Options by simply removing
"CONFIG":

* CONFIG_XSI_SINGLE_PROCESS - gettimeofday()

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
2024-06-04 16:27:12 -05:00
Yong Cong Sin e54b27b967 arch: define struct arch_esf and deprecate z_arch_esf_t
Make `struct arch_esf` compulsory for all architectures by
declaring it in the `arch_interface.h` header.

After this commit, the named struct `z_arch_esf_t` is only used
internally to generate offsets, and is slated to be removed
from the `arch_interface.h` header in the future.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
Yong Cong Sin 3998e18ec4 arch: rename all esf struct to struct arch_esf
Rename every architecture's esf struct to `struct esf`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-04 14:02:51 -05:00
Anders Storrø cee8080117 Bluetooth: Mesh: Fix PB GATT adv name
Fixes issue where PB GATT Server will drop
advertising device name if optional provisioning
URI is not provided.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2024-06-04 05:18:28 -07:00
Vivekananda Uppunda ca19e6bbaa net: wifi_shell: Resolve filter settings mismatch
The control and data settings are set improperly for packet filter
operation for sniffer operation. The change sets them properly.

Signed-off-by: Vivekananda Uppunda <vivekananda.uppunda@nordicsemi.no>
2024-06-04 13:46:37 +02:00
Emil Gydesen ebadb11645 Bluetooth: Audio: Spring cleaning
Adds, removes and modifies includes in all LE audio
files.

Fixes any found spelling mistakes as well.

Fixes a few places where incorrect types were used.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-04 13:37:53 +02:00
Jens Rehhoff Thomsen 06bb9f258a Bluetooth: BAP: Shell: Add endpoint state info
The bap list command now also shows the states of each endpoint.

Fixes #70838

Signed-off-by: Jens Rehhoff Thomsen <jthm@demant.com>
2024-06-04 13:37:39 +02:00
Luca Burelli 709b2e44bf llext: automatically merge sections by type
This patch changes the way sections are mapped to memories. Instead of
looking at the section name, each section in the ELF file is mapped to
the llext_mem enum by looking at the section type and flags.

This allows for a more generic mapping that works for both the ARM and
Xtensa cases, and also allows for sections to be merged if they are
contiguous and non-overlapping in the ELF file.

This patch also fixes a number of corner cases, such as in the logging
test where a section with read-only data was being ignored (not copied
and not relinked).

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-06-04 13:37:22 +02:00
Dominik Ermel c4c7e15ba1 dfu/mcuboot: Use flash_area_flatten instead of flash_area_erase
The invocation of flash_area_erase, in boot_erase_img_bank,
has been replaced by flash_area_flatten.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel bce06a64c4 mgmt/mcumgr: Replace use of flash_area_erase with flash_area_flatten
The commit replaces flash_area_erase with flash_area_flatten.
The function is used in to places:
 1) in image management commands IMG_MGMT_ID_UPLOAD
    and IMG_MGMT_ID_ERASE: to erase an image in secondary slot
    or to scramble trailer part of image, which could be misunderstood
    by MCUboot as valid image operation request;
 2) in command ZEPHYR_MGMT_GRP_BASIC_CMD_ERASE_STORAGE to
    erase/scramble data partition.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 95dfd1210d storage/stream_flash: Support for devices without explicit erase
Support for devices not requiring erase with Stream Flash API.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel bf7d25117a fs/nvs: Switch to use flash_flatten instead of flash_erase
The NVS currently requires explict erase capability of
a device to work, so usage of flash_erase has been replaced
with flash_flatten.
There has been additional LOG_WRN added to warn user that
NVS may not efficiently work with device that do not really
have erase.

Currently NVS relies on devices that require erase.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 64ccfb0479 fs/fcb: Replace flash_area_erase with flash_area_flatten
FCB depends on explicit erase characteristics of a device.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 9da26eda5e fs/littlefs: Use flash_area_flatten in lfs_api_erase
LittleFS is based on program-erase devices and require that
characteristics to work; the commit replaces flash_area_erase
with flash_area_flatten to allow LFS work on devices that
do not provide erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 743d66a7e5 debug/coredump/flash_backend: Switch to flash_area_flatten
Replace usage of flash_area_erase with flash_area_flatten to
allow code to work with devices that do not provide erase
callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel def4f060c1 storage/settings: Replace flash_area_erase with flash_area_flatten
Replace flash_area_erase with flash_area_flatten to allow FCB
Settings backend to work on devices that do not provide erase
callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel 5da7df4e7c Bluetooth: Mesh: Switch erase to flash_area_flatten
The flash_area_erase has been replaced with flash_area_flatten,
allowing code to work with devices that do not provide
erase callback.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Dominik Ermel a5f7ceff81 storage/flash_map: Add flash_area_flatten
Add equivalent of flash_erase, from Flash API, to Flash Map API;
idea is the same: function tries to erase area if driver provides
erase function, otherwise writes erase_value across the defined
area.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2024-06-04 08:00:46 +02:00
Johann Fischer af63e488f0 usb: device_next: hid: fix Get Report buffer handling
After the get_report() callback, we need to determine how many bytes the
HID device wrote to the report buffer. Use the callback return value to
do this, and modify the net_buf data length value if get_report was
successful.

Reported-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2024-06-04 07:56:45 +02:00
alperen sener c93859c659 bluetooth: mesh: fix lpn receive window timing error
APIs for enabling and disabling the scanner may take larger time than
expected and scheduling of the lpn state machine is affected by it.
Since these type of latencies are factored into timeouts and scheduling
times, we need to call scan enable/disable APIs after scheduling the
next event time for LPN state machine to be more accurate.

Signed-off-by: alperen sener <alperen.sener@nordicsemi.no>
2024-06-04 07:55:59 +02:00
Marek Pieta 059643062c usb: device_next: Update remote wakeup log level
The `Remote wakeup feature not enabled or not suspended` log is not
related to an actual error (connected host might not enable USB remote
wakeup feature). Use warning log level.

Signed-off-by: Marek Pieta <Marek.Pieta@nordicsemi.no>
2024-06-04 07:55:22 +02:00
Valerio Setti 4fc6506a8a random: enable AES support CTR_DRBG CSPRNG when it relies on Mbed TLS
PR #72475 disabled default enabling of many Mbed TLS features
including AES. This means that now it must be explicitly added
when required.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-03 16:13:05 -04:00
Hess Nathan aaec285cd5 coding guidelines: comply with MISRA Rule 12.1.
-added parentheses verifying lack of ambiguities

Signed-off-by: Hess Nathan <nhess@baumer.com>
2024-06-03 16:10:33 -04:00
Mathieu Choplain 8aa6ae43ce llext: add support for SLID-based linking
This commit introduces support for an alternate linking method in the
LLEXT subsystem, called "SLID" (short for Symbol Link Identifier),
enabled by the CONFIG_LLEXT_EXPORT_BUILTINS_BY_SLID Kconfig option.

SLID-based linking uses a unique identifier (integer) to identify
exported symbols, instead of using the symbol name as done currently.
This approach provides several benefits:
 * linking is faster because the comparison operation to determine
   whether we found the correct symbol in the export table is now an
   integer compare, instead of a string compare
 * binary size is reduced as symbol names can be dropped from the binary
 * confidentiality is improved as a side-effect, as symbol names are no
   longer present in the binary

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-06-03 15:29:34 -04:00
Joel Guittet 05ad2565fa llext: add _POSIX_C_SOURCE definition to build shell
Fix implicit-function-declaration warning while building the llext shell.

Signed-off-by: Joel Guittet <joelguittet@gmail.com>
2024-06-03 15:28:33 -04:00
Emil Gydesen 92002b2dff Bluetooth: CAP: Implement bt_cap_initiator_unregister_cb
Implement function to unregisterd the CAP initiator callbacks.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 15:28:05 -04:00
Tomasz Moń 8d344cc9d8 usb: device_next: Rename usbd_contex to usbd_context
Add the missing "t" to struct usbd_contex. No functional changes.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-06-03 06:43:20 -07:00
Emil Gydesen d2fbeffaa9 Bluetooth: BAP: Unicast client Split start and connect
Removes the CIS connection establishment from bt_bap_stream_start
and move the behavior to a new funciton bt_bap_stream_connect.

This has 2 advantages:
1) The behavior of bt_bap_stream_start is much more clear and more aligned
with the spec's behavior for the receiver start ready opcode.
2) It is possible to connect streams in both the enabling
and the QoS configured state with bt_bap_stream_connect as
per the spec. This allows us to pass additional PTS test cases.

To implement this new behavior, samples and tests have been updated.

The CAP Initiator implementation has also been updated
to accomodate for the change in BAP, but the CAP
initiator implementation should work the same for application, except
that it's now possible to do unicast start on ASEs in any order
(https://github.com/zephyrproject-rtos/zephyr/issues/72138).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 15:42:33 +02:00
Rubin Gerritsen 3609d97c95 Bluetooth: Document reasons for HCI command timeouts
When reading the error message:
"ASSERTION_FAIL: command opcode 0x0c03 timeout with err -11" it may not be
obvious what is wrong with their setup unless you are very familiar
with HCI.

This commit adds some more documentation to make this more obvious.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-06-03 15:39:23 +02:00
Jukka Rissanen a124dd2596 net: http_server: Send chunked response correctly
The chunked response was not sent properly. There were extra
"\r\n" before the chunk lenght and the length of the string
to be sent was calculated incorrectly.

Fixes #72887

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 15:39:09 +02:00
Tomasz Moń a1afd349a1 usb: device_next: initialize BOS device caps number
Explicitly initialize bNumDeviceCaps to 0 because the bos descriptor is
stored on stack.

Fixes: b0d7d70834 ("usb: device_next: add initial BOS support")
Coverity-CID: 368798

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2024-06-03 15:38:23 +02:00
Seppo Takalo 9e615429d5 net: lwm2m: Block-Wise response NUM field fix
When calculating the offset for blockwise writes,
we should not advance the block_ctx->current field
past the block boundary.
It causes CoAP layer to reply with the next NUM field
instead of the current one being processed.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2024-06-03 15:37:21 +02:00
Jordan Yates 924db97724 usb: cdc_acm: add locks around ring_buf_put
The ring buffer API is explicitly not thread safe, with users needing to
implement their own locking. As `poll_out` and `fifo_fill` are operating
on the same ringbuffer, these locks are needed.

Signed-off-by: Jordan Yates <jordan@embeint.com>
2024-06-03 03:44:45 -07:00
Emil Gydesen 1af717430a Bluetooth: CAP: Do not require CAS unless necessary
Removes the requirement that CAS is found on the remove
device for ad-hoc sets. This makes the CAP API more
versatile as it allows applications to use it with
remote non-CAP devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 03:39:07 -07:00
Yong Cong Sin 02770ad963 debug: EXCEPTION_STACK_TRACE should depend on arch Kconfigs
Fix the dependencies of `CONFIG_EXCEPTION_STACK_TRACE`:
- Architecture-specific Kconfig, i.e.
  `X86_EXCEPTION_STACK_TRACE`, will be enabled automatically
  when all the dependencies are met.
- `EXCEPTION_STACK_TRACE` depends on architecture-specific
  Kconfig to be enabled.
- The stack trace implementations should be compiled only if
  user enables `CONFIG_EXCEPTION_STACK_TRACE`.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 8a5823b474 debug: remove !OMIT_FRAME_POINTER from EXCEPTION_STACK_TRACE
Not all stack trace implementation requires frame pointer, move
that dependency to architecture Kconfig.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 413b1cf409 debug: remove DEBUG_INFO from EXCEPTION_STACK_TRACE
The `DEBUG_INFO` in the `EXCEPTION_STACK_TRACE` is only
required by x86. Move that to `X86_EXCEPTION_STACK_TRACE`
instead.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Yong Cong Sin 1570ef2863 debug: remove PRINTK from EXCEPTION_STACK_TRACE
The `PRINTK` was required for `EXCEPTION_STACK_TRACE` because
it's initial implementation for x86 in #6653 uses `printk()`.
We are using `LOG_ERR()` now, so this is not required anymore.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-06-03 03:02:04 -07:00
Valerio Setti a15af0be9f mbedtls: fix Mbed TLS Kconfig options
PR #72475 disabled default enabling of most Mbed TLS features.
This means that:

- CONFIG_MBEDTLS_CIPHER_AES_ENABLED needs to be manually enabled
  when required;
- CONFIG_PSA_WANT_KEY_TYPE_RSA_KEY_PAIR_BASIC does not need to
  be (almost) always added because there is no default RSA
  key-exchange enabled, so PSA can be built without RSA support.

Signed-off-by: Valerio Setti <vsetti@baylibre.com>
2024-06-03 09:55:58 +02:00
Jukka Rissanen b95821f809 net: dns: llmnr_responder: Print query type properly
Instead of printing either A or AAAA resource query type,
print the correct query type value.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen b305be037c net: Start socket service thread by net core init
Do not depend on init level but start the socket service
already in net core init because DNS init code depends on
socket service API to be ready to serve. And we call DNS
init at the net core init.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 1eb4a709e8 net: dns: Allow using resolver and responder at the same time
Allow mDNS resolver and responder to to be used at the same
time so that both can use the port 5353. This requires
a DNS traffic dispatcher which affects also the normal DNS
resolver.

Fixes #72553

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 63e6a83510 net: dns: Add helper for figuring out the query type
Add helper function that returns the name of the query type
so that we can print it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Jukka Rissanen 434e290649 net: dns: Add ANY query resource type
Don't give an error for ANY type record.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-06-03 09:49:01 +02:00
Emil Gydesen f93b9dee5c Bluetooth: CSIP: Make set_member_by_conn a public function
The function is useful for application to lookup set
members from bt_conn pointers, e.g. when iterating on
connected devices.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-06-03 09:48:48 +02:00
Fengming Ye 4f8c2e8f58 net: conn: fix supplicant l2 recv unexpected frame
Supplicant create AF_PACKET proto ETH_P_PAE socket but receive other
frames like ICMP, UDP and causes following issues.
1. When frame len exceeds MTU, net_pkt_clone cannot clone pkt.
   Thus dropped it and print warning log.
2. It will lower throughput performance as every packet is cloned.

Fix it by conn_raw_socket does not deliver pkts protocol not macted,
after l2 processed, unless conn is all packets.

Signed-off-by: Fengming Ye <frank.ye@nxp.com>
2024-06-03 09:48:32 +02:00
Mathieu Choplain a07d493c9d llext: relocate all symbols regardless of type
In the current implementation, the LLEXT linker will only apply
relocations targeting a given symbol if it has a specfic symbol type.
This is overzealous and causes issues on some platforms, as some symbols
that need to be relocated are skipped due to being of a "bad" type.

Ignore the symbol type when performing relocation to solve this problem,
but also add checks to ensure we don't attempt to relocate symbols with
an invalid section index. If such a relocation is found, return an error
instead of ignoring the relocation entry to ensure that it is impossible
to execute code from a (partially) unrelocated LLEXT.

Also remove all hacks added to circumvent this issue:
* qemu_cortex_r5 exclusion from test cases
* unnecessary exclusion of some flags when building with LLEXT EDK

Fixes #72832.

Signed-off-by: Mathieu Choplain <mathieu.choplain@st.com>
2024-05-31 16:38:09 -05:00
Tomi Fontanilles c1342b3aa9 modules: mbedtls: remove the default enabling of features
In an effort to shave off code size, remove out-of-the-box
enabling of crypto features (except SHA-256).

Configurations are adjusted to enable what they need.

Bonuses:

- When enabled, AES now defaults to using a smaller version
(`CONFIG_MBEDTLS_AES_ROM_TABLES` isn't default enabled anymore,
and if enabled, `CONFIG_MBEDTLS_AES_FEWER_TABLES` defaults to y).

- Conditions around Mbed TLS Kconfig options have been improved
to reflect the reality of the dependencies.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
2024-05-31 16:33:06 -05:00
Robert Lubos 8a808c40cc net: if: Remove redundant ifdef slicing
Some IPv4/IPv6 functions were ifdef-sliced internally, despite being
compiled in conditionally in top-level #ifdef block under the same
condition.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00
Robert Lubos c84444b681 net: if: Improve ifdef blocks matching
In some cases the comment after #endif did not match the opening #if, in
some cases it was missing.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-05-31 09:58:59 -05:00