Commit graph

22,555 commits

Author SHA1 Message Date
Mark Wang
31fba83fb3 bluetooth: classic: add role changed callback
add `role_changed` to `struct bt_conn_cb` to notify the HCI_Role_Change
event to application.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2025-07-19 09:59:16 +02:00
Matthias Plöger
239d53c5fc zbus: add user-configurable HEAP_MEM_POOL_ADD_SIZE_ZBUS
Zbus currently does only support default heap sizes.
The configuration option allows to decrease rom-footprint for embedded
applications. Adding the option to ZBus improves its flexibility and
while not increasing its complexity.

Add default of 0 value to compensate for previous cases where
HEAP_MEM_POOL_ADD_SIZE_ZBUS was defined as "".

Consistent naming 'Zbus'/'zbus' to 'ZBus'

Signed-off-by: Matthias Plöger <matthias.ploeger@phoenixcontact.com>
2025-07-19 09:56:21 +02:00
Tom Burdick
cbfe7813c7 pmci: mctp: I2C+GPIO Target binding
Adds a I2C+GPIO Target device binding for MCTP communication over I2C.

The binding requires an i2c bus and gpio pin, along with a specified I2C
and endpoint address pair. These are then used to create an MCTP binding
which can be used to communicate in a peer to peer manner among other
MCTP endpoints.

Each message transmit signals to the bus controller using a GPIO logical
high and is unset on transmission completion. Pending transmitters are
queued using a semaphore avoiding memcpy being needed to asynchronously
transmit mctp pktbufs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-07-19 09:53:21 +02:00
Tom Burdick
6464329346 pmci: mctp: I2C+GPIO controller bindings
Adds a custom MCTP binding for an I2C bus controller using GPIO signaling
for write requests rather than mode switching.

This binding operates a lot like the I3C binding specification DMTF has
for MCTP. The controller expects to receive interrupts (from GPIO pins)
and upon getting an interrupt read a message from the I2C target device.

The macro does a lot of the heavy lifting to setup all the state needed
for capturing GPIOs, being able to do asynchronous reads/writes, and
such. The entire controller works using state machines driven by
interrupts leading to low latency and clear ram costs.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-07-19 09:53:21 +02:00
Tom Burdick
e3cc7a8c63 pmci: mctp: Supply dedicated mctp heap
Unfortunately libc malloc/free are wrapped with a sys_mutex which is
troublesome for mctp as we likely want to allocate from interrupts in many
cases.

Supply mctp with a dedicated heap initialized and assigned at boot
saving applications a step. The default size is quite small and works
well so long as messages are small.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2025-07-19 09:53:21 +02:00
Cheng Chang
5b204de53a Bluetooth: host: L2CAP: Fix configuration parameters not be checked
Now in other mode rather than basic mode, configuration parameters
include MTU, Flush Time and QoS have been checked.
But in basic mode, they also need to be checked, so the code about this
should not be controlled by macro CONFIG_BT_L2CAP_RET_FC.

Signed-off-by: Cheng Chang <cheng.chang@nxp.com>
2025-07-19 09:51:02 +02:00
Ravinder Singh
394c97a819 Bluetooth: LE: CONN: Added bt_conn_le_set_default_phy function.
Added bt_le_set_default_phy in hci. This handles
the HCI_LE_Set_Default_PHY HCI command.
Added call to bt_conn_le_set_default_phy in central_gatt_write and
peripheral_gatt_write samples.

Signed-off-by: Ravinder Singh <ravinder.singh2@infineon.com>
2025-07-19 09:46:34 +02:00
Sean Kyer
cba074230d settings: Add TF-M ITS backend
Add settings_its backend in order for a non-secure
Bluetooth application to be able to save Bluetooth
settings to persistent storage.

Signed-off-by: Sean Kyer <Sean.Kyer@analog.com>
2025-07-19 09:45:56 +02:00
Make Shi
dcd9adec29 Bluetooth: AVRCP: Adjust positions of internal static functions
- Move the static function locations to beginning of the file to the
  file to avoid function declarations.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-07-19 09:40:19 +02:00
Make Shi
ba05d5c2b2 Bluetooth: Shell: AVRCP: support unit info request and response
Add avrcp_unit_info_req callback function in shell and a command to set
the unit info response.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-07-19 09:40:19 +02:00
Make Shi
c95d3167e2 Bluetooth: AVRCP: Implement unit message reception on the AVRCP target
- Add a new callback to support the situation when a unit info command is
  received, and add an API to respond to the unit info command.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-07-19 09:40:19 +02:00
Make Shi
a559fee00b Bluetooth: AVRCP: Refactored AVRCP API for CT/TG separation
- Only AVRCP connect and disconnect api for AVRCP common functions.
- Added _ct prefixes to all CT callback functions and feature APIs.
- Updated shell demo code for AVRCP API changes.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-07-19 09:40:19 +02:00
Alberto Escolar Piedras
8270444a4d subsys/fs/fuse_fs_access: Remove NATIVE_APPLICATION support
It is not possible to build anymore in that mode, so we do not
need to support it in this driver cmake files.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-07-19 09:38:15 +02:00
Alberto Escolar Piedras
af750b2b41 subsys/tracing/backend_posix: Remove NATIVE_APPLICATION support
It is not possible to build anymore in that mode, so we do not
need to support it in this driver cmake files.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2025-07-19 09:38:15 +02:00
Anas Nashif
1a7ce3f45e Revert "init: Make entry init-function less and introduce service objects"
This reverts commit 175da6bdb0.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2025-07-16 16:39:36 -05:00
Gaetan Perrot
dd180c2789 ipc_service: ipc_icbmsg: fix unchecked error in icmsg_open()
Coverity (CID 516253) reported that the return value of
initialize_tx_with_sid_disabled() was set but not used, leading to
potential silent failures.

Check if the return value is negative and propagate the error through the
existing cleanup path.

Fixes: CID 516253

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-11 13:15:04 -10:00
Robert Lubos
151295f98e net: sockets: Move socket vtable definition
Offloaded socket implementations need to create the socket operations
vtable, therefore need access to struct socket_op_vtable. So far this
has been defined in a private header, so implementations needed to add
the header location to the include path in CMake.

Therefore, move struct socket_op_vtable definition to the internal part
of the public socket header, so it's no longer needed to include a
private header. This is also more consistent with the rest of the public
header content, as for example macros needed to register a socket
implementation are already there.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-11 16:32:49 -05:00
Hake Huang
fb9783d880 tests: ztest: add test hold status in DEVICE_PM
for DEVICE_PM and DEVICE_PM_RUNTIME, ztest need
hold status like CONFIG_PM, otherwise the following
flash will be blocked for some SOC

Signed-off-by: Hake Huang <hake.huang@nxp.com>
2025-07-11 13:44:16 -05:00
Szymon Janc
d699e8ccf0 Bluetooth: Host: Make error messages unique
Both bt_le_adv_stop() and bt_le_adv_resume() were logging same
error message. Add aditional context to it so that logs are
distinguishable.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2025-07-11 08:25:53 -10:00
Andrey Dodonov
1c0608dc02 net: http: service: check for uncompressed file correctly
Correct not resetting compression extension,
when checking for an uncompressed file,
in case if compression is enabled, but no compressed file found.

Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
2025-07-10 16:01:47 -05:00
Robert Lubos
4872527605 net: coap_client: Don't send RST on unrecognized ACK response
According to CoAP RFC (7252, ch. 4.2), Reset cannot be sent in a
response for an ACK reply, rejected ACKs should be silently ignored
instead. Therefore, in case an unrecognized response is received, verify
the response type before sending Reset.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-10 16:01:03 -05:00
Simon Piriou
932005abf2 net: l2: ieee802154: mgmt: fix net_pkt leaks
The ieee802154_radio_send() function does not decrease reference counter
of the net_pkt, it's instead done one layer above in ieee802154_send().
This commit updates the mgmt functions using ieee802154_radio_send() to
always free the used net_pkt afterward.

Signed-off-by: Simon Piriou <spiriou31@gmail.com>
2025-07-10 10:13:35 -05:00
Lyle Zhu
e4569c434a Bluetooth: Classic: L2CAP: Fix retransmission timer restarting
When received the valid S frame, the retransmission timer should not
be restarted if unacknowledged I-frames have been sent but the
retransmission timer has not elapsed.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-07-09 09:43:12 -05:00
Vinayak Kariappa Chettimada
f6495d8b43 Bluetooth: Controller: Fix Tx Ack FIFO index corruption under race
Fix Tx Ack FIFO's first index being advanced beyond a
recorded ack_last value in a node_rx when under race
between ll_rx_get() being pre-empted while executing the
`tx_cmplt_get()` and a call to `ll_rx_put()` in an
interrupt service routine.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2025-07-09 09:42:58 -05:00
Simon Piriou
732a3a5c66 net: l2: ieee802154: shell: fix scan argc validation
Bump the argc check from 3 to 4 as the shell scan command has 3 required
parameters, the last being the scan duration:
- argv[0]
- passive|active
- channels
- per-channel duration in ms

Signed-off-by: Simon Piriou <spiriou31@gmail.com>
2025-07-09 00:26:29 -05:00
Luis Ubieda
b0caaed43b rtio: workq: Restructure workqueue as a threads pool with a queue
Based on a discussion around P4WQ limitations for our application, it
was determined that the RTIO workqueue required the ability to use
additional threads from the pool in spite of work items blocked.
Since this is not covered, nor desired for the P4WQ, then remove this
dependency and re-implement it in a way that covers also this use-case.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2025-07-08 18:35:26 -05:00
Loic Domaigne
a0a47a4b6d Bluetooth: ASCS: fix uninitialized pointer read
Fix uninitialized pointer read reported by Coverity.
Coverity CID: 529879

Signed-off-by: Loic Domaigne <tech@domaigne.com>
2025-07-08 13:44:37 -05:00
Lyle Zhu
d48e2bb4f4 Bluetooth: Classic: L2CAP: Fix issue that pending chan cannot be sent
When the returned buffer is a `NULL` of the pull function, it means
there is not any data needs to be sent. However maybe there is any
frame pending on other L2CAP channel needs to be sent over the same
ACL connection.

Re-trigger the TX processor. It will call the pull function again
and the pending buffer will be pulled from following L2CAP.

Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
2025-07-08 13:41:39 -05:00
Jukka Rissanen
69fddf8f0b net: dns: Check interfaces to be NULL before use
Make sure interfaces variable is not NULL before using it.

Coverity-CID: 529857

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2025-07-08 13:41:11 -05:00
Cheng Chang
80602f32c6 bluetooth: AVDTP:in set config_rej_rsp,LOSC can't be added.
The current logic will result in rsp always being accept because LOSC
added is 0. and according to the spec, LOSC should not be added to the
Set Configuration Reject response.

Signed-off-by: Cheng Chang <cheng.chang@nxp.com>
2025-07-08 13:37:37 -05:00
Olivier Lesage
aa4e6ac0dd bluetooth: host: Handle failure to disable scan when updating own_addr
It wasn't taken into account that bt_le_scan_set_enable()
has a return value. It's not likely that the controller
rejects the command when BT_DEV_SCANNING is set, however.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-07-08 13:37:26 -05:00
Olivier Lesage
ef7ede64cc bluetooth: host: Do not try to set NRPA when scanning with identity
Attempting this would fail (assuming the controller is implemented
correctly) because when using legacy commands it is not allowed to
change the device address while scanning.

It also did not make sense. If we have configured the scanner to use
the identity address as own_addr, because the advertiser and scanner
addresses are shared when using legacy commands, setting the adv NRPA
here would overwrite the identity address used by the scanner, which
I assume is not the intention.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-07-08 13:37:26 -05:00
Olivier Lesage
11782dbbc0 bluetooth: host: rename bool scan_enabled -> scan_disabled
It represents whether scanning was disabled as part of this flow.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-07-08 13:37:26 -05:00
Olivier Lesage
43223a1661 bluetooth: host: Fix uninitialized own_addr_type for legacy scan+adv
In 25c993e5b7 a new case was introduced
where own_addr_type is not set by bt_id_set_scan_own_addr properly.

This led to issues for users where increasing their zephyr version
led to failures to start scanning after advertising in the case where
CONFIG_BT_SCAN_WITH_IDENTITY=n and legacy advertising commands are used.

Signed-off-by: Olivier Lesage <olivier.lesage@nordicsemi.no>
2025-07-08 13:37:26 -05:00
Cheng Kai
ec0865cb4a Bluetooth: SDP: fix attr value len 32 invalid
fix sdp attr value len 32, which was not supported.

Signed-off-by: Cheng Kai <chengkai@xiaomi.com>
2025-07-07 10:13:47 -05:00
Make Shi
9104e941f9 Bluetooth: Classic: L2CAP: Set default value for BR timer timeout
When peer monitor and retransmission timeout are zero, set them to the
default values. This ensures that the monitor timeout is always a valid
value to avoid the L2CAP BR timer work queue hang.

Signed-off-by: Make Shi <make.shi@nxp.com>
2025-07-07 10:07:10 -05:00
Robert Lubos
8f983ccda5 net: lib: http_client: Fix end of message detection
HTTP 1.1 server has two ways of indicating the message body length -
either by providing the Content Length header, or by closing the
connection when the entire body has been transmitted.

The second method didn't work with Zephyr's HTTP client implementation,
as EOF on a socket was treated as an error condition. Therefore, if no
Content Length was provided by the server, such transfers would always
end up with ECONNRESET error.

In order to fix this, we need to notify the parser about the EOF on a
socket when connection is closed. It is the parser role to determine
whether the EOF was expected in current state (by marking end of message
flag) or not (by setting an error).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-07 10:04:17 -05:00
Gaetan Perrot
1610aa0e9f bluetooth: host: a2dp: remove redundant null check
Remove duplicated check for 'ep->stream == NULL' to clean up conditionals
and avoid unnecessary repeated evaluations.

This cleans up the code and avoids unnecessary repeated condition
evaluation.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 14:21:47 -10:00
Tim Pambor
6226bb1264 net: sockets_service: Fix function signature
Update the socket_service_thread function signature to match the expected
k_thread_entry_t type:
typedef void (*k_thread_entry_t)(void *p1, void *p2, void *p3);

Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
2025-07-04 14:21:23 -10:00
Jan Tore Guggedal
a7ce6055b7 zbus: Fix NULL pointer use in zbus_chan_rm_obs()
Fix a bug in zbus_chan_rm_obs() where removing the first observer in a
channel's observer list would cause undefined behavior due to accessing
a member of a NULL pointer.

The issue occurred when prev_obs_nd was NULL (indicating the first node
in the list) and the code attempted to pass &prev_obs_nd->node to
sys_slist_remove(). This resulted in accessing the 'node' member of a
NULL pointer, which is undefined behavior even when taking its address.

The sys_slist_remove() function is designed to handle a NULL prev_node
parameter correctly for removing the first element in a list. The fix
ensures we pass NULL directly instead of attempting to compute the
address of a member within a NULL pointer.

This was detected by Undefined Behavior Sanitizer as "member access
within null pointer".

Signed-off-by: Jan Tore Guggedal <jantore.guggedal@nordicsemi.no>
2025-07-04 15:49:32 -05:00
Gaetan Perrot
80df24e3b2 net: lib: coap: fix potential null pointer
In coap_well_known_core_get(), move the null check for 'resource' before
applying pointer arithmetic ('resource + 1') to avoid undefined behavior
when 'resource == NULL'.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
2025-07-04 15:48:40 -05:00
Robert Lubos
aa4a8789d5 net: sockets: socket_dispatcher: Fix close function type
Socket dispatcher (and offloaded implementations in tests) register
fd as ZVFS_MODE_IFSOCK therefore they should register a  close2(
function instead of close().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
a4fdd2c266 net: sockets: socketpair: Fix close function type
socketpair fd regsiters ZVFS_MODE_IFSOCK therefore it should register a
close2() function instead of close().

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
82945a7f52 net: l2: ieee802154: Prevent NULL pointer access
In case address mode in a packet is none, the address pointer within mhr
struct will not be set. Therefore, the pointer should not be used before
address mode is verified inside ieee802154_check_dst_addr().

This was reported by UBSAN:

  subsys/net/l2/ieee802154ieee802154.c:296:41: runtime error: member
  access within null pointer of type 'struct ieee802154_address_field'

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
31b79a93af net: pkt: Add explicit casts to uint32_t when bitshifting uint8_t val
Cast uint8_t variable to uint32_t explicitly to avoid implicit cast to
int, and thus potentially undefined behavior, reported by UBSAN:

  net_pkt.c:1946:17: runtime error: left shift of 239 by 24 places
  cannot be represented in type 'int'

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
7949789ce8 net: ip: utils: Avoid casting to in(6)_addr struct in net_addr_ntop()
In order to avoid alignment issues when casting void pointers to
in(6)_addr structures, create a properly aligned copy of the ip(v6)
address on stack.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
bd96b5dd83 net: lib: websocket: Avoid bitshift overflow warning
In order to prevent an overflow warning from UBSAN when bitshifting,
cast to uint64_t first before shifting, and then back to uint32_t.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
62a5260e01 net: Fix alignment error with net_ipaddr_copy()
As struct sockaddr have now alignment of 4 bytes, net_ipaddr_copy()
gives the following error if used for sockaddr:

  error: alignment 1 of ‘struct <anonymous>’ is less than 4
  [-Werror=packed-not-aligned]

Just use memcpy() instead, net_ipaddr_copy() was intended to use with IP
addresses, not socket related structs.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
8124032cbb net: ipv4: Avoid casting unaligned address to struct in_addr
Rework the IPv4-related code to avoid casting. Use raw variants of
IPv4-related functions whenever possible (especially on the critical
data path).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00
Robert Lubos
f549bfcfeb net: ipv4: Add raw variants of various IPv4 functions
To address the misaligned access issues reported by UBSAN, introduce raw
variant of certain IPv4 functions used in the critical data path of the
network stack, operating on plain uint8_t buffers in stead of IPv4
address struct.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2025-07-04 13:16:32 -05:00