Commit graph

22,555 commits

Author SHA1 Message Date
Andrzej Puzdrowski
eab304f0db mcumgr/img_mgmt: Allow erase pending image by default
Allows erasing secondary slot which is marked for test or confirmed.
This is safe as bootloader doesn't make any action on boot-setup yet.

Erase of such pending image might considered like the case when it
was never downloaded as well.

This allow user to not stuck with pending irremovable image.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2025-04-01 22:13:20 +02:00
Nicolas Pitre
9da06456f2 kernel: kheap: decouple simple alloc from aligned_alloc
When k_heap_alloc() is expressed in terms of k_heap_aligned_alloc()
it invokes a longer aligned allocation code path with an extra runtime
overhead even though no alignment is necessary.

Let's reference and invoke the aligned allocation code path only when an
actual aligned allocation is requested. This opens the possibility for
the linker to garbage-collect the aligning code otherwise.

Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
2025-04-01 22:13:04 +02:00
Johan Hedberg
39c2605930 Bluetooth: Fix deadlock with settings and bt_hci_cmd_send_sync()
We can't do synchronous HCI command sending in any settings commit()
callback, since we don't know what context the callback is being called
from. One particular deadlock can happen if settings_load() is called from
the preemptible main thread:

main()
 |--> settings_load() (aquire settings_lock mutex)
       |-->commit callback A that defers to system wq
       |-->commit callback B that calls bt_hci_cmd_send_sync()

system wq from the previous deferral from within settings_load():
 |--> work item
       |--> settings_save_one()
             |--> attempt to aquire settings_lock mutex

In the above scenario, the bt_hci_cmd_send_sync() call from the main thread
depends on the system workqueue being processed (since that's what does HCI
command processing by default), while at the same time holding the settings
subsystem's mutex. At the same time, a system wq item tries to store
something into settings, however it deadlocks waiting for the settings
mutex.

The actual scenario that we have in the Bluetooth subsystem is where
"commit callback A" is commit_settings() in host/settings.c, and "commit
callback B" is keys_commit() in host/keys.c.

The solution to the deadlock is to take advantage of deferred bt_id_add()
handling which already exists, i.e. set a flag and deferre the actual
adding to the system workqueue.

Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
2025-04-01 16:28:00 +02:00
Ryan Chu
9ba60d3eb7 bluetooth: host: Apply callback changes of CS complete events
The CS complete callbacks provide both status and params.
In the case of errors, NULL pointer is passed to the params of callbacks.

Signed-off-by: Ryan Chu <ryan.chu@nordicsemi.no>
2025-04-01 16:26:58 +02:00
Ryan Chu
c9240cc99f bluetooth: host: Report status of Channel Sounding complete events
If the HCI status of a complete event is not BT_HCI_ERR_SUCCESS,
the remaining parameters could be invalid.

In this case, the params is passed as NULL pointer to the callbacks.
- LE CS Read Remote Supported Capabilities Complete event
- LE CS Read Remote FAE Table Complete event
- LE CS Config Complete event
- LE CS Security Enable Complete event
- LE CS Procedure Enable Complete event

This change avoids forwarding the invalid fileds to the applications.

Signed-off-by: Ryan Chu <ryan.chu@nordicsemi.no>
2025-04-01 16:26:58 +02:00
Krzysztof Chruściński
aaeb015ec4 logging: frontends: stmesp: Fix sending string location
String location information should only be sent for core which
do not append strings to the log message (PPR, FLPR). Without
this, cpurad was also sending that information and that was
redundant.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-01 16:26:50 +02:00
Krzysztof Chruściński
c8d7d577a6 logging: frontend_stmesp: Fix string addresses from remote core
When decoding logs from a remote core with memory that APP can
access, wrong address of an array with string addresses was used.
Log message contains index of a string and APP strings array was
used instead of remote core. Extend STMESP logging so that address
of string array of a remote core is send during startup to the APP
and APP is using this array to decode strings from remote cores.
Bug applies only to PPR and FLPR as APP has no access to RAD memory.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-04-01 16:26:50 +02:00
Cla Mattia Galliard
f3a3ad308c thread_analyzer: Allow to override the auto-analysis thread priority
By default the thread priority is still the lowest application thread
priority. Allow the priority to be increase by specifying both, the
`override` option as well as the desired `priority`. This pattern was taken
from the shell thread.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-04-01 11:59:39 +02:00
Jack Chistyakov
dd6adc7cad net: virtual: Clear multicast bit when generating link address
The least significant bit of the first octet of a MAC address is a
unicast/multicast bit. The bit should be cleared when generating a
random link address for a virtual interface. Any frames from such
interface/address will be dropped by the network as invalid if
the multicast bit is set.

Signed-off-by: Jack Chistyakov <jack.chistyakov@outlook.com>
2025-04-01 11:53:02 +02:00
Sean Kyer
905aed99fa Bluetooth: Fixed null byte check in DIS UDI
Due to sizeof('\0') evaluating to 4 bytes instead of 1:
- Each UDI field had 4 instead of 1 'zero byte' appended
  (as specified by BLE spec).
- Any field of length 4 was being skipped entirely.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-03-31 19:50:12 -04:00
Raúl Gotor
39c0c4f43c Bluetooth: Mesh: Shell: fixes publication period calculation
The publication period is defined by Steps and Resolution.
At BLE Mesh protocol level, the period is encoded in a byte
where first LSB 6 bits correspond to PerSteps and the last
two to PerRes. There is an issue on how the code at
`subsys/bluetooth/mesh/shell/cfg.c:model_pub_set` is encoding
these two values into the publication period byte.
This is commit fixes issue #87780

Signed-off-by: Raúl Gotor <raulgotor@gmail.com>
2025-03-31 19:48:10 -04:00
Troels Nilsson
c64494a32d Bluetooth: Controller: Fix return value for apto with illegal handles
If the connection handle given to a Read/Write Authenticated Payload
Timeout HCI command is a CIS or BIS handle, the error returned has to
be BT_HCI_ERR_CMD_DISALLOWED with the new TCRL

Fixes EBQ test failures in HCI/BIS/BI-14-C, HCI/BIS/BI-15-C,
HCI/CIS/BI-20-C and HCI/CIS/BI-22-C

Signed-off-by: Troels Nilsson <trnn@demant.com>
2025-03-31 22:01:46 +02:00
Aleksandr Khromykh
69c5c6f40e Bluetooth: Mesh: make corresponding group ID unique
Commit fixes bug when corresponding group ID was never
incremented for independent corresponding relationships.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-31 22:01:11 +02:00
Jukka Rissanen
137eba4e40 net: dns: Check compression flag properly
Allow only 0xc (0b11) as two highest bit to mark the compression
when parsing the CNAME response. See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Jukka Rissanen
5746f61d4c net: dns: Check recursive pointers for CNAME handling
Make sure that the CNAME handling checks recursive name pointers
and fails the response if recursion is detected.
See RFC 9267 ch. 2 for details.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-31 22:00:36 +02:00
Mirai SHINJO
93b59a2314 sd: correct mismatched comment for CONFIG_SDMMC_STACK
The closing comment for CONFIG_SDMMC_STACK #ifdef directive was
incorrectly labeled as CONFIG_SDIO_STACK. This commit corrects the
comment to reflect the correct configuration macro and improve code
clarity.

Signed-off-by: Mirai SHINJO <oss@mshinjo.com>
2025-03-31 21:59:40 +02:00
Lyle Zhu
3bf18870f9 Bluetooth: Classic: SMP: Store derived LK if SMP_FLAG_BOND is set
When deriving the new LK, remove the old LK if it exists.

Store the derived LK if the flag `SMP_FLAG_BOND` of LE SMP is set.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 14:35:50 +02:00
Lyle Zhu
001397653b Bluetooth: Classic: SMP: Set BT_LINK_KEY_SC only if BT_KEYS_SC is set
The flag `BT_LINK_KEY_SC` of LK will also be set when derive LK from
LTK.
It is a incorrect behavior.

The flag `BT_LINK_KEY_SC` should only be set if the flag `BT_KEYS_SC`
of LTK has been set.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 14:35:50 +02:00
Lyle Zhu
2695d2228b Bluetooth: Classic: SMP: Avoid stronger LK be overwrote by weaker LTK
Add the function `ltk_derive_link_key_allowed()` to check whether the
LK can be overwrote by the LTK.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 14:35:50 +02:00
Kapil Bhatt
6f9dbbd54f wifi: utils: Fix crash for scan
The check for index out of bound is missing, It turns into a crash
for input channel more than WIFI_MGMT_SCAN_CHAN_MAX_MANUAL.

Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
2025-03-31 14:33:22 +02:00
Lyle Zhu
f25fe59805 Bluetooth: Classic: SMP: Recovery flag SMP_FLAG_BR_CONNECTED
The flag `SMP_FLAG_BR_CONNECTED` is cleared by the function
`smp_br_reset()` and `smp_br_init`. But the flag
`SMP_FLAG_BR_CONNECTED` should not be cleared at this time.

Recovery the flag `SMP_FLAG_BR_CONNECTED` after the all flags of SMP
cleared.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
b59bc363ea Bluetooth: Classic: SMP: Set secure connection for derived LTK
If the encrypt value of classic connection is
`BT_HCI_ENCRYPTION_ON_BR_AES_CCM`, set the flag `BT_KEYS_SC` for
the derived LTK.

Or, clear the flag `BT_KEYS_SC` for the derived LTK.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
58f6ca80ca Bluetooth: Classic: SMP: Remove old LE keys before upgrading keys
Remove the old LE keys from resolving list and NVM before upgrading
the keys.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
3712b96738 Bluetooth: Classic: SMP: Avoid derived LE keys be added multiple times
In current implementation, the flag `local_dist` will be cleared when
the distributed key frame is performed if the local is the SMP
initiator. After the distributed key is sent out, the function
`smp_pairing_br_complete()` will be called if all bits of `local_dist`
are cleared.

It causes the function `smp_pairing_br_complete()` will be called
multiple times.

Add a flag `local_distributed` to flag the all sent keys. Add only the
flag `local_distributed` is not set, preform the key distribution
frame.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Lyle Zhu
8bb67c5824 Bluetooth: Classic: SMP: Derived LE keys are not handled correctly
The derived LE keys are not saved to NVM. And the IRK is not added to
controller resolving list. It causes two issues,
Issue 1, the LE connection connection cannot be established if the adv
address of peer is RPA.
Issue 2, the LE keys are missing after the power reset.

For issue 1, add a function `smp_br_id_add_replace` to add LE keys.
For issue 2, check the BR bondable flag `BT_CONN_BR_NOBOND` instead of
`SMP_FLAG_BOND`.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-03-31 11:29:49 +02:00
Tomasz Bursztyka
b4f9242a6a shell: kernel: Add a panic command
For testing purposes only. Testing the fatal error handler or
a coredump backend. Or just out of curiosity.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-03-29 07:44:11 -04:00
Tomasz Bursztyka
6ad72847e9 coredump: Add an in-memory backend
Only meant to be used on platforms that would not wipe the RAM on reboot.
This won't work if the platform is halted and restarted as RAM is
volatile, obviously. A relevant fatal error handler needs to be provided
to reboot.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-03-29 07:44:11 -04:00
Tomasz Bursztyka
9bab18d5c8 coredump: Have a dedicated log module for coredump
To enable/disable any coredump logging while debugging the kernel.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-03-29 07:44:11 -04:00
Tomasz Bursztyka
13abd7fe73 coredump: Generalize the shell module
This might come in handy for other coredump backends too, not only flash
one. Obviously: changing the logic to use the coredump generic API instead
of the flash backend's internal functions.

Adding a better output, following how the coredump is actually created:
parsing and printing headers, and their respective content.

Signed-off-by: Tomasz Bursztyka <tobu@bang-olufsen.dk>
2025-03-29 07:44:11 -04:00
Vinayak Kariappa Chettimada
dd1c3948ca fixup! Bluetooth: Controller: Fix incorrect CIS payload count at CIS Estab
Fix incorrect payload count at CIS Establish due to existing
CIG event overlapping the ACL event at the instant when the
CIS gets the active flag set.

The overlapping CIG event picked up the new CIS that had its
active flag set in the current CIG event instead of at the
actual CIS offset which is in the next CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
fcca236e42 Bluetooth: Controller: Fix CIS offset for dissimilar ACL & CIG interval
Fix CIS offset calculation due to use of decremented ACL
event counter, where as the CIS offset is inquired in the
next ACL event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
4ab805b389 Bluetooth: Controller: Fix incorrect CIS offset accepting peer instant
Fix incorrect CIS offset in use if instant is picked from
the peer sent CIS RSP PDU. Instead, keep the instant that
was sent in the CIS REQ PDU as the instant to send in the
CIS IND PDU.

This fixes CIS failed to be established when dissimilar
ACL and ISO intervals are in use.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
f2c020f53e Bluetooth: Controller: Fix incorrect CIS payload count at CIS Estab
Fix incorrect payload count at CIS Establish due to existing
CIG event overlapping the ACL event at the instant when the
CIS gets the active flag set.

The overlapping CIG event picked up the new CIS that had its
active flag set in the current CIG event instead of at the
actual CIS offset which is in the next CIG event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
81dd7595f0 Bluetooth: Controller: Fix Peripheral CIS sorted by CIG
Fix Peripheral CIS sorted by CIG implemenation to use CIS
offset stored in LLL context which is the correct offset
from the CIG anchor point. CIS offset in the ULL context
is the offset from the ACL anchor point at the time of
the CIS establishment.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Vinayak Kariappa Chettimada
26eedaaf45 Bluetooth: Controller: Fix CIS event_count_prepare use
Fix CIS event_count_prepare use missed as part of fixes
related to commit be91cfedfb ("Bluetooth: Controller: Fix
incorrect event_count when CIG overlaps").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-03-29 06:32:21 +01:00
Tim Gibson
1f754ac009 settings: fix settings shell subcommand helper
The settings shell returned an unhelpful message when provided
the incorrect arguments. This changes the returned message to
provide the correct usage message.

Signed-off-by: Tim Gibson <timmaxgibson@gmail.com>
2025-03-29 06:31:39 +01:00
Krzysztof Chruściński
0b866648e1 debug: cpu_load: Fix CPU_LOAD_USE_COUNTER config
dt_chosen_enabled argument was incorrect and it was always returning
n so option could not be used.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2025-03-28 21:52:30 +01:00
Jukka Rissanen
8e908176c7 net: shell: iface: Print VPN public key
If the interface is a VPN interface, then print
the public key of the interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
4eac955305 net: if: Add special handling for IPv4/6 address check for VPN
This is a hack that is used until we have proper IP routing
in place. The code has now special check that makes sure that
we only route IP packets to VPN interface when the packet is
destined to that subnet. So if destination IP address does
not belong to VPN interface subnet, it is not routed there.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
663867dbb0 net: if: Add helper to get src interface and address from dst address
Instead of calling various network interface API functions to get
the network interface and related source IP address, have a single
function that can return both data.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
525b8e58a2 net: l2: virtual: Add support for VPN public/private key set/get
Add support for getting public address and setting private
key for the virtual interface.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
c073a01b39 net: shell: events: Print VPN event information
Add VPN events information printouts to event monitor.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
d95d391968 net: stats: Add VPN statistics support
Enable collection of VPN statistics and allow user to fetch it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
b7dec6c195 net: Add option for VPN enablement
Add support for setting up VPN enablers in the network stack.
These are to be used by the VPN implementation like Wireguard.

Signed-off-by: Jukka Rissanen <jukka.rissanen@gmail.com>
2025-03-28 21:51:57 +01:00
Jukka Rissanen
0a8bad7e28 net: dhcpv4: Add parsing of received domain name
Currently we ignore the received domain name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
22f15de7a6 net: dhcpv4: Add parsing of received host name
Currently we ignore the received host name but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Jukka Rissanen
8ec4fba67c net: dhcpv4: Add parsing of broadcast address
Currently we ignore the broadcast address but make sure we
print it in order to avoid unknown option prints.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-03-28 21:51:33 +01:00
Aleksandr Khromykh
bf22fa697b Bluetooth: Mesh: remove device key candidate
Commit removes device key candidate if provisionee failed
during device key refresh procedure or mesh reset has been
called in between. Otherwise, device key candidate gets
stuck in the internal trusted storage of crypto library.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2025-03-28 16:11:39 +01:00
Cla Mattia Galliard
eb029b9ee1 net: http: server: Avoid compiler warnings for zero-length-arrays
Avoid compiler warnings for zero-length-arrays in the http-server. By using
memcpy instead of strcpy.

Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
2025-03-28 16:11:27 +01:00
Triveni Danda
589333e4d9 wifi: shell: Add support for EAP-TLS method
Add support to read identity and private key password if
configured in Enterprise mode.

Signed-off-by: Triveni Danda <triveni.danda@nordicsemi.no>
2025-03-28 16:10:36 +01:00