Commit graph

21541 commits

Author SHA1 Message Date
Eduardo Montoya
8ff12f3ace net: openthread: enable CSL delayed transmissions
Add support for delayed transmission of frames for the CSL
Transmitter OpenThread function.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-04-26 13:40:43 +02:00
Trond Einar Snekvik
6976658719 usb: dfu: convert z_timeout_end_calc to sys_clock_timeout_end_calc
The z_timeout_end_calc function was replaced by
sys_clock_timeout_end_calc in #33302. A reference to the old function
snuck into master through #30015.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-26 13:40:29 +02:00
Wolfgang Puffitsch
feb9943e84 Bluetooth: controller: Fix overflow with preferred periodicity
Avoid possibly overflowing maximum interval when calculating interval
with preferred periodicity.

Changed calculation to round down from maximum interval and reset to
maximum in case of underflowing minimum interval.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-04-26 13:38:34 +02:00
Kai Ren
92c5afe2be Bluetooth: shell: Fix null check in conn and data length update
Perform null check of default_conn in call cmd_conn_update()
and cmd_conn_data_len_update() in ./subsys/bluetooth/shell/bt.c

Signed-off-by: Kai Ren <renkaikaiser@163.com>
2021-04-26 13:05:55 +03:00
Trond Einar Snekvik
2d983a89ad net: shell: Wrap iface_flags2str in #ifdef to silence warning
The net_shell only uses iface_flags2str when CONFIG_NET_NATIVE is
enabled. Disabling this produces an "unused function" warning for this
function. Wrap the function in an #ifdef to silence the warning for this
configuration.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-26 12:41:13 +03:00
Jukka Rissanen
9f2fa87e05 net: Remove support for CONFIG_NET_CONTEXT_TIMESTAMP option
This option was only able to collect statistics of transmitted
data. The same functionality is available if one sets the
CONFIG_NET_PKT_RXTIME_STATS and/or CONFIG_NET_PKT_TXTIME_STATS
options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-26 10:46:43 +03:00
Jukka Rissanen
a7f1c2821a net: sockets: RX statistics were not properly compiled in
The RX statistics might not get updated properly because the used
ifdef was referring the TX options.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-26 10:46:43 +03:00
Marcin Niestroj
d98911d712 net: dns: add 10ms delay when rescheduling query timeout handler
Query timeout handler is rescheduled if DNS context mutex is locked. So
far there was no timeout used, which means that work is simply put at
the end of system workqueue. This solves cases when mutex is locked by
any higher priority cooperative threads.

If however mutex was locked in application code within lower priority
thread (which is very likely) and query timeout has expired in the
meantime, then system workqueue is busy looping by calling query timeout
handler and trying to acquire DNS context lock.

Reschedule query timeout handler with 10ms delay, so that all
threads, including those with lower priorities, have a chance to move
forward and release DNS context lock.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-23 15:05:41 -05:00
Jonathan Nilsen
0e6ac008a0 storage/stream: Add persistent write progress to stream_flash
Add additional API to stream_flash that can be used to make
stream write progress persistent using the settings subsystem.
This functionality makes it possible to resume a write operation
after it was interrupted, e.g. by power loss.

Signed-off-by: Jonathan Nilsen <Jonathan.Nilsen@nordicsemi.no>
2021-04-23 15:01:32 -05:00
Piotr Szkotak
be226ca55a shell: openthread: increase shell stack when used with OpenThread
This commit increases the shell stack sizes when used with
OpenThread shell and the joiner to compensate for enlarged
MPU stack guard.

Signed-off-by: Piotr Szkotak <piotr.szkotak@nordicsemi.no>
2021-04-23 09:47:10 -04:00
Emil Gydesen
2bada95482 Bluetooth: Host: Adds periodic advertising min/max interval macros
Add the BT_GAP_PER_ADV_MIN_INTERVAL and BT_GAP_PER_ADV_MAX_INTERVAL
macros in gap.h that are also reference in bluetooth.h and
used for parameter validation in adv.c.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-23 15:01:32 +02:00
Asger Munk Nielsen
19650299fb Bluetooth: controller: Moved sdu_interval field members
Moved sdu_interval struct members from llcp_cis to cis group,
to match spec and enable access by ULL

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2021-04-23 15:00:45 +02:00
Krzysztof Chruscinski
c313474cb0 shell: uart: Add TX disabling in uninitialization
Uninitialization of uart transport was missing disabling of TX
interrupt. It had to be done by the user before using uart.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-23 15:00:21 +02:00
Trond Einar Snekvik
3656f7f609 Bluetooth: Mesh: Provisioning output count number should be at least 1
When selecting a random count for blink, beep or vibrate, the Bluetooth
Mesh Profile Specification v1.0.1, section 5.4.2.4 states: "the device
shall select a random integer between 0 and 10 to the power of the
Authentication Size exclusive".

This means that if size is 1, the integer should be in the range 1-9,
while the implementation chose an integer in the range 0-9. Reduce the
range and add 1 to the num to correct this for these actions.

Fixes #34209.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-23 14:58:56 +02:00
Joakim Andersson
d1469ecf26 Bluetooth: host: Fix undefined reference to bt_le_adv_lookup_legacy
Fix undefined referenc to bt_le_adv_lookup_legacy in bt_le_oob_get_local
when bt_le_oob_get_local is used in a central only application.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-23 15:30:40 +03:00
Carlo Caione
256ca55476 arm64: Rework stack usage
The ARM64 port is currently using SP_EL0 for everything: kernel threads,
user threads and exceptions. In addition when taking an exception the
exception code is still using the thread SP without relying on any
interrupt stack.

If from one hand this makes the context switch really quick because the
thread context is already on the thread stack so we have only to save
one register (SP) for the whole context, on the other hand the major
limitation introduced by this choice is that if for some reason the
thread SP is corrupted or pointing to some unaccessible location (for
example in case of stack overflow), the exception code is unable to
recover or even deal with it.

The usual way of dealing with this kind of problems is to use a
dedicated interrupt stack on SP_EL1 when servicing the exceptions. The
real drawback of this is that, in case of context switch, all the
context must be copied from the shared interrupt stack into a
thread-specific stack or structure, so it is really slow.

We use here an hybrid approach, sacrificing a bit of stack space for a
quicker context switch. While nothing really changes for kernel threads,
for user threads we now use the privileged stack (already present to
service syscalls) as interrupt stack.

When an exception arrives the code now switches to use SP_EL1 that for
user threads is always pointing inside the privileged portion of the
stack of the current running thread. This achieves two things: (1)
isolate exceptions and syscall code to use a stack that is isolated,
privileged and not accessible to user threads and (2) the thread SP is
not touched at all during exceptions, so it can be invalid or corrupted
without any direct consequence.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-04-23 06:32:20 -04:00
Kumar Gala
043891e1ea include: Move ec_host_cmd.h to mgmt/ec_host_cmd.h
Move ec_host_cmd.h out of the top level include/ dir into
include/mgmt/ec_host_cmd.h and deprecated the old location.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-22 12:51:16 -04:00
Kumar Gala
e1032ad2c3 include: Move emul.h to drivers/emul.h
Move emul.h out of the top level include/ dir into
include/drivers/emul.h and deprecated the old location.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-04-22 12:51:01 -04:00
Maik Vermeulen
ae4c5193a3 net: coap: coap_find_options() now returns 0 when options empty
coap_find_options() now first checks if there is actual payload
to parse.

Fixes #34463.

Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
2021-04-22 19:34:11 +03:00
Vinayak Kariappa Chettimada
a379196b48 Bluetooth: controller: nRF5: Back-to-Back Radio Tx interface
Add Radio interface to perform back-to-back transmit of PDU
with a configurable inter frame spacing.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-22 16:00:10 +02:00
Vinayak Kariappa Chettimada
377d168c51 Bluetooth: controller: nRF53 sw_switch always required Radio End
nRF53 implementation of sw_switch always requires Radio End
event, hence optimize out redundant code due to explicit use
of radio_tmr_end_capture.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-22 16:00:10 +02:00
Vinayak Kariappa Chettimada
0426b1dd68 Bluetooth: controller: Minor indentation and HAL code change
Minor indentation change and replaced if-then-else-if clause
with toggle implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-22 16:00:10 +02:00
Vinayak Kariappa Chettimada
72504c8a58 Bluetooth: controller: Enclose macro parameters in paranthesis
Enclose macro parameters in paranthesis to avoid ambiguous
macro expansions.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-22 16:00:10 +02:00
Krzysztof Chruscinski
9a85a89313 shell: logging: Fix assertion when shell is overflowed with logging
When shell had too many pending log messages it was attempting to
drop expired messages and retrying to put the new message. There
was an assumption that enough messages are dropped and new message
can be put. It may not be the case if no message expired during
given time. Wrapped the operation in loop to continue until expired
message is freed and new message is enqueued.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-22 14:04:33 +02:00
Paul Sokolovsky
01014a2c05 net: sntp: Depend on NET_SOCKETS_POSIX_NAMES || POSIX_API
This library is coded with standard POSIX names for socket functions,
so make that requirement explicit.

Also, switch it from select'ing NET_SOCKETS, to depend'ing on it. This
follows the general approach of avoiding unneeded select's in Zephyr,
which lead to conflicting dependencies and make debugging dependencies
complex overall. In this particular case, it's fair (for a user) to
expect that "simple network time protocol" requires networking API,
namely sockets, and have that explicitly on in their app configuration,
giving better overview of their app config overall.

Fixes: #34165

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2021-04-22 13:41:33 +03:00
Emil Gydesen
cfe0849072 Bluetooth: services: Adds OTS name length checks
Adds name length checks. The OTS spec does not
explicitely specifiy a maximum name length, but the
maximum name length in the directory listing object
shall be less or equal to 120 octets.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-22 11:32:25 +02:00
Emil Gydesen
5a90fcee3a Bluetooth: services: Adds additonal len checks for ots_dir_list
Adds additional length checks for the OTS directory listing
implementation. This will check the object name length and
the total length of the object when encoding,
as well as the length of the objects when removing objects
from the directory listing.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-22 11:32:25 +02:00
Andrés Manelli
ecf89143da logging: Do not set CYCCNTENA to zero in swo backend
The log_backend_swo_init function sets the CYCCNTENA bit of the DWT
register to 0, disabling the counter (which is necessary for the timing
functions.
Avoid overwriting the CYCCNTENA bit.
Do not try to set read-only bits.

Fixes #34341

Signed-off-by: Andrés Manelli <am@toroid.io>
2021-04-22 09:14:44 +02:00
Emil Gydesen
59f3e2c502 Bluetooth: host: Fix typo in PA defines and missing min check
Fixes a typo where the BT_GAP_PER_ADV macros had MAX twice,
as well as adding a MIN timeout macro and check.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-04-21 20:41:17 -04:00
Marcin Jeliński
2633606130 ipc: rpmsg_service: switch to new work API
Replace existing deprecated API with the recommended alternative.

Signed-off-by: Marcin Jeliński <marcin.jelinski@nordicsemi.no>
2021-04-21 11:53:19 -05:00
Joakim Andersson
15dfec4df6 Bluetooth: host: Fix ECC thread stack size too small
Fix ECC thread stack size which is to small to account for the worst
case scenario. When an interrupt happens at the point where the ECC
thread is at the highest stack size usage pushing the thread context
to service the ISR causes a stack overflow.

Increase the ECC thread stack size by atleast the size of the basic
stack frame of 32 bytes aligned on 8 byte for ARM architectures.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-04-21 16:57:14 +03:00
Piotr Mienkowski
41c10d4f66 ztest: fix ztest thread priority in cooperative mode
By default ztest thread is running at the priority `-1`. This value is
invalid when the testcase is running in cooperative mode only. Set
default ztest thread priority to `-2` if this is the case. The fix is
modeled on the approach used to define the default
`MAIN_THREAD_PRIORITY`.

Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
2021-04-21 08:10:36 -05:00
Bjørn Spockeli
9c871fb0b6 Bluetooth: controller: nRF21540 FEM support for nRF52x Series
Added nRF21540 FEM support for nRF52x Series.

Signed-off-by: Bjørn Spockeli <bjorn.spockeli@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Bjørn Spockeli
9930e22322 Bluetooth: controller: Add GPIO control for nRF21540 CSN and PDN lines
Added GPIO control for nRF21540 CSN and PDN lines.

Signed-off-by: Bjørn Spockeli <bjorn.spockeli@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Bjørn Spockeli
568113c0a9 Bluetooth: controller: Add Kconfig options for nRF21540 PDN and CSN pins
Added Kconfig options for nRF21540 PDN and CSN pins.

Signed-off-by: Bjørn Spockeli <bjorn.spockeli@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Bjørn Spockeli
207b393fff Bluetooth: controller: Add PA/LNA pin range for nRF5340 SoC
Added correct SOC_NRF5340_CPUNET pin range for
BT_CTLR_GPIO_PA_PIN and BT_CTLR_GPIO_LNA_PIN.

Signed-off-by: Bjørn Spockeli <bjorn.spockeli@nordicsemi.no>
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Vinayak Kariappa Chettimada
35122d4be5 Bluetooth: controller: GPIO PA/LNA support for nRF53x
Ported the GPIO PA/LNA support for nRF53x by using a DPPI
channel.

Fixes #24142.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Vinayak Kariappa Chettimada
0772890992 Bluetooth: controller: Adjust DPPI used for nRF53x
Adjust the PPI used by nRF53x so that DPPI 0-4 available
for application's use.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-21 15:04:12 +02:00
Marcin Niestroj
552028dd20 logging: add log_output_timestamp_to_us() helper function
So far we only have log_msg_timestamp_get() function, which returns
internal timestamp representation. This is either clock cycles or uptime
in ms, depending on main clock precision.

Introduce log_output_timestamp_to_us() helper function, which allows to
convert internal logging timestamp to us.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2021-04-20 18:21:26 -04:00
Kai Ren
de16299c62 Bluetooth: shell: Fix null check in cmd_conn_phy_update
Null check in case of system failure.

Signed-off-by: Kai Ren <renkaikaiser@163.com>
2021-04-21 01:21:05 +03:00
Luiz Augusto von Dentz
33d95894e1 Bluetooth: Align error handling of send functions
This aligns the error handling of send function to never unref the
buffer in place so the caller retain the ownership of the buffer
whenever there is an error.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2021-04-20 18:20:04 -04:00
Jamie McCrae
840d1d9381 bluetooth: Add flag to force device name to appear in AD data
This adds a new flag, BT_LE_ADV_OPT_FORCE_NAME_IN_AD, which can be used
to force the Bluetooth GAP device name to appear in the advertising
data rather than the scan response data of an advert with scan response
data.

Signed-off-by: Jamie McCrae <jamie.mccrae@lairdconnect.com>
2021-04-20 18:19:30 -04:00
Flavio Ceolin
8cbda26cdd logging: log_minimal: Fix violations to rule 10.4
Logical AND operator accepts only unsigned type and operands.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-20 15:50:49 -04:00
Flavio Ceolin
3687021c83 logging: log_minimal: Fix violation to rule 14.4
Non-boolean essential type is being interpreted as a boolean.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-20 15:50:49 -04:00
Flavio Ceolin
8c5a9ffaab logging: log_minimal: Fix violations to 21.2 and 8.3
Just renaming the function parameter fix two violations, one is
caused because the parameter name is different from the declaration
the other violation is because the identifier was starting with
underscore.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-20 15:50:49 -04:00
Flavio Ceolin
ed6e016251 logging: log_minimal: Fix violations to rule 10.4
Fix violations for the rule 10.4.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-04-20 15:50:49 -04:00
Jukka Rissanen
d7321152a9 net: virtual: Remove unnecessary null check
The virtual_iface is already NULL checked by net_if_get_by_iface()
at the beginning of the function so no need to do it here too.

Coverity-CID: 220535
Fixes #34006

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-20 13:44:39 -04:00
Jukka Rissanen
c2877579ba net: virtual: Remove dead code
Simplifying the loop in order to remove dead code (ctx_up is
always NULL after the slist loop.

Coverity-CID: 220538
Fixes #34003

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-04-20 13:44:39 -04:00
Anas Nashif
3b3e858c50 portability: move cmsis api headers
Move cmsis OS api headers under include/portability. Those are not
libraries and only serve to provide a level of abstraction using the
CMSIS OS APIs to existing Zephyr interfaces.

Removed one level and put them directly under include/portability.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-20 08:45:05 -04:00
Anas Nashif
a15f32f58c portability: move cmsis APIs to subsys/portability
Move cmsis OS apis under subsystem/portability. Those are not libraries
and only serve to provide a level of abstraction using the CMSIS OS APIs
to existing Zephyr interfaces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-04-20 08:45:05 -04:00