Commit graph

16559 commits

Author SHA1 Message Date
Christopher Friedt 137097f5c3 logging: log_core: correct timeout of -1 ms to K_FOREVER
Many releases ago, specifying to block indefinitely in the log
processing thread would do just that.

However, a subtle bug was introduced  such that specifying -1
for `CONFIG_LOG_BLOCK_IN_THREAD_TIMEOUT_MS` would have the
exact opposite effect than what was intended.

As per Kconfig, a value of -1 should translate to a timeout of
`K_FOREVER`. However, conversion via `K_MSEC(-1)` results in
a `k_timeout_t` that is equal to `K_NO_WAIT` rather than the
intent which is `K_FOREVER`.

Add a dedicated check to to ensure that a value of -1 is
correctly interpreted as `K_FOREVER` in `log_core.c`.

For reference, the blocking feature was described in #15196,
added in #16194, and it would appear that the regression
happened in c5f2cdef09.

Signed-off-by: Christopher Friedt <cfriedt@meta.com>
2023-10-16 12:06:42 +02:00
Ladislav Podivin 390b6520b8 Logging: improve help message of LOG_PRINTK Kconfig option
Improve it so that:
- it mentions the important fact that it redirects `printk` messages
 to the logging subsystem
- it is consistent with the help messages of the other options in this
 file (i.e. it starts with "If enabled")

Signed-off-by: Ladislav Podivin <ladislav.podivin@tietoevry.com>
2023-10-13 22:36:47 +03:00
Tom Burdick c678f25bc1 llext: Fix a bug in section linking
When relocating section symbol addresses the value where the
relocation is to be written is an offset into the section to load.

Simply rewriting it with the section address is not enough, we need
to write the address of the section with the offset into it.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-10-13 16:47:02 +01:00
Jakub Rzeszutko 69d50db53a shell: fix a memory corruption coverity issue
Added a condition to check if the size of the copied
memory is a positive number.

Fixes #58700
Fixes #58703

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@verkada.com>
2023-10-13 13:11:28 +03:00
Dawid Niedzwiecki f02c612c99 mgmt: ec_host_cmd: align buffers
Align the rx and tx buffers to prevent unaligned access.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2023-10-13 11:59:33 +03:00
Alexander Stark d385d10130 mgmt: mcumgr: update bt smp initialization
Oneline fix to smp_bt.c smp transport register.
smp_client_transport_register() is a void function and
has no return value, so it should be ignored.

Signed-off-by: Alexander Stark <alexander.t.stark@gmail.com>
2023-10-13 09:40:21 +01:00
Flavio Ceolin 5fcae0c021 random: timer: Use build constant for seed
Use Kconfig symbol for initial seed.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-13 10:03:53 +03:00
Flavio Ceolin a99a0700ba random: kconfig: Allow customizing timer initial state
Add a build option to allow changing the initial state used
in the timer based random generator and by the kernel in the
early random number generator.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-13 10:03:53 +03:00
Mariusz Skamra 3828f1cec2 Bluetooth: ascs: Check subscription state on ASE notification
Check whether peer is subscribed for ASE state notification before
calling bt_gatt_notify. This handles an assert thrown when the
notification failed to be sent.

Fixes: #63728
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-12 18:48:09 +03:00
Emil Gydesen c47b7f7936 Bluetooth: BAP: Broadcast sink: Clear pa_sync on PA terminated
If the PA gets terminated, we clear the pa_sync field of the
corresponding broadcast sink object.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:19:46 +03:00
Emil Gydesen 00deb0ea75 Bluetooth: BAP: Remove static from state_changed in mod_src
For some reason the state_change variable was static, which
does not make any sense. Changed it to a regular local
bool in bt_bap_scan_delegator_mod_src.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Emil Gydesen 58e40239fd Bluetooth: BAP: Scan delegator missing state change for bis_sync
If the bis_sync value changes, that should trigger a state change
notification.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 18:18:42 +03:00
Aleksandr Khromykh 00457ae6c6 Bluetooth: Mesh: improve solicitation debug logging
Commits adds debug logging for all reasons
preventing of the proxy solicitation.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Aleksandr Khromykh 625faa7f03 Bluetooth: Mesh: fix proxy solicitation
Commit makes workable proxy solicitation functionality
only server part without dependencies on client part.
Only on demand proxy server is required.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-10-12 18:07:50 +03:00
Pavel Vasilyev 0af523eba7 Bluetooth: Mesh: Fix failing DFU/SR/FD/BV-08-C test
The `upload_status_rsp_with_progress` function uses the currently set
slot pointer to set firmware id field in the message. If another
upload starts but the firmware is already received, the slot API won't
let us to set the fwid and will return an error code. In this case, the
slot pointer stays invalid as fwid wasn't set, and
`upload_status_rsp_with_progress` will not add fwid as the lenght is
zero.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 15:29:45 +03:00
Pavel Vasilyev 5cf6218c62 Bluetooth: Mesh: Fix Capabilities Status message with OOB upload enabled
The `else` case was incorrectly excluded by preprocessor.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-12 13:59:06 +03:00
Jamie McCrae c67560cbbd mcumgr: grp: settings_mgmt: Handle settings return values
Handles return values from settings handlers which were missing
and would return "Unknown error" to clients instead of the read
error

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:54:30 +01:00
Jamie McCrae 828940b420 mcumgr: grp: fs_mgmt: Fix error on hash/checksum of empty file
Fixes the error code being returned when trying to perform a
hash/checksum on an empty file to show it is because the file is
empty, not because a paramter (which was not provided) was too
large.

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:54:01 +01:00
Jamie McCrae 65bb96f37c retention: blinfo: Fix issue with crash writing to keys
Fixes an issue which would cause a fault if someone attempted
to write to the (non-writable) blinfo keys

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
2023-10-12 11:53:21 +01:00
Jukka Rissanen 0a16d5c7c3 net: socket: mgmt: Check buf size in recvfrom()
Return EMSGSIZE if trying to copy too much data into
user supplied buffer.

Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
2023-10-12 10:33:36 +03:00
Vinayak Kariappa Chettimada 7ee427ff58 Bluetooth: Controller: Fix CIS encryption when DF support enabled
Fix hung Controller when establishing CIS on an encrypted
ACL connection with Controller built with direction finding
support enabled.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-12 09:48:54 +03:00
Emil Gydesen de67ec9e67 Bluetooth: BAP: Fix broadcast source reconfig with subset of streams
When the bt_bap_broadcast_source_reconfig was supplied with a subset
of the streams, it would only update the codec cfg and qos for the
streams provided in the parameters.

This commit changes that, so all streams are properly updated,
as they share some common values.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:41:30 +03:00
Emil Gydesen 7339849077 Bluetooth: BAP: Broadcast Sink should not terminate the PA Sync
When calling bt_bap_broadcast_sink_delete, the broadcast sink
should not attempt to terminate the PA Sync. The PA sync can live
on without the broadcast sink, just as the broadcast sink can live
on without the PA sync (which is why the PA sync check was completely
removed).

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:40:41 +03:00
Emil Gydesen 37b6ddd918 Bluetooth: BAP: Broadcast Sink only set synced BIS indexes
When updating the Scan Delegator receive state, we shall only
set the BIS indexes in bis_sync that we are actually synced to.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-12 09:33:55 +03:00
Bjarki Arge Andreasen 517bec233e modem: modem_cmux: Increase modem cmux buf size
This commit increases the buffer used for commands
in the control channel within an instance of the
modem_cmux module. The buffer was not large enough to
store an MSC command if the optional break signals
where included. This commit fixes the issue and
updates the test suite to use the max size MSC message.

Signed-off-by: Bjarki Arge Andreasen <baa@trackunit.com>
2023-10-11 18:57:11 +03:00
Pavel Vasilyev 2c9fc043d7 Bluetooth: Mesh: Print URI and FWID in Upload OOB Start msg
this is useful for debugging.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev d1c2ca2525 Bluetooth: Mesh: Release previously reserved slot before reserving again
If the previous upload was in-band and it didn't complete, the slot will
stay reserved. By design we release slot not at the end of the upload
phase, but at the start of a new upload phase.

This fixes DFU/SR/FD/BV-13-C.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev 7154f356af Bluetooth: Mesh: Ignore duplicate OOB upload request
If a Fw Distribution Client sends the Upload OOB Start message, but the
application layer didn't call bt_mesh_dfd_srv_oob_check_complete yet,
we have no other option other than ignore the message. The next phase
in this case could be Transfer Active, Transfer Success or Failed and it
will be set only after Check Firmware OOB procedure completes.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev 1329a9d312 Bluetooth: Mesh: Fix Fw Dist Upload OOB Start msg length check
This message _at least_ 2 bytes long, but can be longer, thus
BT_MESH_LEN_MIN should be used.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Pavel Vasilyev 9641864a20 Bluetooth: Mesh: Fix Upload Progress for already received fw
In OOB upload, when Check Firmware OOB procedure completes successfully
and the firmware is already received, we send Firmware Distribution
Upload Status message with update Phase set to Transfer Success. In this
case, we must set Upload Progress to 100%. This can't be done through
the callback as the application layer doesn't yet know that the firmware
is already received. This will happen by the exist from
bt_mesh_dfd_srv_oob_check_complete function, which will return error
code -EEXIST.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-11 14:04:11 +03:00
Mariusz Skamra 916df03e7a Bluetooth: ascs: Fix Source ASE link loss state transition
According to the ASCS_v1.0 the ASE in Streaming state shall transit to
QoS Configured state when link loss happen.

Relates: ES-24215 (errata)
Fixes: BAP/USR/SCC/BV-168-C
Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2023-10-10 15:18:37 +03:00
Flavio Ceolin e7bd10ae71 random: Rename random header
rand32.h does not make much sense, since the random subsystem
provides more APIs than just getting a random 32 bits value.

Rename it to random.h and get consistently with other
subsystems.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2023-10-10 14:23:50 +03:00
Pavel Vasilyev 68365d5b67 Bluetooth: Mesh: Reset targets state before starting DFU on DFD srv
The list of receives in the Firmware Distribution Server model and
and the Firmware Update Client model are 2 different lists.

In the Firmware Update Client model it is called the Update Receives
state and the Active Update Receivers state which is a subset of
receivers from the Update Receivers State. In the Firmware Distribution
Server model it is called the Distribution Receivers List state.

When Distribute Firmware procedure starts, in the Initiate step, the
Receivers List input (which is the input for the Update Receivers
state), is composed of the Distribution Receives List state. During DFU,
the Update Receivers state becomes the Active Update Receivers state
which keeps only active nodes. Timed out or failed nodes dropped out
from this list. The Distribution Receivers List state stays unchanged
and thus don't need to be populated again after every successfull and
failed DFU.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-09 16:18:53 +03:00
Martin Jäger 33bd2fed08 task_wdt: fix race condition for task_wdt_add function
The task_wdt_add function changes the reload_period of the channel to a
non-null value, which indicates that the channel is used. If the
function is interrupted by a task_wdt_trigger running in ISR context
before adding of the new channel has finished, the next timeout will be
scheduled based on inconsistent channel data.

Using a spinlock avoids such data races.

Fixes #61004

Signed-off-by: Martin Jäger <martin@libre.solar>
2023-10-09 16:10:00 +03:00
Håvard Reierstad 3d40d91f86 Bluetooth: mesh: access: Fix model relation register
Added offset to the model relation register for vendor
models to find correct model index
for Composition Data Page 1. The previous implementation used the
'mod_idx' from the 'bt_mesh_model' struct, which led to issues in the
model relation register due to SIG and vender models having the same
model index.
Modified existing functions related to the model relation
register to take in the offset.

Modified macros for determining if a model is a base- or
extending model.

Added check in 'add_items_to_page' to check whether the model relation
is an extension.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Håvard Reierstad ea753eb52a Bluetooth: mesh: Change cfg_cli buffer length check
Changed buffer length check in bt_mesh_comp_p1_elem_pull.
The previous threshold would result in the
method not detecting the final element when it consisted of just one
model.

Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
2023-10-09 15:06:06 +03:00
Jeroen van Dooren fe8d30dd42 net: ip: tcp: Fix kernel crash on idle thread
Fixing kernel crash caused by memory release
while having a scheduled work item pending.

Signed-off-by: Jeroen van Dooren <jeroen.van.dooren@nobleo.nl>
2023-10-09 10:16:05 +02:00
Dennis Grijalva b122685eff bluetooth: conn: Fix compiler warning
When compiling conn.c using arm-none-eabi-gcc version 11.3.1 20220712
with the -Wmaybe-uninitialized flag a warning is emitted due to
pending_no_cb not being initialized. I'm not sure if initializing it to
NULL is the "correct" fix, but it's certainly not any worse then it being
uninitialized, and it fixes the warning.

Signed-off-by: Dennis Grijalva <dennisgrijalva@meta.com>
2023-10-08 18:17:22 +03:00
Carles Cufi f2af4a7bfd Bluetooth: host: document the connection states
Connection states are non-trivial to understand based on their names
only, so add short descriptions in the header file explaining what they
do.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 17:50:03 +03:00
Fredrik Danebjer fefbb28edb Bluetooth: Audio: Fix return code in PACS notify
Fix errenous return value in pacs_gatt_notify function. The function
would always return zero, and not forward the error correctly.

Signed-off-by: Fredrik Danebjer <frdn@demant.com>
2023-10-06 17:43:08 +03:00
Pavel Vasilyev f4a592f3bb Bluetooth: Mesh: Don't reset mod pointer
Don't reset values set in init callback as it is called only once by
bt_mesh_init call. The reset callback is called on every node reset.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2023-10-06 16:47:09 +03:00
Anders Storrø 65f029e185 Bluetooth: Mesh: Common comp page parse func
Create common composition page parser function.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Anders Storrø 57cb1b1ccb Bluetooth: Mesh: Add missing comp pages to LCD mod
Adds support for all composition data pages to the
Large Composition Data model.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
2023-10-06 16:21:02 +03:00
Carles Cufi ee0314a832 Bluetooth: host: Replace length check assert with if statement
A few of the length checks that deal with HCI packets coming from the
controller were using assert statements. But the recommended practice is
to drop invalid packets and continue execution whenever a malformed
packet arrives from an external source, so replace those assert
statements with branches that will drop the packet and return.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 16:18:43 +03:00
Ingar Kulbrandstad a5d15ec017 Bluetooth: Mesh: Fixed issue with RPR server and client.
Fixed issue when reprovisioning is done on a device with
both RPR client and server on the same device.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2023-10-06 16:06:12 +03:00
Andries Kruithof e8716bf793 Bluetooth: controller: change calc for data in PDU
The existing formula for the amount of data that can be filled
in in the current PDU is correct but confusing. Replace it with
a simpler formula.

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Andries Kruithof d00d44c925 Bluetooth: controller: fix failing EBQ advertising tests
Updates the chaining for advertising.
Instead of unconditionally adding a new PDU when new data
is added we now instead fill the last PDU in the chain with
the incoming data, only adding a new PDU when there is
not enough room.

This reduces the nr. of PDUs used for advertising, and also
fixes some qualification failures

Signed-off-by: Andries Kruithof <andries.kruithof@nordicsemi.no>
2023-10-06 16:04:11 +03:00
Emil Gydesen af953a1d07 Bluetooth: BAP: Fix bug in BASE bis index
The indexes were reset to 0 for each subgroup, which meant
that if we had a broadcast source with 2 subgroups and
1 BIS in each, both of them would use index 0x01.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-10-06 12:21:42 +01:00
Jonathan Rico b1da312e9d Bluetooth: ATT: discard RX on a disconnected connection
A race condition between ATT RX and the connection teardown can happen, as
the teardown is executed from a workqueue.

For example:
- connection is established
- `connected` cb is called (in BT RX context)
- user calls `bt_conn_disconnect` in that cb
- connection is marked as disconnecting
- ATT teardown & general conn cleanup is scheduled
- BT RX gets an ATT request, tries to handle it
- ATT bearer is still not GC'd, so it tries and fails to send it
  -> results in error message "not connected" on log
- ATT teardown & general conn cleanup runs

To avoid that, we not only check the bearer state, but also its ACL conn
state.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-10-06 12:19:39 +01:00
Vinayak Kariappa Chettimada e50748b67c Bluetooth: Controller: Fix leak in scheduled ticker node
Fix leak in scheduled ticker node when rescheduling ticker
nodes.

Applications having active Extended Advertising or Observer
role with the use of ticker reschedule in window feature
would experience assertion check failure due to delayed
radio event preparation or stalled controller with no active
roles.

Fix updating of the ticker linked list when handling
rescheduled tickers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2023-10-06 12:54:12 +02:00