Commit graph

21541 commits

Author SHA1 Message Date
Guennadi Liakhovetski
0aa6b1c9de llext: pass the whole struct llext_load_param
To simplify LLEXT loader parameter extension pass the whole
struct llext_load_param to final consumers instead of extracting
individual fields from it in the caller function.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-09-29 21:21:24 +02:00
Guennadi Liakhovetski
f04e646af0 llext: (cosmetic) use a more common name for a variable
It's more common in the LLEXT code base to call elf_sym_t instances
"sym" and not "sym_tbl." Convert llext_link_plt() to follow this
convention.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-09-29 21:21:24 +02:00
Guennadi Liakhovetski
43a69f868b llext: make llext_loaded_sect_ptr() available to all LLEXT code
Make llext_loaded_sect_ptr() a proper function to be able to call it
from platform LLEXT code.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2024-09-29 21:21:24 +02:00
Pete Skeggs
09fab7e680 net: lib: http: ensure SYS_FOREVER_MS behavior
The http_client_req() function's timeout parameter is allowed
to be SYS_FOREVER_MS. However, K_MSEC() does not convert this
to a proper k_timeout_t, so sys_timepoint_calc() ends up
returning 0, which is causes immediate timeouts.

Check for this case specifically and force value passed to
sys_timepoint_calc() to be correct.

Signed-off-by: Pete Skeggs <peter.skeggs@nordicsemi.no>
2024-09-29 21:20:50 +02:00
Arif Balik
8742d9f25e logging: backend: add semihosting
Added semihosting support in logging backend

Signed-off-by: Arif Balik <arif.balik@enda.com>
2024-09-28 08:18:00 -05:00
Krzysztof Chruściński
c2454f2a9f logging: frontend: stmesp: Do not append strings when not needed
Currently we can assume that flpr and ppr cores are always owned by
cpuapp. In that case, cpuapp (which processes ETR buffer content) has
access to the memory where logging strings from ppr and flpr are
located. Those strings do not need to be appended to the message
which is written to the STM (in case of standalone configuration).
This approach reduced logging time, e.g. logging a message with
one argument takes 1.8us on cpuapp and 6.3us on cpurad.

This setting applies only to the case when cpuapp is the owner
of those co-oprocessors and shall be updated if that becomes
configurable but currently there are no means to detect core
owner.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-09-27 14:30:57 +01:00
Morten Priess
7e892f8c6f Bluetooth: controller: Remove SC-jitter from ISO pause/resume setup
Because timing of the pause/resume for peripheral/sync is based on
central/broadcaster active clock, the sleep-clock jitter shall not be
added.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Morten Priess
fe83a9dc22 Bluetooth: controller: Fixes and improvements for PTO implementation
- Add next pointer to node_rx_iso_meta for pre-transmission linked
  list (does not increase memory usage as union is larger).
- Fix broadcaster not setting PTC with test configuration
- Refactor stopping of sync ISO tickers to separate function

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Morten Priess
541b516a3f Bluetooth: controller: Make ISO Pause/Resume common
Share pause/resume functionality by moving resume ticker handling to
ull_iso. Rename interface function to ull_conn_iso_resume_ticker_start,
and provide handles instead of instance pointer.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2024-09-27 09:03:37 +02:00
Jamie McCrae
9c821eb999 mgmt: mcumgr: grp: img_mgmt: Add slot info command
Adds a new command that will return information on slots
themselves, listing the slot sizes, without any internal
information about the slot data. Will also return the maximum size
of an image for a set of slots if built using sysbuild.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-09-26 17:48:05 -04:00
Vinayak Kariappa Chettimada
b423941010 Bluetooth: Controller: Remove unused nRF21 FEM SPI CSN control
Remove unused nRF21 FEM SPI CSN control as the Zephyr
Controller does not implementation SPI control for Tx/Rx
nor for Tx gain settings.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2024-09-26 17:43:34 -04:00
Babak Arisian
c0cfe49a54 Bluetooth: BASS: Add support for dynamic registration of BASS
Added support for dynamic registration and unregistration of the
Broadcast Audio Scan Service (BASS) within the scan delegator.
This enables both scan delegator and BASS to be registered or
unregistered dynamically at runtime.

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-09-26 17:42:39 -04:00
Jamie McCrae
770482a45a mgmt: mcumgr: grp: os_mgmt: Fix issues raised in comments
Fixes an issue with structure which was previously raised in a
comment, and adds a new bool to the structure to enable this
restructure to work

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2024-09-26 17:42:01 -04:00
Emil Gydesen
ec2c5b0c1f Bluetooth: GATT: Replace magic number 0 with macro for auto ccc
Replace the magic number 0 with a #defined value for
the auto CCC discovery feature.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-26 17:41:24 -04:00
Francois Gervais
bfed8d0966 net: lib: coap_client: wait for all acknowledgements
This commit makes sure we continue to wait for extra confirmations even
after the request is done so we can handle duplicate confirmations if any.

Detailed description:

rfc7252#section-4.5 specifies that:

"The recipient SHOULD acknowledge each duplicate copy of a
 Confirmable message".

So if, for example, the client sends to a multicast destination address,
the server will get multiple requests and will confirm all of them.

Without this commit, the client will set the request to done after
receiving the first answer.
From here the request object will be marked as free and the duplicate
acknowledgements will stay buffered in the network stack.
Once the client tries to send a new request, it will unbuffer those
duplicate acknowledgements but now the request object is unallocated
so the client won't be able to handle those acknowledgements as duplicates.
It will instead treat it as an unexpected ACK.

To work around this issue, rfc7252#section-4.8.2 states that:

"EXCHANGE_LIFETIME is the time from starting to send a Confirmable
 message to the time when an acknowledgement is no longer expected,
 i.e., message-layer information about the message exchange can be
 purged."

Keeping the request object allocated for EXCHANGE_LIFETIME ensures that
duplicate acknowledgements can be handled accordingly.

This commit adds a basic implementation of what is stated in the RFC.

EXCHANGE_LIFETIME has been arbitrarily set to 3 * ACK_TIMEOUT which
seems more reasonable than the 247 seconds stated in the RFC.

Signed-off-by: Francois Gervais <francoisgervais@gmail.com>
2024-09-26 09:20:23 -05:00
Rubin Gerritsen
417a9e81ec Bluetooth: Controller: Add device tree dependency to selection
This commit makes the device tree configuration decide
which link layer is compiled in. We do this to avoid
hard-to-understand linker errors referencing device tree nodes.

The following configuration creates a difficult to parse
linker error:
* BT_LL_CHOICE contains multiple entries, BT_LL_SW_SPLIT
  is selected.
* Each BT_LL_CHOICE has its own unique device tree node with its
  own "compatible".
* Only one of the link layer device tree nodes has status "okay",
  but not the one corresponding to BT_LL_SW_SPLIT.

The linker error indicates that code using the HCI driver fails
to link with the controller. This because the HCI driver device
tree node references the link layer selected in devicetree which
is not compiled in.

By adding a dependendency to the device tree node, this can no longer
happen. Instead, if BT_LL_SW_SPLIT is now selected in a configuration
file, a Kconfig warning will be issued:

```
warning: The choice symbol BT_LL_SW_SPLIT
(defined at subsys/bluetooth/controller/Kconfig:129) was
selected (set =y), but BT_LL_SOFTDEVICE (defined at
/home/ruge/ncs/nrf/subsys/bluetooth/controller/Kconfig:11)
ended up as the choice selection.
```

This should be easier to understand than:

```
...(hci_core.c.obj):(.data.bt_dev+0x16c):
undefined reference to `__device_dts_ord_132'
```

After this commit we should consider getting rid of link layer
selection from Kconfig completely as the link layer is in practice
selected through device tree.

Unit tests have been updated to satisfy the dts dependency.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2024-09-26 11:10:22 +01:00
Robert Lubos
da6b607a32 net: tcp: Do not cancel connect sem from tcp_conn_unref()
Resetting the connect semaphore from tcp_conn_unref() prevents the
ref/unref mechanism from being used freely when needed. Therefore, move
the code responsible for resetting pending connection to
tcp_conn_close() (called only when the connection is being closed on
behalf of the TCP stack, for instance due to RST being received) and to
net_tcp_put() (connection closed on behalf of the application).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2024-09-26 10:58:37 +01:00
Jukka Rissanen
a41f625fab net: tcp: Make sure that connection failure is propagated to app
It is possible that TCP connect() will fail if for example network
interface does not have IP address set. In this case we close
the connection during net_tcp_connect() but do not set the return
code properly. This looks in the application like the connection
succeeded even if it was not.

As the tcp_in() call in net_tcp_connect() might close the connection,
we just take extra ref count while calling tcp_in(). Otherwise we
might access already freed connection.

Before the fix:

net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp_connect: conn: 0x8087320, ret=0

After the fix:

net_tcp_connect: context: 0x80757c0, local: 0.0.0.0, remote: 192.0.2.2
net_tcp_connect: conn: 0x8087320 src: 0.0.0.0, dst: 192.0.2.2
tcp_conn_ref: conn: 0x8087320, ref_count: 2
tcp_in: [LISTEN Seq=1604170158 Ack=0]
tcp_conn_close_debug: conn: 0x8087320 closed by TCP stack (tcp_in():3626)
tcp_conn_close_debug: LISTEN->CLOSED
tcp_conn_unref: conn: 0x8087320, ref_count=2
net_tcp: tcp_conn_unref: conn: 0x8087320, ref_count=1
net_tcp: net_tcp_connect: conn: 0x8087320, ret=-128

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-26 10:58:37 +01:00
Alberto Escolar Piedras
b5b91b3edb ipc: icmsg & icbmsg: Add support for POSIX arch targets
Add support in this IPC backends for POSIX arch targets in general,
and ensure the nrf5340bsim defines the buffer which will be used.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-26 03:34:26 -04:00
Alberto Escolar Piedras
5dc810e261 ipc: pbuf: Provide function for Rx side initialization
Provide a new function for initializing the Rx side,
so users do not need to initialize the pointers by hand
if they did not use PBUF_DEFINE().

Let's also rename pbuf_init() to pbuf_tx_init() to clearly
signify the previous function was only meant to be used
by the Tx side.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-26 03:34:26 -04:00
Alberto Escolar Piedras
b6f1767db5 subsys/ipc icmsg_me.c: Fix ssize_t build error for some libCs
ssize_t is not part of the C library ISO standard subset, and as such
one cannot expect a C library to expose the type by default.
Some libraries like glibc do not expose this type in general, and
trying to build using them results in build errors.

There is 3 possible options:
1. Continue using ssize_t and:
1.a define _POSIX_C_SOURCE before including any header
1.b include sys/types.h directly (A bit uglier)
3. Not use ssize_t, and instead rely on ISO standard types

Let's just go with 1.a assuming we want to keep using this type,
as that is the correct way of getting this type defined.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2024-09-26 03:34:26 -04:00
Ben Wolsieffer
063b146eb4 net: tcp: Fix net_tcp_endpoint_copy() with IPv4 disabled
The IPv6 branch of net_tcp_endpoint_copy() was accidentally made
conditional on CONFIG_NET_IPV4 rather than CONFIG_NET_IPV6.

Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
2024-09-26 03:32:26 -04:00
Emil Gydesen
fff3ff02c5 Bluetooth: CSIP: Add bonding requirement for set lock/release
The CSIP spec states that the procedures shall only be done
on bonded devices, so a check for that was added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-26 03:31:47 -04:00
Torsten Rasmussen
205691edce cmake: linker: evaluate CONFIG_LINKER_ITERABLE_SUBALIGN in CMake
Evaluate CONFIG_LINKER_ITERABLE_SUBALIGN in CMake instead of in the
linker script.

It cannot be assumed that a linker generator implementation is
pre-processed and therefore Kconfig settings cannot be used in those
but must be evaluated in CMake.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2024-09-25 16:16:35 -05:00
Jukka Rissanen
765bfbbc3c net: stats: dns: Collect DNS statistics
If DNS statistics is enabled in Kconfig, then start to collect it.
This is useful in order to see how many DNS requests/responses
received or sent, and also see the amount of dropped DNS packets.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-25 13:52:15 -05:00
Jukka Rissanen
ca0bd2cc23 net: mdns: Discard the message if query count is 0
As described in RFC 6804 ch. 2, if query count is 0, discard
the message silently.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-25 13:52:15 -05:00
Luca Burelli
db451f2c46 llext: export DT devices to extensions
This change adds a new configuration option, LLEXT_EXPORT_DEVICES, which
enables exporting all devices defined in the device tree to llext
extensions. When enabled, all devices are made available to extensions
via the standard DT_ / DEVICE_* macros.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
2024-09-25 12:59:13 +02:00
Burak Gorduk
6e3c3f67e1 bluetooth: host: Use consistent API naming for CS
This change adds bt_le_cs prefix to public CS API as well as
adding le_cs prefix to CS related bt_conn callbacks. This is
to ensure consistency within CS API while maintaining the
separation between the Bluetooth LE and Classic features.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
2024-09-25 12:58:51 +02:00
Burak Gorduk
7b82214d29 bluetooth: host: HCI support for CS configuration
Adds following HCI support for CS configuration:
- LE CS Create Config command
- LE CS Remove Config command
- LE CS Config Complete event

Two callbacks have been added to notify the application
when a new CS configuration is created or an existing
CS configuration is removed.

Signed-off-by: Burak Gorduk <burak.gorduk@nordicsemi.no>
2024-09-25 12:58:51 +02:00
Babak Arisian
d8c1d4d7b6 Bluetooth: Host: BT scan failure when connecting by name in shell
Added a timeout for active scans (instead of using the host's scan
timeout) in the shell by submitting a k_work that stops the scan
after a specified period.

Fixes #78659

Signed-off-by: Babak Arisian <bbaa@demant.com>
2024-09-25 12:58:11 +02:00
Olivier Lesage
7538a981c9 bluetooth: host: set BT_BUF_EVT_RX_SIZE to 255 when CS is enabled
Channel sounding frequently produces very large events, so the default
of 68 bytes can lead to buffer overruns / memory corruption.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2024-09-25 04:05:14 -04:00
Lyle Zhu
18d1ca7c78 Bluetooth: classic: Fix LE LTK cannot be derived issue
In the handler of SMP_Pairing rsp, the encryption key
flag is cleared incorrectly.

It causes the LE LTK cannot be derived.

Do not modify the encryption key flag to fix the
issue.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2024-09-25 04:02:11 -04:00
Yangbo Lu
6fe7f6c55d net: lib: http_server: fix snprintk issue of size_t
The size_t type may vary from machines. Current snprintk code was
causing below build issue on arm64.

error: format '%x' expects argument of type 'unsigned int', but argument
4 has type 'size_t' {aka 'long unsigned int'} [-Werror=format=].

Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
2024-09-25 04:00:02 -04:00
Fin Maaß
99e6280d7e logging: log_output: timestamp_print uses gmtime_r, a POSIX function
Define _POSIX_C_SOURCE for this file to make sure gmtime_r is visible.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-09-24 14:29:02 -05:00
Fin Maaß
1d91d0f269 logging: log_output: switch to gmtime_r
switch from gmtime() to gmtime_r().

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-09-24 14:29:02 -05:00
Fin Maaß
54b2f56984 logging: add ISO 8601 formated timestamp
add ISO 8601 formated timestamp for logging.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-09-24 14:29:02 -05:00
Fin Maaß
20a6ad7918 logging: add formated timestamp for realtime
This adds a timestamp format mode, that includes the date, which is
usefull, when using realtime for the logging timestamp.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-09-24 14:29:02 -05:00
Fin Maaß
683ae11510 logging: net: don't replace syslog timestamp
this way CONFIG_LOG_OUTPUT_FORMAT_CUSTOM_TIMESTAMP
only uses the custom timestamps for
logs that are not send via syslog.

Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
2024-09-24 14:29:02 -05:00
Emil Gydesen
1406c547d6 Bluetooth: TBS: Add support for dynamic TBS
The TBS and GTBS instances can now be dynamically registered
and unregistered, which fits better for the use cases of TBS
where specific bearers can come and go depending on the
features of the device.

For example if a SIM card is inserted, then a device can
register a TBS for the provider and remove it again if the
SIM card is removed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-24 09:21:54 -04:00
Emil Gydesen
bf897cf941 Bluetooth: Shell: Restructure shell files
Moves around the shell files so that they are placed nearer
to the features they expose access to.

A few changes as possible has been made.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-24 09:21:04 -04:00
Carlo Kirchmeier
cb304318df net: dns: Improve interface count mismatch warning
In order to reduce confusion regarding interface count
the respective warning was adjusted to better reflect
the actual state of the system.

Signed-off-by: Carlo Kirchmeier <carlo.kirchmeier@zuehlke.com>
2024-09-24 09:20:48 -04:00
Jukka Rissanen
00bb90a42e net: if: Check chksum offloading properly for VLAN interfaces
Make sure we check the checksum offloading capabilities correctly
for VLAN interfaces. Use the real Ethernet interface when doing the
check.

Fixes #78724

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-24 10:11:33 +02:00
Mateusz Kapala
77555898de mgmt: mcumgr: Add SMP SVC and CHR UUIDs to header
Added the SMP service and characteristic UUIDs to the smp_bt module
header and used those definitions.

Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
2024-09-23 18:10:49 -04:00
Emil Gydesen
4e4971b25d Bluetooth: GATT: Fix issue with 0/NULL for bt_gatt_attr_read
The bt_gatt_attr_read function did not properly handle cases
where value is NULL and/or value_len is 0, or bad mixes of the
two.

The important part is here is that we do not perform the pointer
arithmetic on NULL and/or call memcpy with a NULL src with a
non-0 length.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 18:09:13 -04:00
Jukka Rissanen
8aab3ca39d net: shell: Allow user to disable not used commands
User can set CONFIG_NET_SHELL_SHOW_DISABLED_COMMANDS=n to prevent
unused net-shell commands from showing. This can save flash as
the disabled commands will not be shown in net-shell listing.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-23 14:10:15 +01:00
Jukka Rissanen
9d9398f42d net: shell: iface: Add DHCPv6 status prints
It is useful to know the currect status of DHCPv6 client when
printing the interface information.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-23 14:10:15 +01:00
Jukka Rissanen
e459191ace net: shell: dhcpv6: Add cmd to start/stop DHCPv6 client
Allow user to use the net-shell to start or stop DHCPv6 client.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-23 14:10:15 +01:00
Jukka Rissanen
bc003db998 net: shell: dhcpv4: Add cmd to start/stop DHCPv4 client
Allow user to use the net-shell to start or stop DHCPv4 client.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-23 14:10:15 +01:00
Jukka Rissanen
7e4a2c6d46 net: shell: virtual: Add attach/detach commands
Allow "net virtual" command to attach or detach virtual
interfaces. This is useful for device management.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2024-09-23 14:10:15 +01:00
Emil Gydesen
72829b3b77 Bluetooth: ISO: Added missing NULL checks for API functions
Add missing NULL check for public API function, so that the
function will return -EINVAL rather than crashing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2024-09-23 14:08:52 +01:00