Commit graph

21541 commits

Author SHA1 Message Date
Daniel Leung
e912a0533a drivers: ethernet: build as static library
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.

Note that the include to subsys has been moved from
under the drivers into subsys, as it is actually
the subsystem's job to make sure the include
directories are correct.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Daniel Leung
378ad046c8 drivers: bluetooth: build as static library
Instead of putting object files inside libzephyr.a,
simply build a separate static library as most other
driver types are doing this already.

Note that the include to subsys/bluetooth has been
moved from under drivers/bluetooth to subsys/bluetooth,
as it is actually the subsystem's job to make sure
the include directories are correct.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Daniel Leung
23712842d1 bluetooth: audio: build as static library
Make subsys/bluetooth/audio build as a static library.
This is in preparation to enable building the bluetooth
drivers as a static library. That would change the line
"zephyr_include_directories(subsys/bluetooth)" where
this include path is applied to all code compiled.
Its removal will result in subsys/bluetooth/audio not
able to find subsys/bluetooth/common/log.h. So change
subsys/bluetooth/audio to be built as a static library
so it can link to the subsys/bluetooth library where
it can find "log.h" there.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-08-17 06:06:03 -04:00
Flavio Ceolin
cfa5715b3d pm: device: Use the right build conditional
_pm_devices, pm_suspend_devices, pm_low_power_devices and
pm_resume_devices are only used if CONFIG_PM_DEVICE is defined and not
CONFIG_PM.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-17 06:03:44 -04:00
Vinayak Kariappa Chettimada
d1e64cb9d7 Bluetooth: Controller: Fix hci_core assertion on advertising disable
Fix a race condition that caused the Controller to deadlock
waiting for a semaphore that be given when LLL events have
been disabled.

ULL reference count is checked in thread context to decide
if LLL events are pending, but the reference count can be
decremented by the ULL execution context which prevents the
set `disabled_cb` function not being called due to no
pending event to produce the done events.

Fixed by re-checking if reference count is zero and avoid
waiting to take the semaphore.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-17 10:22:14 +02:00
Saleh Mehdikhani
8618de9be4 Bluetooth: controller: radio: Fix wrong argument of radio_df_ctrl_set
While RADIO_DFECTRL1_TSAMPLESPACING and RADIO_DFECTRL1_TSAMPLESPACINGREF
has similar values, but they are logically different.
As expected by "radio_df_ctrl_set" function, TSAMPLESPACING should be
passed to this function not TSAMPLESPACINGREF.

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2021-08-17 10:21:10 +02:00
Vinayak Kariappa Chettimada
190532bcc4 Bluetooth: Controller: Only remove duplicate resume events
When events are placed back into pipeline as resume events,
only remove duplicate resume events and not new prepare
events that may have been enqueue between the start of the
pre-empt ticker and its timeout.

Due to new prepare events that was removed, extra done
events generated cause the number of enqueued done events
to overflow and assert.

Fixes #36381.
Fixes #37597.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:13:11 -04:00
Vinayak Kariappa Chettimada
790a291e24 Bluetooth: Controller: Fix incorrect pipeline iterator index reset
Fix the incorrect iterator index being reset when flushing
duplicate resume events in the pipeline.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:13:11 -04:00
Vinayak Kariappa Chettimada
82eb2a4019 Bluetooth: Controller: Update AD data race implementation
Update the AD data race condition handling with explicit
revert of `pdu->last` value after detecting the race.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 15:12:55 -04:00
Vinayak Kariappa Chettimada
30b4c29aaf Bluetooth: Controller: Minor conditional compile refactor
Minor conditional compile refactor.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
c399155bc4 Bluetooth: Controller: Reduce the Rx window switch for continous scan
Reduce the Rx window swithch overhead for continuous scan by
using radio interfae `radio_tmr_start_now` that accounts for
any minimum ticker offset requirement.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
22a96ade74 Bluetooth: Controller: Remove radio complete and Tx after scan response
Remove the radio software switch from Rx to Tx after
reception of scan response.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Vinayak Kariappa Chettimada
eddd1b18eb Bluetooth: Controller: Remove radio complete and Tx for passive scan
Remove the radio software switch from Rx to Tx when in
passive scanning, as there is no transmission requirement
after reception of a PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-16 12:46:43 +02:00
Emil Obalski
6f4f1dc230 logging: Add configurable logging thread delay
This patch adds confiugurable delay when starting log processing
thread.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2021-08-13 11:19:27 -04:00
Vinayak Kariappa Chettimada
dc633856d7 Bluetooth: Controller: Fix uninit update flag given to PDU _latest_get
Fix uninitialized update flag given to PDU _latest_get()
functions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-13 10:14:50 -04:00
Mateusz Sierszulski
9d62f8d8ac shell: add devmem load command
This commit adds a devmem load command for shell that allows
users to easily load arbitrary data into the device memory.

Signed-off-by: Mateusz Sierszulski <msierszulski@internships.antmicro.com>
Signed-off-by: Tomasz Gorochowik <tgorochowik@antmicro.com>
2021-08-13 10:13:36 -04:00
Morten Priess
fdc92ebb27 Bluetooth: controller: Implement ADV re-schedule for new scheduler
The new JIT scheduler does not have slot reservation, which means that
the ticker extension feature for automatically re-scheduling a colliding
non-anchored event, e.g. ADV, cannot be used.

This implementaion reacts to ADV envent done with result ABORTED or
TOO_LATE, and in those cases attempts to re-schedule the ADV event again
within the 10 ms pertubation window.

As the original scheduling, the re-scheduling is randomized, so there
is no absolute predictability as to how many attempts will be made. The
advertiser will attempt with randomly delayed re-schdules until the
window is exhausted.

If re-scheduling is unsuccessful, the weight of the ADV event is
increased, improving it's chances of success in the next event.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2021-08-13 07:30:56 -04:00
Fabio Baltieri
f88a420d69 toolchain: migrate iterable sections calls to the external API
This migrates all the current iterable section usages to the external
API, dropping the "Z_" prefix:

Z_ITERABLE_SECTION_ROM
Z_ITERABLE_SECTION_ROM_GC_ALLOWED
Z_ITERABLE_SECTION_RAM
Z_ITERABLE_SECTION_RAM_GC_ALLOWED
Z_STRUCT_SECTION_ITERABLE
Z_STRUCT_SECTION_ITERABLE_ALTERNATE
Z_STRUCT_SECTION_FOREACH

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2021-08-12 17:47:04 -04:00
Chen Peng1
34d2ca613f cmsis_rots_v1: fix for clearing signal flags in osSignalWait.
we use flag 0 in osSignalWait function to wait for
any single signal flag, but with this 0 flag,
it won't clear thread signal results as expected,
we need to check whether signal flag is 0 firstly.

Signed-off-by: Chen Peng1 <peng1.chen@intel.com>
2021-08-12 17:30:03 -04:00
Johann Fischer
4f2682bd79 usb: cdc_acm: avoid spurious interrupt on configured or resume events
Do not submit k_work on on configured or resume events and
avoid spurious interrupt.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-12 16:57:12 -04:00
Johann Fischer
37f4d9ba63 usb: cdc_acm: rework cdc_acm_poll_out to non-blocking
Change cdc_acm_poll_out to do the best to mimic behavior
of a hardware UART controller without flow control.

With this patch, if the USB subsystem is not ready,
no data is transfered to the buffer, that is, new character
is dropped. If the USB subsystem is ready and the buffer is full,
the first character from the tx_ringbuf is removed to
make room for the new character.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-12 16:57:12 -04:00
Krzysztof Kopyściński
00bfac00ae Bluetooth: gatt: Add option to read multiple without variable length
Currently, with EATT enabled, when bt_gatt_read is called with multiple
handles first it'll try to use gatt_read_mult_vl, and if it fails
gatt_read_mult will be used to try again. Add option to skip
the gatt_read_mult_vl and use gatt_read_mult right away. This is needed
by tests that expect BT_ATT_OP_READ_MULT_REQ but support variable
lenght, thus don't return BT_ATT_ERR_NOT_SUPPORTED.

Removed fallback from read multiple vl to read multiple on
BT_ATT_ERR_NOT_SUPPORTED error.

This was affecting:
GATT/CL/GAR/BV-05-C, GATT/CL/GAR/BI-18-C, GATT/CL/GAR/BI-19-C,
GATT/CL/GAR/BI-20-C, GATT/CL/GAR/BI-21-C, GATT/CL/GAR/BI-22-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-08-12 11:07:08 -04:00
Ryan Erickson
e4dc8ed26b logging: Add log mem shell command
Add log mem shell command to determine memory pool
usage of logging system.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2021-08-12 11:06:32 -04:00
Andrew Hedin
b52ad8f3e1 logging: Add strdup current use to shell cmd
Add the number of strdup buffers currently in use to the
`log strdup_utilization` shell command.

Signed-off-by: Andrew Hedin <andrew.hedin@lairdconnect.com>
2021-08-12 11:06:32 -04:00
Vinayak Kariappa Chettimada
00d707e470 Bluetooth: Controller: Fix node rx memory corruption regression
Fix the node rx memory pool corruption regression introduced
due to same peer connection being rejected.

Regression introduced in commit 30f260dfaa ("Bluetooth:
controller: Fix adv/scan context access post release").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:57:12 +02:00
Vinayak Kariappa Chettimada
27b8beaa22 Bluetooth: Controller: Fix to handle relative short preempt timeout
When a new radio event is scheduled with a relatively short
preempt timeout while there is already a started preempt
ticker, then stop the ticker, abort the previous event that
requested the preemption, and request to start ticker with
the new relatively short preempt timeout.

Fixes #30245.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:56:56 +02:00
Vinayak Kariappa Chettimada
6cd9ec8c8d Bluetooth: Controller: Preempt ticker to use atmost one operation
When there are multiple events in prepare pipeline then fix
the implementation so that only one preempt ticker start
or stop operation is enqueued towards ticker_job for
processing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-12 11:56:56 +02:00
Flavio Ceolin
69e57d633f pm: device: Do not suspend wake up sources
Check if a device is being used as a wake up source before suspend it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-11 19:39:13 -04:00
Flavio Ceolin
8eceeee798 pm: device: Add wakeup source API
Introduce a new API to allow devices capable of wake up the system
register themselves was wake up sources. This permits applications to
select the most appropriate way to wake up the system when it is
suspended.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-11 19:39:13 -04:00
Flavio Ceolin
a245ed2a87 pm: device: Change atomic flags type
Just using a simple atomic for flags instead of using an array.

While is neat using ATOMIC_DEFINE for future proof. The reality is
that it brings some problem for the wakeup source implementation
that needs to statically initialize it during the device definition.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-11 19:39:13 -04:00
Eduardo Montoya
570dab7a1a net: openthread: add Netdata Publisher Kconfig option
Enable new feature from the upmerge:
- OPENTHREAD_NETDATA_PUBLISHER

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-08-11 11:29:36 -04:00
Eduardo Montoya
4b4e298914 net: openthread: propagate security and header updated flags
When transmitting a frame, inform the radio driver whether
security processing and/or header updates are needed or not.

When a frame was transmitted, inform back to OpenThread whether
the security procedure and/or header updates were completed for
the frame or not.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-08-11 11:29:36 -04:00
Lingao Meng
8e1682d1ea samples: conn_cb replace to const zsector
It is more efficient and saves part of RAM
by replacing it with static one dynamically.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-11 13:42:28 +02:00
Lingao Meng
23a9594944 Bluetooth: Add connect event structure to zsector
Add an optional version for connection events
to save some memory.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-11 13:42:28 +02:00
Vinayak Kariappa Chettimada
eb22d5acf2 Bluetooth: Controller: Change random address on advertising re-enable
If HCI LE Set Extended Advertising Enable command is sent
again for an advertising set while that set is enabled, then
any change to the random address shall take effect.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Vinayak Kariappa Chettimada
e82fcb070a Bluetooth: Controller: Permit enabling already enabled advertising
Permit enabling already enabled advertising. Enabling
advertising when it is already enabled can cause the
random address to change, as specified in the Bluetooth
Specifications.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Vinayak Kariappa Chettimada
06f02b570e Bluetooth: Controller: Comment on enabling of already enabled scanning
Add comment about enabling of already enabled scanning.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-11 07:32:59 -04:00
Berend Ozceri
46adc9eef5 net: icmp: add option to suppress destination unreachable errors.
By default ICMP desination unreachable error packets are generated when
input packets target ports that are not in a listening state. This not
only reveals the presence of the host on the network which may be
considered a security vulnerability depending on the application, it
also ends up triggering ARP lookups to respond to the sending host. With
a small ARP table and a network where there may be broadcast (or
multicast) service discovery traffic such as mDNS or uPnP, ARP table
thrashing can occur impacting network stack performance.

Signed-off-by: Berend Ozceri <berend@recogni.com>
2021-08-11 11:46:44 +02:00
Lingao Meng
6bf35fa749 Bluetooth: Mesh: Fixes Same appkey add to multi netkey
The latest MESH.TS 1.0.1.2 4.15.10 Appkey List Procedures
MESH/NODE/CFG/AKL/BI-04-C

Verify that the IUT can respond to an Config AppKey Add
message with NetKeyIndex and AppKeyIndex already stored.

6. Repeat step 1 with the same AppKey, the same
AppKeyIndex, but NetKeyIndex field set to 0x001.

7. The Lower Tester expects the IUT to respond
with an Config AppKey Status message with the
Status field set to 0x04 (Invalid NetKey) and
the NetKeyIndex and AppKeyIndex values equal to
those sent in step 5.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-10 07:39:11 -04:00
Jakub Rzeszutko
1d00a75d21 shell: improve shell_execute_cmd function
The function to execute shell commands: shell_execute_cmd will now
behave similarly to invoking command line commands.
I.e. after the command is executed the command buffer is cleared,
while the cursor is set to the initial position.

Signed-off-by: Jakub Rzeszutko <jakub.rzeszutko@nordicsemi.no>
2021-08-10 07:38:02 -04:00
Vinayak Kariappa Chettimada
4830571356 Bluetooth: Controller: Fix advertising after connections from same peer
Fix the missing resumption of connectable advertising and
release of received connection complete buffers from LLL
after detecting connection from same peer.

Relates to commit 010c5c2f20 ("Bluetooth: controller:
Ignore connections from same peer").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-10 07:36:47 -04:00
Evgeniy Paltsev
497cb2e587 CPP: fix static objects init for MWDT toolchain
The constructors of static objects are stored in ".ctors"
section. In case of MWDT toolchain we have incompatible
".ctors" section format with GNU toolchain. So let's use
initialization code provided by MWDT instead of Zephyr one
in case of MWDT toolchain usage.

As it is done for GNU toolchain We call constructors of
static objects but we don't call destructors for them.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-08-09 22:47:22 -04:00
Joakim Andersson
79021187ac Bluetooth: host: Check for mandatory callback when accepting new channel
Add a check for the mandatory channel receive callback when the
application provides the L2CAP channel operations.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Joakim Andersson
921644c5a6 Bluetooth: OTS: Make L2CAP channel recv callback static
Make the OTS module L2CAP channel recv callback a static function.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Joakim Andersson
9f989a0b00 Bluetooth: OTS: Add configuration for OTS channel TX mtu
Add configuration for Object Transfer Service channel MTU for outgoing
L2CAP SDUs.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-09 13:03:55 -04:00
Trond Einar Snekvik
8ab219cde5 bluetooth: Add defines for ECC key lengths
Adds defines for ECC public keys, private keys, DH keys and key
coordinates. Replaces raw numbers throughout.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-09 16:45:57 +02:00
Piotr Pryga
2675b8d8aa Bluetooth: controller: remove warning about defined bvt unused function
Remove compilation warning about adv_sync_pdu_ad_data_set function
that is defined but not used.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
120751118c Bluetooth: controller: ULL: Add handling of chains in disable CTE
Direction finding functionality allows to send a number of periodic
advertising PDUs in a chain that have CTE.
Disable sending CTE requiers additional steps while removing
cte_info from periodic advertising chains.
Removal of cte_info fields may be just delete of that filed
from extended advertising header. In case the PDUs are empty
PDUs created just to transport CTE. Those PDUs should be removed
from a periodic advertising chain.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
9c23fe0dcc Bluetooth: controller: Add release of chains when get latest adv pdu
Add release of chained PDUs by lll_adv_pdu_and_extra_data_-
latest_get function. It is requier to release unused
PDUs from a chain to avoid PDUs leakage.
It maight happen when chained PDUs were used by Direction
Finding, then lll_adv_pdu_and_extra_data_lates_get is used
instead of lll_adv_pdu_lates_get.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00
Piotr Pryga
467d132e6f Bluetooth: controller: Add macro with minimum allowed adv. PDU size
To check if advertising PDU is empty we can compare its length to 1.
To avoid use of magic number, the commit provides a macro for that
purpose.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-07 20:50:03 -04:00