Commit graph

21541 commits

Author SHA1 Message Date
Dominik Ermel
512dab526c mgmt/mcumgr: Add Kconfig option to select number of supported images
The commit adds IMG_MGMT_UPDATABLE_IMAGE_NUMBER Kconfig option, int,
that allows to select how many images are supported by mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-10-05 19:20:51 -04:00
Wolfgang Puffitsch
f3b97ccfb6 Bluetooth: controller: Introduce Kconfig for Read ISO Link Quality
Introduce Kconfig for Read ISO Link Quality command. Support for the
command is optional according to the specification.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
d58224566d Bluetooth: controller: Reorder variable declarations in ISO HCI commands
Reorder variable declarations in HCI command handlers of ISO-related
commands to conform to reverse Christmas tree style.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
7c0b74bc0d Bluetooth: controller: Fix use of handle field in HCI command handling
Fix use of handle field in HCI command handling for some ISO-related
commands. The response buffer may reuse the command buffer. Therefore,
the handle field must not be copied directly from the command to the
response.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Wolfgang Puffitsch
230f8db0d5 Bluetooth: controller: Update supported commands for ISO
Set bits for ISO-related supported commands depending on selected
features and adjust compilation guards for the respective handler
functions.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-10-04 20:48:01 -04:00
Trond Einar Snekvik
cd89f42393 Bluetooth: Mesh: Model extensions walk stops before last model
When reaching the last model in the circular extension linked list, the
walker would abandon the walk before checking the last model. This makes
us skip models when checking the subscription list, potentially causing
incoming messages to be wrongfully ignored.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-10-04 20:45:23 -04:00
Emil Gydesen
f9e2fc3fc4 Bluetooth: ISO: Move bt_iso_accept and make static
Move the function and make it static as it is only
used in iso.c and for unicast only.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-10-04 20:40:06 -04:00
Szymon Janc
088fac76ed Bluetooth: Mesh: Fix crash on disconnect
bt_mesh_proxy_role_setup() is called conditionally when peer is
connected and gatt_disconnected() is always called. This leads
to unbalance in role->conn reference count and crash.

Instead of hot-fixing this in gatt_disconnected(), this commit adds
proper bt_mesh_proxy_role_cleanup() API that is called by roles
implementations if cleanup is needed.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2021-10-04 18:52:08 +02:00
Vinayak Kariappa Chettimada
072c8f2c68 Bluetooth: Controller: Fix assertion failed [evdone]
When there are radio events with time reservations lower
than the preemption timeout of 1.5 ms, the pipeline has to
account for the maximum radio events that can be enqueued
during the preempt timeout duration. All these enqueued
events could be aborted in case of late scheduling needing
as many done event buffers.

During continuous scanning, there can be 1 active radio
event, 1 scan resume and 1 new scan prepare. If there are
peripheral prepares in addition, and due to late scheduling
all these will abort needing 4 done buffers.

If Extended Scanning is supported, then an additional
auxiliary scan event's prepare could be enqueued in the
pipeline during the preemption duration.

Fixes #36381.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-04 18:26:11 +02:00
Ingar Kulbrandstad
c1e053c9b3 Bluetooth: Mesh: Missed IV update cannot be captured
It seems that if the IV update is missed, a node cannot
recover it until the IV index has increased to a value
greater than Node's Last known IV + 1.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2021-10-04 08:37:43 -04:00
Szymon Janc
c589994dc0 bluetooth: Add support for reconfiguring L2CAP channels
This allows application to increase channel's MTU and (in some cases)
MPS. When channel gets reconfigured dedicated callback is called to
inform application.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2021-10-04 11:05:03 +02:00
Christopher Friedt
fa26dc0988 net: dns_sd, mdns: support service type enumeration
Support DNS-SD Service Type Enumeration in the dns_sd library
and mdns_responder sample application.

For more information, please see Section 9, "Service Type
Enumeration" in RFC 6763.

https://datatracker.ietf.org/doc/html/rfc6763

Fixes #38673

Signed-off-by: Christopher Friedt <chrisfriedt@gmail.com>
2021-10-01 20:11:50 -04:00
Vinayak Kariappa Chettimada
24596f5c08 Bluetooth: Controller: Refactor out sync setup addr and sid check
Refactor out the implementation of Periodic Sync Setup
address check including Periodic Advertiser List and SID.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
bf01d55107 Bluetooth: Controller: Implement Periodic Advertiser List
Implement support for Periodic Advertiser List to be used
in LE Periodic Advertising Create Sync command.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
d76711f187 Bluetooth: Controller: Refactor ull_filter adva_get and tgta_get
Refactor `ull_filter_adva_get` and `ull_filter_adva_get` to
input resolving index compare to adv context reference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Vinayak Kariappa Chettimada
4bfeee6d9e Bluetooth: Controller: Minor filter accept list related refactoring
Refactoring related to filter accept list, resolving list,
and removed the redundant anon variable.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 21:48:51 +02:00
Jakub Rzeszutko
8b8a3bbf71 shell: fix assert in panic mode
In panic mode, the function: z_shell_fprintf is expected to be
called from an interrupt context. Therefore, the dedicated assert
cannot be checked in this case.

Fixes #38612

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-10-01 14:42:25 -04:00
Aleksander Wasaznik
a5cf50e61f Bluetooth: Host: Fix resource leak in bt_gatt_unsubscribe
There are two simmilar functions for unsubscribing from GATT handles.

 - `gatt_sub_remove`, which is called on disconnect for every
 subscription will free the `subscriptions` entry when the entry
 represents no subscriptions.

 - `bt_gatt_unsubscribe`, called by the application, which forgets to
 free the `subscriptions` entry.

If all subscriptions grouped in a `subscriptions` entry are removed
using `bt_gatt_unsubscribe` before disconnect, there are no
subscriptions left to call `gatt_sub_remove` on. The `subscriptions`
entry is then never freed.

The above results in a resource leak of a `subscriptions` entry.

This fix makes explicit and enforces the invariant that there should not
be entries in `subscriptions` with an empty subscription list.

Fixes #38688

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2021-10-01 14:38:06 -04:00
Piotr Pryga
982743b765 tests: Bluetooth: df: Add test to verify correctness of relase of PDUs
Add unit tests that will ensure the CTE disable operation does not
cause breaking of LLL operations by too early release of chained PDUs.
The tests verify if numbers of PDUs in free PDUs fifo and free PDUs
memory pool are correct.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-01 14:32:49 -04:00
Piotr Pryga
a3378d1c9f Bluetooth: controller: Fix ASSERT caused by ULL releasing chain PDUs
When CTE is enabled for periodic advertising and number of CTE is
greater than number of PDUs in a chain, that are needed to transport
advertising data, there are additional empty PDUs used for transport
CTE.

CTE transmission may be disabled when periodic advertising event is
pending in LLL. rem_cte_info_from_per_adv_chain removed CTEInfo field
from extended advertising header in chained PDUs. When there were found
empty PDUs (created to transport CTE only), they were released from
the chain that was currently used by LLL. That caused an assert in
isr_tx handler due to broken advertising chain.

The rem_cte_info_from_per_adv_chain may not relese PDUs that are in
use by LLL. The PDUs may be released by LLL in prepare step when
advertising pdu double buffer is swapped by lll_adv_sync_data_latest-
_get.

This PR fixes that issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-10-01 14:32:49 -04:00
Vinayak Kariappa Chettimada
bacfd0175f Bluetooth: Controller: Fix assert on aux LLL scheduled chain reception
Fix asserted in ULL due to incorrect resumption of scan
window when auxiliary channel chain PDU is LLL scheduled by
a ULL scheduled auxiliary channel PDU reception.

The issue is solved by having `is_chain_sched` flag in the
auxiliary channel scan context and using the already present
`is_aux_sched` in the primary channel scan context to
differentiate if the auxiliary PDU Rx ISR is to return back
to primary channel scan window or to close the auxiliary
chain PDU reception radio event.

Relates to #38146.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 14:32:24 -04:00
Vinayak Kariappa Chettimada
e123c4e381 Bluetooth: Controller: Fix to ignore aux ptr in scannable advertising
Fix to ignore aux pointer struct in scanning advertising, to
avoid ULL scheduling from setting up ticker to receive chain
PDUs while LLL is receiving scan response PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-10-01 14:32:24 -04:00
Nick Ward
e0f18128bf task_wdt: fix silent init failures
The task_wdt_init() API can fail to install a timeout for the fallback
hardware WDT (hw_wdt) without returning an error code.  This patch
enables task_wdt_init() to return the hw_wdt install timeout error code
if the hw_wdt install timeout fails.

Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-10-01 15:21:32 +02:00
Eduardo Montoya
b945d7aee4 openthread: align platform code to ARM PSA changes
Align `otPlatRadioSetMacKey` with latest upstream changes.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-10-01 11:37:38 +02:00
Gerard Marull-Paretas
93de9b1d80 pm: stop handling devices on PM_STATE_RUNTIME_IDLE
According to the state documentation, this state does not need to handle
devices:

> Runtime idle is a system sleep state in which all of the cores enter
deepest possible idle state and wait for interrupts, no requirements for
the devices, leaving them at the states where they are.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-09-30 16:05:59 -04:00
Vinayak Kariappa Chettimada
5cb3721313 Bluetooth: Controller: Fix HCI command parameter check failures
Fix assorted HCI command parameter check failures faced
during conformance testing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-30 11:47:57 +02:00
Aleksandr Khromykh
797c17436b Bluetooth: Mesh: logging public key in big endian
Local public key has been logged in little endian but
remote public key in big endian. That has been changed.
Both are logged in big endian to be able to compare in logs.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2021-09-29 15:34:13 -04:00
Aleksandr Khromykh
ebf9a591d6 Bluetooth: Mesh: split debug for prov and prov_device
Debug configuration for prov and prov_device has been split
since prov general modul and it is used for provisioner as well.
It is not necessary to enable prov_device debugging
to debug provisioner.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2021-09-29 15:34:13 -04:00
Robert Gałat
464cd567a9 coredump_log: coredump log in panic mode
Current impementation assumes that CONFIG_LOG_IMMEDIATE=y
guarantees complete transfer, and it is not true.
In my opinion core dump should always be printed in panic mode.

Signed-off-by: Robert Gałat <robert.galat@nordicsemi.no>
2021-09-29 14:50:12 -04:00
Rubin Gerritsen
ca088aafbe Bluetooth: host: Warn on incomplete adv reports
When the controller forwards incomplete reports to the host,
the application currently has no way of reassembling them.
Therefore the application may fail to parse the data.

Issue a warning until
https://github.com/zephyrproject-rtos/zephyr/issues/37368
is resolved.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2021-09-29 14:47:47 -04:00
Vinayak Kariappa Chettimada
aa4b75b58c Bluetooth: Controller: Separate address get and read functions
Have separate Bluetooth Device address get and read
functions, remove use of function just to return Extended
Advertising Random address and replace with simple
assignment statement.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
d7cfb5473b Bluetooth: Controller: Use defines for aux pointer offset unit value
Use defines for aux pointer offset unit value.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
651137ee11 Bluetooth: Controller: Fix Extended Advertising channel use
Add implementation defined channel index in the auxiliary
pointer of the common extended payload format in the primary
channel PDUs and the same be used in the transmission of
auxiliary PDUs.

Fixes #35668.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3075ba92d1 Bluetooth: Controller: Add FIXME for Per Adv chain channel use
Add FIXME comments for missing use of channel selection
algorithm for Periodic Advertising chained PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
ec784fd420 Bluetooth: Controller: Add advertiser clock accuracy value
Add implementation to set correct Advertiser's clock
accuracy value in the auxiliary pointer field in the common
extended payload format.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
6af9a433c2 Bluetooth: controller: Fix populate offset in latest advertising PDU
Fix implementation to populate the aux, and sync offset
in the latest PDU. If both the current and latest of the
double buffer has been filled and LLL did not pick the
latest PDU, then the offset should be filled into the latest
PDU (and not into the first/current PDU).

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3ce9b2f2f5 Bluetooth: Controller: Minor indentation fixes
Minor indentation fixes.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
3a8bf279d9 Bluetooth: Controller: Explicitly typecast void return for memcpy calls
Explicitly typecast void return for memcpy calls.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Vinayak Kariappa Chettimada
ec10ef601d Bluetooth: Controller: Minor rename of ULL internal function
Rename ULL internal helper function to get the random
address.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 14:44:47 -04:00
Carles Cufi
301a7103a0 Bluetooth: common: Add build asserts for address struct sizes
In some HCI packed structures we place non-packed structs inside (in
particular the address structs).
Alignment is not an issue for those because all their members are just
byte-aligned, but size is. If the compiler ever packs those it would
become a real problem, and so detect this at build time.
See the link below for more info:
https://stackoverflow.com/a/66389167

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-09-29 19:07:52 +02:00
Joakim Andersson
da31a33905 Bluetooth: host: Access local IRKs consistently
Change the way the local IRKs are accessed to be consistent with the
all other uses.
Coverity thinks using the pointer to the array is suspicious in this
case.

Fixes: #38130

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-09-29 10:44:38 -04:00
Joakim Andersson
b7ad63362c Bluetooth: host: Verify valid local identity loaded from settings
Verify that the local identity loaded from the settings key is
valid for the current configuration.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-09-29 10:44:38 -04:00
Vinayak Kariappa Chettimada
ad36dcdf15 Bluetooth: Controller: Use defines for scanning state types
Use defines for scanning state types of passive, active,
initiator and synchronization state.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:05:57 +02:00
Vinayak Kariappa Chettimada
e0ac70ad91 Bluetooth: Controller: Allow resolving list update during passive scan
Allow resolving list update  when passive scanning,
otherwise deny if advertising, active scanning, initiating
or periodic sync create is active.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:05:57 +02:00
Vinayak Kariappa Chettimada
bbe8fe721b Bluetooth: Controller: Fix imprecise data bus error in periodic sync
Fix imprecise data bus error when receiving Periodic
Advertising Report caused due to uninitialized `extra` field
member in the node rx struct passed from ULL to LL thread
context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:02:37 +02:00
Vinayak Kariappa Chettimada
665a8d2c6e Bluetooth: Controller: Fix repeated per sync drift compensations
Fix repeated periodic sync drift compensation invoked when
receiving chain PDUs which caused memory corruptions and
bus faults.

Use `is_aux_sched` flag in Periodic Sync's LLL context to
differentiate between the first AUX_SYNC_IND PDU followed by
use of LLL scheduling to receive following AUX_CHAIN_IND PDU
versus ULL scheduling being used to receive AUX_CHAIN_IND
PDUs.

Drift compensation to be done only using the AUX_SYNC_IND
PDU and not on reception of AUX_CHAIN_IND PDU using ULL
scheduling.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-29 15:02:37 +02:00
Krzysztof Chruscinski
a18bc0f4f7 logging: Cleaning references to tracing in logging
There were some leftovers in logging after attempt to use
logging as tracing backend. Removing all references since it
lead to test compilation failures.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-09-29 14:59:36 +02:00
Robert Lubos
45e07dbbb3 net: sockets: tls: Ignore empty iovec entries in sendmsg
According to `sendmsg()` man pages, the `struct msghdr` can contain
empty records (iov_len equal to 0). Ignore them in TLS `sendmsg()`
implementation to avoid unnecessary calls to mbed TLS.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-09-29 11:08:40 +02:00
Robert Lubos
f0ec61ef70 net: mqtt: Handle incomplete zsock_sendmsg write
In case zsock_sendmsg did not send all of the data requested, update the
`struct msghdr` content and retry.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-09-29 11:08:40 +02:00
Robert Lubos
6e04a0f59d net: context: Do not overflow net_pkt when using msghdr
If data for `context_sendto()` was provided in a form of
`struct msghdr` (for instance via `sendmsg()`), it was not verified that
the provided data would actually fit into allocated net_pkt. In result,
and error could be returned in case the provided data was larger than
net_pkt allows.

Fix this, by verifying the remaining buffer length when iterating over
`struct msghdr`. Once the buffer is filled up, break the loop. In
result, functions like `sendmsg()` will return the actual length of data
sent instead of an error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-09-29 11:08:40 +02:00