Commit graph

21541 commits

Author SHA1 Message Date
Andrzej Kaczmarek
ebb5b9a558 Bluetooth: shell: Fix 'bt per-adv-data'
ad_len parameter is not length of complete advertising data, but number
of bt_data structs passed to bt_le_per_adv_set_data - we pass only one.

Also memset target buffer before converting hex string so data shorter
than specified will be right-padded with zeroes instead of some
leftovers.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-02-02 07:15:40 -05:00
Peter Bigot
487b0002cb tests: fs: littlefs: update filecache configuration
The mem_pool Kconfig API is deprecated as allocation now uses a k_heap.
Update to allocate a heap with the same amount of memory as was
defaulted with mem_pool customization.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-02-02 07:15:17 -05:00
Peter Bigot
8ea2956ca3 fs: littlefs: revise how per-file cache memory is allocated
Originally the file cache used a mem_pool, but that data structure has
been deprecated and replaced by a heap that includes metadata in the
heap area.  As a result attempts to allocate all blocks will fail
because some of the reservation intended for cache data is now holding
metadata instead.

It's not immediately clear how to adjust the required heap size to
support this metadata as it depends on heap chunk units and data
structures that are not visible to the application.  Experimentally a
value of 24 bytes works, while smaller values do not.

Further the previous Kconfig API to configure the allocation pool is
completely inappropriate with the new heap data structure which has
such different behavior.

So: Deprecate the old Kconfig API.  Add a new Kconfig option to
directly control the cache size.  Infer a default cache size that
works with the old mem_pool parameters assuming a per-block overhead.
But to avoid wasted memory use the heap allocation only when the
application customizes the size, and use a slab in other cases.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-02-02 07:15:17 -05:00
Jukka Rissanen
4c8760b299 net: tcp2: Properly cleanup receive queue
When pushing received data to the application, check that app
was able to receive the data. If the application already closed
the socket, then we must free the received net_pkt in order to
avoid memory leak.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-01 15:23:33 -05:00
Jukka Rissanen
de72faeb2c net: tcp2: slist API is not thread safe so use locking
Make sure we lock when accessing the slist, as it is not
a thread safe API.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-01 15:23:33 -05:00
Jukka Rissanen
a5f9520428 net: tcp2: Cleanup properly if running out of mem
If we cannot allocate net_pkt or net_buf, then check this condition
properly and release other resources that were already allocated.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-01 15:23:33 -05:00
Peter Bigot
0ef7be2f6f power: allow finer control of PM selection
Some targets, such as network cores on a multi-core SoC, do not
support system power management because they do not control the SoC.
Provide a flag that can be selected to inihibit enabling system power
management on those targets.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-02-01 15:05:03 -05:00
Peter Bigot
5d2acb30eb Revert "soc: nordic: Disable PM for SOC_NRF5340_CPUNET_QKAA"
This reverts commit f38ba314ea.

nrf5340dk_nrf5340_cpunet doesn't support power management, but that
should be handled another way.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2021-02-01 15:05:03 -05:00
Jukka Rissanen
7ae54adc37 net: tcp2: Create a timer for connection establishment
We need to make sure that when listening a connection establishment,
the connection gets cleared if we do not receive final ACK.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-02-01 12:32:30 -05:00
Nicolas LANTZ
942979b252 Bluetooth: Mesh: Fix fix mod_sub_get_vnd
pass cid instead of CID_NVAL in parameters of mod_member_list_get

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2021-02-01 08:38:24 -05:00
Vinayak Kariappa Chettimada
b8b946f37f Bluetooth: controller: Fix rx_demux scheduling for LOW_LAT_ULL
Fix the mayfly callee id for the rx_demux scheduling under
the LOW_LAT_ULL implementation. This could be causing
undefined mayfly execution behavior in nRF51x SoC.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-02-01 08:36:19 -05:00
Joakim Andersson
c14da53772 Bluetooth: host: Remove the deprecated bt_conn_create_slave_le function
Remove the deprecated bt_conn_create_slave_le function.
This was deprecated in the 2.3.0 release.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-29 12:53:10 -05:00
Dominik Ermel
d4666f537c fs: Fix fs_open resource leak when invoked on fs_file_t object in use
Fixes problem when fs_open invoked on fs_file_t object, which is already
holding information on opened file, overwrites references to other
memory objects within the fs_file_t object causing resource leak.
If fs_open is invoked on already used fs_file_t object, it will return
-EBUSY.

Note: The change requires that all fs_file_t objects should be
initialized to 0.

Fixes: #29478

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-29 08:04:51 -05:00
Dominik Ermel
fd610846ef native_posix: fuse: Add fs_file_t type variable initializations
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-29 08:04:51 -05:00
Dominik Ermel
512a6f8cb6 fs: shell: Add fs_file_t type variable initializations
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-29 08:04:51 -05:00
Dominik Ermel
9fdf06e172 settings: Add fs_file_t type variable initializations
The commit adds initializations of fs_file_t variables in preparation
for fs_open function change that will require fs_file_t object, passed
to the function, to be initialized before first usage.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-01-29 08:04:51 -05:00
Vinayak Kariappa Chettimada
1afbe0770c Bluetooth: controller: Fix accept scan en/disable if already en/disabled
Conform to Bluetooth Specification, if the LE_Scan_Enable
parameter is set to 0x01 and scanning is already enabled,
any change to the Filter_Duplicates setting shall take
effect. Disabling scanning when it is disabled has no
effect.

Fixes #31019.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-29 08:02:46 -05:00
Flavio Ceolin
30de4b5dd9 power: Fix dummy policy states info
../../../../../include/power/power_state.h:280:41: warning: missing
braces around initializer [-Wmissing-braces]
  280 | #define PM_STATE_DT_ITEMS_LIST(node_id) {           \
      |                                         ^

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-28 20:24:46 -05:00
Flavio Ceolin
131913c5b6 power: Fix function return in dummy policy
There was one case where the dummy policy was returning a wrong type
in the function pm_policy_next_state.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-01-28 20:24:46 -05:00
Nicolas LANTZ
3ff1eb618f Bluetooth: Mesh: Fix mod app key get vnd
pass cid instead of CID_NVAL in parameters of mod_member_list_get

Signed-off-by: Nicolas LANTZ <nicolas.lantz@ubicore.net>
2021-01-28 07:52:06 -05:00
Kasun Hewage
7dad85695e net: coap: Fixed discovery response formatting according to RFC6690
CoAP RFC (RFC7252) states that end points should support
the CoRE Link Format of discoverable resources as described in RFC6690
(refer section 7.2 of the RFC7252).

Fixes #31609

Signed-off-by: Kasun Hewage <kasun.ch@gmail.com>
2021-01-27 18:26:13 -05:00
Vinayak Kariappa Chettimada
7712caa1a7 Bluetooth: controller: Fix peripheral conditional compilation
Fix regression in peripheral only build conditional
compilation introduced in commit 8a9bda307cc1 ("Bluetooth:
controller: Fix CPR conditional compilation").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
7295204af9 Bluetooth: controller: Fix CPR conditional compilation
Move the newly added Connection Parameter Request reject
state implementation under conditional compilation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
804419592f Bluetooth: controller: Fix incorrect reset of CPR reject state
Fix regression in adding the state for Connection Parameter
Request being rejected where in Connection Parameter Request
Procedure state machine was prematurely reset before the
reject PDU was enqueued.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
7bf202791f Bluetooth: controller: Fix missing initialization
Fix missing initialization of ticks_to_offset value on
instantiation of new peripheral context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
b5cba3c955 Bluetooth: controller: Minor identation changes
Minor changes to indentations in advanced scheduling
implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
b150d3a90f Bluetooth: controller: Fix repeated offsets in CPR PDU
Fix repeated offsets in LE Connection Parameter Request PDU
due to rounding errors. Use tick units of connection
interval to calculate the offset units.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
a8e25d9402 Bluetooth: controller: Fix deferred Conn Param Req offset population
Fix deferred Connection Parameter Request offset population
by introduction of explicit states waiting for the offset
calculations to complete in the ULL_LOW context.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
383e688e3f Bluetooth: controller: Fix deferred Conn Update offset population
Fix deferred Connection Update offset population by
introduction of explicit states waiting for the offset
calculation to complete in the ULL_LOW context.

Fixes #29636.

The problem was, in an encrypted connection the enqueued PDU
to be transmitted is encrypt in the prepare callback by the
hardware and swapped to a different buffer for transmission;
the deferred offset population did not reflect in the
transmitted PDU as it was filled in the cleartext buffer
while encryption completed into the encrypted buffer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 13:35:48 -05:00
Vinayak Kariappa Chettimada
2919989ee9 Bluetooth: controller: Fix compilation error with encryption disabled
Fix compilation error with encryption support disabled in the
controller.

Fixes #31693.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-27 07:57:28 -05:00
Piotr Pryga
53b4da93e9 Bluetooth: controller: ll_sw: Fix wrong cmake code that adds radio_df.c
Fix error introduced by pull request:
https://github.com/zephyrproject-rtos/zephyr/pull/31591

Zephyrs CMake extension function zephyr_library_sources_ifdef()
does not allow to use complex conditions to toggle if
sources should be included in build or not.
It allows to use only single variable as an input for
feature_toggle argument because it is double-expanded
in contition statement in the function.

In case there is a requirement that source file is included
when more complicated condition is true we have to fall-back
to reqular if() statement and zephyr_library_sources().

The fix is required because without it radio_df.c source
is never compiled. If DF functionality is enabled build
will fail because of missing functions implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-27 07:57:03 -05:00
Joakim Andersson
3102f3b081 Bluetooth: host: Fail pairing with identical public key
Fail the pairing procedure when both devices have the same non-debug
public key.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-26 13:41:56 -05:00
Watson Zeng
f71cd2aaf5 spinlock: validate: fix the dependency with MP_NUM_CPUS
the implementation of spinlock validation uses two LSB bits in the
bottom of a pointer union to store a CPU index, which only has space
for 4 CPUS. the MP_NUM_CPUS should be <= 4.

Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
2021-01-26 08:43:45 -05:00
Eduardo Montoya
58fe3e1fd6 net: openthread: add SRP Kconfig options
Enable new features from the upmerge:
- OPENTHREAD_SRP_CLIENT
- OPENTHREAD_SRP_SERVER

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-01-26 07:29:10 -05:00
Eduardo Montoya
80c0f3fbb6 net: openthread: configure required masterkey
After the latest upmerge, OpenThread requires explicit configuration
of the Master Key. This commit adds a Kconfig symbol that can be
used to setup its value. By default no Master Key is configured and
OpenThread generates a random one.

The Sockets Echo samples are configured with a fixed key with this
commit.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-01-26 07:29:10 -05:00
Jan Pohanka
cd7461495f usb: fix possible deadlock in usb_transfer_sync()
Syncing here is done with a semaphore declared on a function stack
and released in a callback. In case of a cancelled transfer (eg.
cable disconnect) the callback is never called.

The fix introduces a periodic check if a transfer is still valid.

Signed-off-by: Jan Pohanka <xhpohanka@gmail.com>
2021-01-26 07:21:13 -05:00
Jukka Rissanen
1584c806a7 net: config: Tweak the startup of logging backend
Only start the network logging backend if the autostarting
option CONFIG_LOG_BACKEND_NET_AUTOSTART is enabled.
Also, call init to make sure that the backend is initialized
properly.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-01-26 07:12:14 -05:00
Vinayak Kariappa Chettimada
8f537de8c4 Bluetooth: controller: Fix encryption and procedure with instant
Fix implementation to run local peripheral initiated control
procedure with instant in parallel with remote initiated
encryption procedure.

Relates to #28887.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:39 -05:00
Thomas Ebert Hansen
d4347339f5 Bluetooth: controller: Fix enc. setup during PHY update
If a PHY update is waiting for the instant to be reached and the master
starts the encryption procedure, store the pending PHY update procedure
and handle it simultaneously with the encryption setup.

This fix prevents the encryption setup from stalling and thereby timing
out after 40s, after which the master drops the link.

The ll_conn::llcp::encryption can not longer be unioned with the
ll_conn::llcp:phy_upd_ind as one would overwrite the other.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2021-01-26 06:18:39 -05:00
Vinayak Kariappa Chettimada
d2415fcfd0 Bluetooth: controller: Add peripheral/central conditional compilations
Add conditional compilation on peripheral and central
specific control procedure implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:39 -05:00
Vinayak Kariappa Chettimada
abcee4dc2b Bluetooth: controller: Fix BIG Sync Terminate command
Fix BIG Sync Terminate Command to generate Sync Established
event if Sync initiation is in progress.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:23 -05:00
Vinayak Kariappa Chettimada
eaa0215c74 Bluetooth: controller: Fix missing node rx allocation for ISO establish
Added missing allocation of node rx buffer required for
generation of Broadcast ISO Sync Established.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-01-26 06:18:23 -05:00
Hubert Miś
0475cd0eae net: coap: Allow encoding packets using data from constant buffers
Token and payload are appended from data buffers to a CoAP packet
being encoded. Keyword const was missing for parameters in functions
appending these parts to a packet.

Now token and paylod can be copied to CoAP packet from constant
buffers, that can be stored in ROM.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-26 06:17:41 -05:00
Hubert Miś
759f7454d8 net: coap: define max token length
This patch introduces COAP_TOKEN_MAX_LEN definition in coap.h file.
This definition replaces magic number across CoAP protocol
implementation and CoAP samples.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2021-01-26 06:17:41 -05:00
Krzysztof Chruscinski
7f08061f0c logging: Revamp menuconfig
Clean up logging menuconfig by grouping configuration into
sections like: mode, processing configuration, backends.

Additionlly, removed LOG_ENABLE_FANCY_OUTPUT_FORMATTING which is no
longer in use.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-01-26 06:15:42 -05:00
Emil Gydesen
085d2eda8d Bluetooth: Audio: Add missing unref for ISO recv
The net_buf was never unref'ed when the host received an
ISO package that was a SINGLE.

Also adds a few additional debug messages.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Emil Gydesen
aed1db5782 Bluetooth: shell: Fix number of optional args for iso send
`iso send` may take an optional "count" parameter but the
number of optional arguments was incorrect.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-01-25 21:47:06 -05:00
Piotr Pryga
a8c18ff5f4 tests: Bluetooth: df: Fix build error, missing antenna config in DTS
The DF tests are implemented to be executed with nrf52_bsim platform.
The nrf52_bsim platform does not include Direction Finding Extenstion.
Due to that, radio_df.c compilation failed with error about missing
antenna configuration in DTS.

To solve the problem, I've changed nrf.cmake to include radio_df.c
file when CONFIG_BT_CTLR_DF is defined and CONFIG_SOC_SERIES_BSIM_NRFXX
is not definded.

Thanks to that any other platform is not affected. The file will not
build if there is no appropriate configuration or there are missing
features in a hardwared.

Unit tests have provided stub imlpementation or radio functionality.
If nrf52_bsim has implemented Direction Finding Extension, the
DF unit tests code will stil work and will not require additional
changes. Also content of the file is not affected by contional
compilation entries.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-01-25 21:46:34 -05:00
Joakim Andersson
dbe4a5f0d2 Bluetooth: host: Remove ATT modification of L2CAP conn pointer
Remove ATT modifying the L2CAP channel state by unassigning the
the connection pointer on timeout.
Unassigning this pointer does not prevent the ATT channel from receiving
since bt_l2cap_recv does not inspect this pointer before calling the
channel receive function.
This prevented the disconnected callback from being called on the
channel after the channel had timed out, but since the disconnected
callback now handles this case this workaroun is no longer needed.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00
Joakim Andersson
28bddf9380 Bluetooth: host: Handle ATT timeout on disconnected ATT channel
Handle ATT timeout on disconnected ATT channel.
When the ATT channel is disconnected with a pending request the ATT
timeout is canceled and the response processed with an error code.
However canceling of delayed work is not guaranted to succeed, e.g:
"Work queue thread has removed the work item from the queue but has not
 called its handler"
This could lead to timeout handler being invoked after the disconnected
handler.

Fixes: #29098

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-01-25 18:49:30 -05:00