Commit graph

21541 commits

Author SHA1 Message Date
Andrzej Kaczmarek
f0352500b3 Bluetoth: controller: Fix memory corruption in RPA refresh
memcpy() could overwrite memory adjacent to "pdu" due to invalid
copy size.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-07 13:59:55 +01:00
Morten Priess
392e044548 Bluetooth: controller: Fix ull_conn LSTO for must_expire
When CONFIG_BT_CTLR_CONN_META is enabled and the ticker "must_expire"
feature is used, collisions may cause incorrect decrement of the
supervision_expire counter, resulting in a too early link supervision
timeout.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-12-07 13:36:17 +01:00
Dominik Ermel
c8ccf4fbc8 mgmt: mcumgr: Remove log management support from Kconfig
The commit removes a leftover configuration of the log management that
has never worked and has been removed with the commit
0bb466c34e4fe863733a929baa8f51981263ce3d to apache/mynewt-mcumgr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-12-07 12:56:40 +01:00
Vinayak Kariappa Chettimada
b19747ee11 Bluetooth: controller: Fix incorrect initiator window offset
Fix incorrect initiator window offset used when in continous
initiator scanning. Calculated window offset to free time
space after existing central connections is not decremented
correctly when there is change in window at every initiator
scan interval.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-07 11:41:37 +01:00
Vinayak Kariappa Chettimada
0db7e5afb8 Bluetooth: controller: Fix corruption of footer auto-variable
Fix corruption of ftr auto-variable due to reuse to insert
new node rx into the received auxiliary PDU chain, which can
cause corrupt reference used later in the implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-07 11:41:29 +01:00
Vinayak Kariappa Chettimada
e6911bc06c Bluetooth: controller: Fix Coded PHY S2 S8 coding use
Fix PHY Update control procedure to accept the preferred Tx
coding options (S2 or S8) requested even if there is no
actual PHY change happening on procedure completion.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-04 23:08:51 -05:00
Andrzej Kaczmarek
e9cece87bb Bluetooth: controller: Add definitions for AdvA and TargetA offsets
Both AdvA and TargetA have constant offset in extended header so it
makes sense to have dedicated definitions for those numbers.
AdvA is always placed at the beginning on extended header while TargetA
follows AdvA directly. There are no PDUs without AdvA and with only
TargetA.

Offsets of other fields depends on extended header contents and thus
are non constant.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
99226e1e95 Bluetooth: controller: Add ext_hdr member to pdu_adv_com_ext_adv
'ext_hdr' member only covers extended header part of 'ext_hdr_adv_data'
and with addition of 'data' member to 'pdu_adv_ext_hdr' those can be
used to quickly access both extended header flags and data directly
from 'pdu_adv' without need for extra local variables and casts.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
def072ea65 Bluetooth: controller: Rename pdu_adv_hdr to pdu_adv_ext_hdr
pdu_adv_hdr name is quite confusing since it suggests some generic
header for advertising PDUs while this in fact is extended header
which is a part of common extended advertising payload and only applies
to extended advertising PDUs.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
014eb0ddf8 Bluetooth: controller: Rename ext_hdr_adi_adv_data
The 'adi' part of that member name does not make sense since ADI is
already part of extended header, so we only have 'extended header' and
'advertising data'.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 23:08:15 -05:00
Andrzej Kaczmarek
85adca4be3 Bluetooth: controller: Use proper handle in advertising events
If handle mapping is enabled, we need to use proper advertising set
handle in HCI event.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 16:31:44 -05:00
Andrzej Kaczmarek
77fd7fdbd7 Bluetooth: controller: Initialize scan rsp only for legacy adv
When legacy set is configured we need to make sure scan response is
properly initialized with empty data. For extended sets we should not
touch scan response on configure since data for those sets have to be
set explicitly, e.g. we cannot enable scannable advertising set if no
data was set.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 17:44:13 +01:00
Andrzej Puzdrowski
694a9af1dd settings: fix possible unaligned write while a line coping
It was possible that settings_line_entry_copy() did unaligned
flash write.
This patch introduce respecting the flash write-block-size.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2020-12-04 17:10:47 +01:00
Andrzej Kaczmarek
e4c39d6e19 Bluetooth: controller: Fix AdvA/TgtA for extended adv PDUs
AdvA in extended advertising PDUs was only set if random address was
used. This patch enables proper support for AdvA/TgtA in those PDUs
also with LL Privacy enabled.

On enable, we always update advertising PDU (i.e. ADV_IND, ADV_EXT_IND
or ADV_AUX_IND, depending on advertising set parameters) as well as
scan response PDU.

On RPA timeout, we simply copy old PDU as-is and update AdvA in new
PDU, since both PDUs are exactly the same (except AdvA) so no need to
recreate it step-by-step.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-04 17:09:46 +01:00
Emil Gydesen
b527f80f0f Bluetooth: controller: Guard ll_adv_iso_by_hci_handle_* functions
Guards the functions with CONFIG_BT_CTLR_HCI_ADV_HANDLE_MAPPING
and added a non-HCI inline function for them.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
2c67c29fd4 Bluetooth: controller: Remove empty BIS packet tx from ULL
The empty BIS packet should be enqueue and handled in the LLL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
47e716ba83 Bluetooth: controller: removed node_rx for big create/terminate
Removed the node_rx argument for the BIG create/terminate
functions. The event should not be sent right after the
command, but needs to wait for transmissions of
empty BIS packets or BIG terminate indications.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
b32af6a643 Bluetooth: controller: ll_big_create add check if handle already created
Adds a check to verify that the BIG handle isn't already allocated.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
146fd961ef Bluetooth: controller: ull_adv_iso merge unknown adv id check
Merges the 3 checks for checking valid adv when creating a big.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
9c9253db5f Bluetooth: controller: Move ISO tx functionality to ull_iso.c
Moves the ISO tx pool and functions from ull_adv_iso.c to
ull_iso.c as the pool and functions will be shared between
BIS and CIS.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
e1aa633e67 Bluetooth: controller: Rearrange functions in ull_adv_iso.c
Rearranged the functions so the order of functions match
the common pattern in other ULL files.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
41fe6d72a1 Bluetooth: controller: Implements BIG terminate command
Implements the BIG terminate command that terminates a
BIG and returns the appropriate events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
339b9b8df5 Bluetooth: controller: BIG create sends empty BIS PDUs (ULL)
When a BIG is create, it will now start sending empty BIS PDUs;
at least from an ULL perspective, as the LLL support is still
missing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Emil Gydesen
5a512fbe2f Bluetooth: controller: Implements ULL handling for BIG create command
Implements handling of the BIG create command in the upper link layer.
Does not yet handle sending any BIS events.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-04 17:09:33 +01:00
Jukka Rissanen
cc528d37c2 net: syslog: Make sure CONFIG_LOG_IMMEDIATE is not set
The immediate logging option cannot be used with network logging
support CONFIG_LOG_BACKEND_NET as that would cause the generated
rsyslog messages to be malformed. The UDP packets would only have
one byte payloads which is not correct. So make sure that user is
not able to select a configuration with immediate mode and network
logging.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-12-04 15:46:42 +02:00
Vinayak Kariappa Chettimada
1d63c81033 Bluetooth: controller: Fix Extended Scanning on Coded PHY
Fix Extended Scanning on Coded PHY, auxiliary PDUs on Coded
PHY where not received due to redundant conditional code
only applicable in connection role being copy-pasted during
the development of Extended Scanning feature.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Vinayak Kariappa Chettimada
d6a3a0a05e Bluetooth: controller: Use memmove to copy overlapping memory
Use memmove to copy overlapping memory when populating the
Common Extended Advertising Header Format in the advertising
PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Vinayak Kariappa Chettimada
6cc7278b8b Bluetooth: controller: Fix maximum PDU len configuration
Fix maximum PDU len configuration when advertising and/or
scanning on primary channels.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-03 13:54:25 -05:00
Robert Lubos
7eefde36c3 net: lwm2m: Fix msg find based on pending/reply
The message should only be returned if the requested pending/reply
pointer is not NULL. Otherwise it could get an incorrect match (for
instance if specific pending pointer is searched for and reply is NULL
the function could return any message that doesn't expect a reply (and
thus has its reply pointer set to NULL).

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-03 13:53:33 -05:00
Robert Lubos
4331c05f17 net: lwm2m: Allow to acknowledge request early from the callback
LwM2M engine by default sends piggybacked responses for requests after
all callbacks are executed. This approach however isn't good enough if
the application callback executes some lenghty operations (for instance
during FW update). Delaying the ACK may result in unnecessary
retransmissions.

This commits adds an API function which allows to send an early empty
ACK from the application callback. This prevents further retransmissions
from the server side. After all callbacks are executed, the LwM2M engine
will send the response as a separate CON message.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-03 13:53:33 -05:00
Piotr Pryga
98b11ee95c Bluetooth: host: Fix data type of advertising set handle
Change type of advertising set handle to 8 bit to comply with
Bluetooth Core spec. type.
Fixes wrong usage of adv. set handle variable in function
bt_le_per_adv_set_param.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2020-12-03 14:53:37 +02:00
Joakim Andersson
180099f9ff Bluetooth: host: Remove irq_lock around connection lookup
Remove irq_lock around connection lookup, this is no longer needed
now that the lookup functions always have a valid reference.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Joakim Andersson
4350021f09 Bluetooth: host: Make connection lookup functions thread-safe
Make the connection lookup functions thread-safe by re-using the
bt_conn_ref returning NULL mechanism and keeping a valid reference.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Joakim Andersson
fae964c008 Bluetooth: host: Make bt_conn_ref return NULL if the ref count is zero
Make bt_conn_ref return NULL if the reference count has reached zero.
This makes it possible to re-use bt_conn_ref internally to re-use the
reference count mechanism to check if the reference is in use.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-03 13:52:02 +01:00
Andrzej Głąbek
7ee994af0f bluetooth: controller: nrf: Provide info about used DPPI resources
Use common definitions of HAL_USED_PPI_CHANNELS and HAL_USED_PPI_GROUPS
macros that will provide (through z_bt_ctlr_used_nrf_ppi_* variables)
information about either PPI or DPPI (depending on the SoC) resources
used by the Bluetooth controller.
Update also the hal_nordic module revision, to make the related nrfx
allocator aware of those reserved DPPI resources.

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-12-02 16:44:40 +01:00
Andrzej Głąbek
1f6f383481 bluetooth: controller: nrf: Clean up a bit radio_nrf5_ppi.h
Remove no longer needed definition of NRFX_PPI_CHANNELS_USED_BY_PWM_SW
(after recent changes in the nrf_hw_models models, also for simulated
nRF boards the nrfx_glue.h file is processed, so this symbol is always
defined).
Remove also a couple of *_PPI_x_INCLUDE macros, to make the code a bit
clearer and to avoid things like a build assertion (also removed here)
that checks if HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI_0_INCLUDE is indeed
defined as BIT(HAL_SW_SWITCH_GROUP_TASK_DISABLE_PPI(0)).

Signed-off-by: Andrzej Głąbek <andrzej.glabek@nordicsemi.no>
2020-12-02 16:44:40 +01:00
Johann Fischer
4a59067c36 disk: remove USB MSC specific FAT12 ramdisk
For USB mass storage class, a fixed size 16 KiB FAT12 ramdisk
is forced. This is not really visible to the user and
the DISK_RAM_VOLUME_SIZE option is ignored.
There is no use of such a small file system and for USB MSC
testing, like throughput or USB3CV, a file system is not necessary.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2020-12-02 11:50:11 +01:00
Yuval Peress
beaf0230ba drivers: sensors: bmi160: Fix issue with sample read
When testing the bmi160 I've come across an issue where the readings
didn't make sense to me. The issue comes from reading the
BMI160_SAMPLE_BURST_READ_ADDR which is 0x0C assuming both accelerometer
and gyroscope. At this point we would normally read 12 bytes
(2 bytes per sample * 3 axes * 2 sensors). This reading takes place in
bmi160_sample_fetch and begins writing to data->sample.raw

Without this change, the first byte written is actually to the dummy
byte which effectively gets tossed. The issue is that this is the
GYR_X<7:0>(LSB) according to the BMI160 data sheet. When we later call
either bmi160_gyr_channel_get or bmi160_acc_channel_get we're looking
at sample.gyr and sample.acc (which is effectively shiften by 1 byte).

This change gets rid of the dummy byte which re-alignes gyr with the
start of the raw buffer.

Signed-off-by: Yuval Peress <peress@chromium.org>
2020-12-01 17:58:06 -05:00
Peter Bigot
63638ceed6 shell: use public API to check device readiness
Avoid the private API now that there's a public equivalent.

Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
2020-12-01 15:19:22 -05:00
Robert Lubos
b27c14e355 net: lwm2m: Verify if block transfer is used before skipping TLV parsing
Verify if block tranfer is used and not an initial block when skipping
directly to data processing during FW update in PUSH mode.

This fixes a bug, which caused TLV not to be processed when the FW
object was updated as a whole, and actual resource number was encoded in
a TLV (for instance when writing FW Update URI).

Fixes #30135

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-01 11:26:55 -05:00
Flavio Ceolin
b6ef0c0d94 random: ctr_drbg: Fix the error path in sys_csrand_get
When ctr_drbg_initialize fails the function returns without unlock irq
that was previously locked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-12-01 10:20:06 -06:00
Flavio Ceolin
6ac3d0b5b1 random: ctr_drbg: Check entropy_get_entropy return
entropy_get_entropy return is not being checked what may result in a
vulnerability because tc_ctr_prng_reseed will not get proper entropy
data.

Fixes #29869

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2020-12-01 10:20:06 -06:00
Robert Lubos
1c8f52a670 net: lwm2m: Rework bootstrap DELETE operation
Rework the bootstrap DELETE operation, to support deletion of multiple
resources.

Current implementation had several oversimplifications, making it not
spec-compliant:
* DELETE `/` removed only Security object instances (!= 0)
* DELETE `/x` was handled as DELETE `/x/0`, therefore not removing all
  of the object instances.

Since the above is only supported during bootstrap and not regular
Device management, this functionality was implemented in the
`bootstrap_delete` function, which now will be called for all DELETE
operations initiated during bootstrap. The regular LwM2M DELETE handler
will only be called during regular Device management, as it has more
strict limitations on what can be deleted.

Additionally, handle empty URI Path option as `/`, therefore indicating
deletion of all resources.

Fixes #29964

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-01 11:17:12 -05:00
Jukka Rissanen
04a421d1b8 net: shell: Fix statistics for network interface
We did not check that user has supplied network interface index
in "net stats iface <idx>" command.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-12-01 12:37:52 +02:00
Jakub Rzeszutko
3e65944cfe shell: documentation update
Updated the documantation with newly added configuration features.
Added information where to find minimal shell config file.
Added information how to activate particular features.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00
Jakub Rzeszutko
86df66290f shell: help feature improvement
Shell help printing function can now fully support
CONFIG_CBPRINTF_NANO.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00
Jakub Rzeszutko
6e18a63f9b shell: move help command to shell.c
The help command is needed to list all available commands
when it is not possible to use the tab key.
Previously when build-in commands were deactivated command
help was not compiled as well.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00
Jakub Rzeszutko
de7e208d8d shell: tab feature optimization
Add options to Kconfig that deactivate the Tab button and
autocompletion feature.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00
Jakub Rzeszutko
572d2b02a2 shell: select command feature optimalization
Added IS_ENABLED(CONFIG_SHELL_CMDS_SELECT) to remove a dead code.
Added static inline function that returns pointer to the selected
command.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00
Jakub Rzeszutko
0e91aada4a shell: history feature optimization
When history feature is not compiled in it makes no sense to
trim the command. In addition when history feature is not active the
shell will not call function history_put.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2020-11-30 16:03:01 -06:00