Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
449d0b29b7 Bluetooth: Controller: Fix extended advertising timeout
Fix extended advertising PDUs seen after the advertising
duration has elapsed, by considering the events skipped
due to overlap with other events which is provided by
the ticker lazy parameter.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-19 12:04:56 +02:00
Vinayak Kariappa Chettimada
5659b005f1 Bluetooth: Controller: Add checks for invalid PHYs
Add checks for invalid PHYs supplied to HCI LE Extended Scan
Parameters and LE Extended Create Connection commands.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-19 12:04:36 +02:00
Vinayak Kariappa Chettimada
027835fea6 Bluetooth: Controller: Disallow anonymous legacy advertising
Check and disallow legacy advertising from being anonymous.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-19 12:03:35 +02:00
Marcin Niestroj
577315c4ff fs: littlefs: drop newline character in log messages
Newline character is automatically appended in log backends such as
UART, so there is no need to add it explicitly.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-19 12:03:15 +02:00
Marcin Niestroj
c314557f2a fs: shell: fix incorrect message format when mount fails
There is '%u' and '%d' in format message, while there is only one
argument (besides format string). Remove ununsed '%u' to stop printing
garbage.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-19 12:02:58 +02:00
Marcin Niestroj
8e1a071725 logging: allow timestamp formatting for FS backend
FS backend is no different when it comes to producing human readable
timestamp. Allow to select it when FS is the only enabled logging
backend.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-07-19 12:02:43 +02:00
Johann Fischer
8b37c62b35 usb: remove useless len argument from usb_data_to_host()
The len argument always has the same value as
usb_dev.setup.wLength, which is also the last received
USB device request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-07-19 04:01:22 -04:00
Piotr Pryga
378a1e082a Bluetooth: controller: remove unnecessary ull_adv_ext_hdr_data struct
After extracting from ull_adv_sync_pdu_set_clear functions:
ull_adv_sync_pdu_alloc, ull_adv_sync_extra_data_set_clear
Use of ull_adv_ext_hrd_data structure became unnecessary.
The extra_data member of the structure was never used
due to separate function responsible for setting extra_data
content.
In all cases content for extended advertising header fields
may be passed to the ull_adv_sync_pdu_set_clear directly
as void * pointer, instead of pointer to ull_adv_ext_hdr_data.

This simplifies use of ull_adv_sync_pdu_set_clear as well
as removes unneccesary code to handle special structure type.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-07-17 16:43:08 -04:00
Piotr Pryga
4c3d76bf8b Bluetooth: controller: remove extra_data use in BIG create and terminate
extra_data is not used by ll_big_create and ll_big_terminate.
extra_data_prev and extra_data_new are optional arguments for
ull_adv_sync_pdu_alloc.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-07-17 16:43:08 -04:00
Piotr Pryga
bef9d14f7f Bluetooth: controller: simplify arg list of ull_adv_sync_pdu_alloc
ull_adv_sync_pdu_alloc function was extracted from ull_adv_sync_pdu_-
-set_clear function. The arguments list of ull_adv_sync_pdu_alloc
was derived from source function but the acutal functionality is
only part of what it was before.

The ull_adv_sync_pdu_alloc does not change extended advertising
PDU header fileds. The hdr_add_fields and hdr_rem_fields arguments
were used to allocate or not allocate memory for extra_data related
with new periodic advertising PDU. Also hrd_data pointer was
not used by the function.

The function arguments list was simplified.
New enum ull_adv_pdu_extra_data_flag was introduced to provide
named flags for extra_data memory management.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-07-17 16:43:08 -04:00
Robert Lubos
8a4e489739 net: sockets: dtls: Fix handshake with socket offloading
Fix `poll()` handling for DTLS clients when the underlying socket is an
offloaded socket. As in this case no `k_poll()` is used underneath, it's
not possible to monitor the handhshake status with `tls_established`
semaphore. Instead, do the following:

1. If no handhshake is in progress yet, just drop the incoming data -
   it's the client who should initiate the handshake, any data incoming
   before that should not be processed.
2. If handshake is currently in progress, lift the `POLLIN` flag and add
   small delay to allow the other thread to proceed with the handshake.
3. Otherwise, just proceed as usual.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-16 22:09:58 -04:00
Robert Lubos
b4366a8732 net: sockets: tls: Fix handshake on non blocking sockets
The TLS/DTLS handshake in most cases is a blocking process, therefore
the underlying socket should be in a blocking mode to prevent busy
looping in the handshake thread. Fix this by clearing the O_NONBLOCK
flag on the underlying socket before the handshake, and restoring it
afterards.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-07-16 22:09:04 -04:00
Elliot Revell-Nash
15318634b7 logging: count file with index 0 as log file too
Fixes #36667

If you had a single log file with index 0 created and you reboot
the log backend wasn't counting it and was overwiting it.
If you filled that file up before rebooting then it worked as
expected, creating a new file at the next index on each boot.

Signed-off-by: Elliot Revell-Nash <elliot.revell-nash@wdtl.com>
2021-07-16 21:55:55 -04:00
Marcin Jeliński
20d63b078c ipc: ipc_service: RPMsg multi-instance as backend for IPC Service
Implementation of the backend for IPC Service.
Multi-instance RPMsg was used as a backend.

Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
2021-07-16 21:43:39 -04:00
Marcin Jeliński
3fcd8d1003 ipc: Added IPC Service to support different transport backends
IPC Service allow plugging in different transport backends.
Specifies a generic API that is implemented by the backend.

Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
2021-07-16 21:43:39 -04:00
Marcin Jeliński
54d2eb45a1 ipc: Add multiple instances RPMsg
This patch implements a service that adds multiple instances
capabilities to RPMsg.
Each instance is allocated a separate piece of shared memory.
Multiple instances provide independent message processing.
Each instance has its own work_q.

Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
2021-07-16 21:43:39 -04:00
Vinayak Kariappa Chettimada
78e3fe3d75 Bluetooth: Controller: Refactor Periodic Advertising time update
Refactor Periodic Advertising time update function to use
caller supplied Periodic Advertising PDU to calculate the
time reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
ab6d4693da Bluetooth: Controller: Use BT_HCI_ERR_SUCCESS return and other changes
Apply suggestions from code review, and change to using
BT_HCI_ERR_SUCCESS instead of returning 0.

Co-authored-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
ead034d514 Bluetooth: Controller: Fix Extended and Periodic Coded PHY time
Fix Extended and Periodic Coded PHY time reservation. The
define earlier used does not have calculations for Coded
PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
177ebac790 Bluetooth: Controller: Periodic advertising time reservation
Implementation to update Periodic Advertising time
reservations when advertising data and/or CTE length is
updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
91956dadcd Bluetooth: Controller: Disallow Periodic Adv Enable if already enabled
Add check for already enabled and started Periodic
Advertising when HCI LE Set Periodic Advertising Parameters
command is called.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
baca5c2c55 Bluetooth: Controller: Refactor out Periodic Advertising time calc
Refactor out Periodic Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data updates.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
f93e41202d Bluetooth: Controller: Extended advertising time reservation
Implementation to update Extended Advertising time
reservations when advertising and scan response data are
updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
9928c81fbf Bluetooth: Controller: Export primary adv channel event time calc
Export the function calculating the primary channel
advertising event time reservation, so that Extended
Advertising implementation can reuse it.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
dd1b296d46 Bluetooth: Controller: Update DID when scan response data removed
Update DID value when scan response data is remove, length
set to 0.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
739b8ad903 Bluetooth: Controller: Refactor out Extended Advertising time calc
Refactor out Extended Advertising time calculations so that
it can be reused when PDU length is updated as part of
advertising data and scan response data updates.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
ee04896ca9 Bluetooth: Controller: Legacy advertising time reservation
Implementation to update legacy advertising time
reservations when advertising and scan response data are
updated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
e50e4f97e0 Bluetooth: Controller: Refactor out advertising time calculations
Refactor out advertising time calculations so that it can be
reused when PDU length is updated as part of advertising
data and scan response data updates.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
85c4095b76 Bluetooth: controller: Extended/Periodic Advertising time reservations
Add Extended and Periodic Advertising radio event time
reservations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Vinayak Kariappa Chettimada
8822b24b17 Bluetooth: Controller: nRF5: Use conservative Tx-Rx turnaround timing
Use a conservative turnaround time of 150us covering slower
nRF51 and faster nRF52 CPU that influence the turnaround
timing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-16 10:48:39 +02:00
Pieter De Gendt
de13034502 net: openthread: add Kconfig options for periodic parent search
The openthread has enhanced features for periodic parent search,
this commit adds kconfig options to enable and configure these.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-07-15 15:16:32 +02:00
Vinayak Kariappa Chettimada
7cd77c2cec Bluetooth: Add identifiers for Bluetooth 5.3
The Bluetooth 5.3 specification was recently released, and
has a new version identifier (12) assigned to it in the
Bluetooth Assigned Numbers.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-07-15 13:56:03 +02:00
Marcin Niestroj
1ce1d19bb5 net: pkt: introduce net_pkt_remove_tail()
Introduce a helper function for being able to remove any arbitrary
length from tail of packet. This is handy in cases when removing
unneeded data, like CRC once it was verified.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-07-15 06:54:33 -04:00
Piotr Pryga
a95457a984 Bluetooth: controller: df: Fixes truncated transmission of CTE
There was an issue with wrong length of CTE send in connectionless
mode, with periodic advertising PDUs. Radio peripheral was not
configured to send CTE with correct length while PDU had CTEInfo
field informing receiver that CTE is attached to the PDU.

Source of the problem was in ll_df_set_cl_cte_tx_enable function.

Order of parameters in ull_adv_sync_pdu_alloc was wrong.
ULL_ADV_PDU_HDR_FIELD_CTE_INFO was speficed as hdr_rem_fields.
Because of that extra_data, memory used to provide CTE configuration
to LLL, was not allocated. PDU content is prepared in ULL, so CTEInfo
field included correct information, while Radio was never configured
by LLL to send CTE.

ull_adv_sync_extra_data_set_clear received a pointer to hdr_data,
instead of a direct pointer to df_cfg structure. When extra_data
was allocated correclty, wrong CTE configuration was provided
copied there and LLL received invalid CTE length. It was different
than the length in PDUs CTEInfo field.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-07-15 11:39:13 +02:00
Michał Narajowski
ca53e86f67 Bluetooth: Mesh: Add msg length check for Cfg and Health models
According to spec we should ignore messages with incorrect msg size.
This patch adds a check to every opcode handler.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-07-15 11:34:52 +02:00
Michał Narajowski
b9422ea9f3 Bluetooth: Mesh: Add return value for opcode callback
```
3.7.3.4 Message error procedure
When receiving a message that is not understood by an element, it shall
ignore the message.
Note: A message can be falsely identified as a valid message, passing
the NetMIC and TransMIC authentication using a known network key and
application key even though that message was sent using different keys.
The decryption of that message using the wrong keys would result in a
message that is not understood by the element. The probability of such a
situation occurring is small but not insignificant.
A message that is not understood includes messages that have one or more
of the following conditions:
• The application opcode is unknown by the receiving element.
• The access message size for the application opcode is incorrect.
• The application parameters contain values that are currently
Prohibited.
Note: An element that sends an acknowledged message that is not
understood by a peer node will not receive any response message.
```

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-07-15 11:34:52 +02:00
Eduardo Montoya
72cc39d843 net: openthread: handle NONE level logs
`OT_LOG_LEVEL_NONE` has some uses within OpenThread but it is not
hanled in the Zephyr's platform implementation. This commit makes
use of those logs as `LOG_LEVEL_ERR` level.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-07-14 13:14:59 -04:00
Krzysztof Chruscinski
f7efacf441 logging: log_backend_spinel: Add support for logging v2
Added support for logging v2 backend API in spinel backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-14 11:06:46 -05:00
Krzysztof Chruscinski
940a54c6f6 logging: log_backend_xtensa_sim: Add support for logging v2
Added support for logging v2 backend API in xtensa_sim.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-14 11:05:15 -05:00
Alexander Wachter
ad130f2661 cpp: Restore C++2A Kconfig
Restore the legacy C++2a Kconfig for compilers that
do not support C++20.

Signed-off-by: Alexander Wachter <alexander.wachter@leica-geosystems.com>
2021-07-14 07:19:43 -04:00
Ingar Kulbrandstad
3ec6411c7f Bluetooth: Mesh: Align capitalization for BT mesh
Align the capitalization of the term "Bluetooth Mesh" to Bluetooth mesh"
in the documentation. This is done to to match the new updated naming
convention done in Bluetooth SIG. In the upcoming spec versions, it its
used "Bluetooth mesh" with the lower case convention.

Signed-off-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
2021-07-13 11:23:54 -04:00
Krzysztof Chruscinski
d90775a014 logging: Shell commands available when shell acts as log backend
Some commands shell not be present when shell is not acting as
a log backend. Use of them lead to crash in that case.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-13 10:12:27 -04:00
Dan Kalowsky
9b33391147 subsys/cpp: add support for C++2b
Add the ability to enable support for C++2B (aka 23) to the build
system.

Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
2021-07-13 09:40:51 -04:00
Dan Kalowsky
c0811e9951 subsys/cpp: update tag for C++2a to C++20
C++20 was tagged and released in December of 2020.  It is no longer
forth coming.

Signed-off-by: Dan Kalowsky <dkalowsky@amperecomputing.com>
2021-07-13 09:40:51 -04:00
Krzysztof Chruscinski
28be4ba91d logging: log_backend_net: Add support for logging v2
Added support for logging v2 backend API in net backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-13 09:39:28 -04:00
Gerard Marull-Paretas
26ad8376bd pm: remove callback from control function
The callback is not used anymore, so just delete it from the pm_control
callback signature.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Gerard Marull-Paretas
a4f22b6235 pm: device: remove runtime PM callback
The callback used by the device runtime PM can be easily replaced by a
simple state set after calling the state set/get calls. Broadcast logic
is simplified too, leading to the same previous behavior.

Since this is the only place where this callback was used, it can now be
removed from all devices and so pm_control callback signature
simplified.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-13 09:36:45 -04:00
Mark Wang
149d490b3f Bluetooth: SDP: judge the buf->len before sys_get_be16
There may be less than 2 bytes in buf before calling sys_get_be16.

Signed-off-by: Mark Wang <yichang.wang@nxp.com>
2021-07-13 14:18:28 +03:00
Dominik Ermel
6617af02c4 subsys/mgmt/mcumgr: Add SMP Zephyr specific storage erase command
The commit adds support for Zephyr basic mgmt group to mcumgr.
The first command added to the group is storage erase command.

Authored-by: Sigvart Hovland <sigvart.hovland@nordicsemi.no>
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-13 11:56:39 +02:00
Chih Hung Yu
a927ae39ed net: lib: sockets: Fix assertion failure when zsock_close()
When zsock_close() is called, socket is freed before the mutex for the
socket is unlocked. If the freed socket is given to another thread
immediately, the mutex for the socket will be initialized by the new
socket owner, while the mutex is still locked by the thread calling
zosck_close().

Fixes #36568

Signed-off-by: Chih Hung Yu <chyu313@gmail.com>
2021-07-12 20:16:37 -04:00