Commit graph

21541 commits

Author SHA1 Message Date
Jukka Rissanen
46efe3ed70 net: packet: Do not drop net_pkt immediately
If there are no sockets in the system, then do not drop the
packet immediately as there can be other L2 network handlers
like gPTP in the system. This will also allow ICMP messages
to pass to local handler.

Fixes #34865

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-24 23:29:24 -04:00
Henrik Brix Andersen
374629af90 canbus: isotp: remove unused work queue
Remove unused local work queue.

Fixes #34862

Signed-off-by: Henrik Brix Andersen <henrik@brixandersen.dk>
2021-05-22 08:14:35 -05:00
Carles Cufi
0e26836c8a Bluetooth: controller: Add conn creation param checks
Coverity detected that a zero divisor can be passed to
ll_create_connection() without parameter sanitization. Conditionally
check the connection creation parameters according to spec.

Fixes #35343.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-05-21 18:50:22 +02:00
Krzysztof Kopyściński
58460f9273 Bluetooth: gatt: cancel all prepared writes on invalid write response
On sending write request we should check write response.
If data prepaired to be written by peer or offset are not equal
to the data and offset we sent, we shall send Execute Write
Request with Request Flag set to 0x00 (Cancel All Prepared Writes).

This was affecting GATT/CL/GAW/BI-32-C and GATT/CL/GAW/BI-37-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-05-21 18:50:26 +03:00
Erik Brockhoff
6ce0f2ee66 Bluetooth: controller: add apto/appto reset for peripheral
For peripheral the apto/appto_expire are now reset on adv start

Signed-off-by: Erik Brockhoff <erbr@oticon.com>
2021-05-21 15:17:20 +02:00
Vinayak Kariappa Chettimada
d999d5eb64 Bluetooth: controller: Fix missing HCI event data len limit check
Fix the missing HCI event data len limit check when encoding
incomplete advertising data report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-21 13:39:22 +02:00
Andrzej Kaczmarek
9835888a91 Bluetooth: controller: Fix data length calculation in adv report
Max data length has to be adjusted for subevent code, otherwise we'll
hit an assert when trying to add data to event due to insufficient
free space.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-05-21 13:39:22 +02:00
Martin Jäger
a46a36a4cf task_wdt: Pause hardware wdt during debugging
Enable the option to pause the fallback hardware watchdog if the MCU is
halted by a debugger.

This fixes issue #33509 where some boards with Nordic MCUs could not be
flashed anymore after using the task watchdog sample.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-05-21 05:00:07 -05:00
Benjamin Lindqvist
f0f1a4d724 net: lwm2m: no duplicate device error codes
The resource description on the OMA LwM2M registry states that only the
first instance of a particular error should trigger creation of a new
error code instance.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2021-05-21 04:55:26 -05:00
Asger Munk Nielsen
38850b4820 Bluetooth: Controller: fix uninitialized variable
Fixes issue #35157
[Coverity CID: 221380]

Signed-off-by: Asger Munk Nielsen <asmk@oticon.com>
2021-05-20 21:27:40 -04:00
Martin Jäger
79531c86a2 task_wdt: use correct hardware watchdog channel number
The hardware watchdog was always fed with channel ID 0. This is correct
in most cases, but we should still use the actual ID returned from
wdt_install_timeout.

Signed-off-by: Martin Jäger <martin@libre.solar>
2021-05-20 13:18:45 -05:00
Vinayak Kariappa Chettimada
858dc7fab4 Bluetooth: controller: Fix EVENT_OVERHEAD_START_US jitter
As EVENT_OVERHEAD_START_US offset is used in ticks unit in
LLL, ULL scheduling using ticker should also use ticks unit
for EVENT_OVERHEAD_START_US when reducing the first
connection event preparation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-20 15:33:55 +02:00
Vinayak Kariappa Chettimada
8cfbaf5d55 Bluetooth: controller: Revert strict preempt ticker start failure check
Revert the strict preempt ticker start failure check.
Preempt ticker start can fail when enqueuing prepares into
already filled pipeline which has preempt ticker already
started for the first prepare that was added in the
pipeline.

Regression introduced in commit 5b75bdf589 ("Bluetooth:
controller: nRF5: Check preempt event on timeout").

Fixes #35476.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-20 15:33:32 +02:00
Emil Gydesen
01c4d597b3 Bluetooth: Host: Avoid memcpy'ing bt_addr_t to same pointer
From le_ext_adv_param_set we will occasionally attempt
to call bt_addr_copy where the `addr` and &adv->random_addr.a
are the same pointer. Doing a memcpy where source and destination
is the same pointer is undefined behavior and should not be
done.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-20 13:22:21 +02:00
Emil Gydesen
7d3def3275 Bluetooth: Audio: Fix VCS client shell missing compile
The VCS client shell was never compiled before, and thus
the implementation had a few undetected errors.

This commit adds the VCS client to the shell CMakelists
as well as fixing the issues.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-20 13:19:17 +02:00
Emil Gydesen
71c7566b96 Bluetooth: Audio: Move NULL check for conn in bt_vcs_discover
Move the check for the connection pointer before we get the
index.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-20 13:02:56 +02:00
Emil Gydesen
03a2c291c0 Bluetooth: Audio: Fix dead code issue in VCS
The common API functions in VCS had dead code in specific
configurations, causing coverity issues. Fixed by this
commit.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-20 12:00:57 +02:00
Vinayak Kariappa Chettimada
c0a8f38ec6 Bluetooth: controller: Avoid deferencing null return value
Add assert check to avoid deferencing null return value by
ull_adv_set_get() function.

Fixes #35347.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-19 17:10:08 -04:00
Vinayak Kariappa Chettimada
7d1a959d01 Bluetooth: controller: Explicitly ignore return value
Explicitly ignore return value from call to mayfly_enqueue.

Fixes #32917, #32961.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-19 17:10:08 -04:00
Vinayak Kariappa Chettimada
a92f7c6138 Bluetooth: controller: Fix side effect in assertion
Fix side effect in assertion when checking a volatile
variable inside assert check.

Fixes #32904, #32923.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-19 17:10:08 -04:00
Trond Einar Snekvik
85ad497c39 Bluetooth: Mesh: Don't reset PB ADV reliable timer on retransmit
The send_reliable function was reused in multiple places as part of the
k_delayed_work changes for Bluetooth Mesh in #33782. This function
contains a line that resets the start timer, causing prov_retransmit to
continously move the goal post for when to give up sending.

Extract this line out of the send_reliable function, and put it along
with the other link.tx initialization in bearer_ctl_send and
prov_send_adv.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-05-19 15:54:20 +03:00
Emil Gydesen
10011fd1de Bluetooth: Audio: Update VOCS conn check return value
Change the return value from -ENOTCONN to -EINVAL as that
is a more appropriate return value for checking a NULL
pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-19 07:53:10 -05:00
Emil Gydesen
a9efa14a95 Bluetooth: Audio: Update AICS client conn check return value
Change from -ENOTCONN to -EINVAL as that is a more appropriate
return value for checking a NULL pointer.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-19 07:53:10 -05:00
Emil Gydesen
8470fe8cb3 Bluetooth: Audio: Update VCS Client conn check return value
Instead of return -ENOTCONN they will now return -EINVAL as
that is a more appropriate return value for checking if
the pointer is NULL.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-05-19 07:53:10 -05:00
Jukka Rissanen
03e1872def net: tcp: Change locking order in connection establishment
When application calls TCP connect(), the call is blocked
by a semaphore which is then released when the connection
is established. Unfortunately the semaphore release was done
before the connection was marked as established. Depending
on the configuration options set, it is possible that after
the semaphore release, the thread that is waiting on connect()
is run immediately. Because of this, the connection bookeeping
still thought that the connection was not established even if
it was. A simple solution is to release the semaphore after
the connection is marked as established.

Fixes #35390

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2021-05-19 07:52:26 -05:00
Pavel Vasilyev
1b129c50c2 Bluetooth: Mesh: Remove outated RPL entry from persistent storage
This commit fixes a bug where outdated RPL entries might not be removed
properly from the persistent storage making those entries dead.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-05-18 12:29:53 -05:00
Freddie Yang
013008a3ef Bluetooth: Host: Disable BLE scan before setting random address
According to Bluetooth core specification v5.2, if Host set
random address when any of scanning (passive or active), the
Controller shall return the error code Command Disallowed (0x0C).

Signed-off-by: Freddie Yang <freddie.yang325@outlook.com>
2021-05-18 12:29:04 -05:00
Nick Ward
3cad7f3a19 shell: kernel: fix reset command echo abrupt termination
Allow time for the shell to successfully echo the reboot command input
before the reboot abruptly terminates it. n This can help external
systems that interact with the shell and require the reboot command's
echo to successfully complete to synchronise with the device.

Fixes: https://github.com/zephyrproject-rtos/zephyr/issues/35325

Signed-off-by: Nick Ward <nick.ward@setec.com.au>
2021-05-18 11:28:07 -05:00
Eduardo Montoya
68626227a3 net: openthread: fix CSL API
A couple of fixes on the OpenThread radio implementation.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-05-18 11:24:40 -05:00
Justin Morton
e3517e5080 net: http: update status if no status text is provided
Call on_status if the Reason-Phrase is not provided.
This allows for the numeric status code to be set.
Also, ensure the numeric status code is always set
in on_status, not just if the specific callback is set.

Signed-off-by: Justin Morton <justin.morton@nordicsemi.no>
2021-05-18 11:23:59 -05:00
Johann Fischer
21b3609824 net: enable TX thread if USB device support is enabled
Without TX thread support in network stack USB device stack
blocks it self by usb_transfer_sync() which is
called in the same context as usb_set_interface() in sequence
of netusb_enable(), net_if_up(), net_l2_send().

Fixes: #35338

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-05-18 11:21:51 -05:00
Pavel Vasilyev
8717a0f678 Bluetooth: Mesh: Pass correct pointer to publish_sent
This commit fixes a bug where incorrect pointer passed to publish_sent
in access.c caused bus fault.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-05-18 11:05:46 +02:00
Anas Nashif
cd9421a45e tracing: systemview: display return value of APIs
In systemview, display return value correctly.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
3b82c388f6 pm: trace pm_device_enable/disable
Trace both pm_device_enable and pm_device_disable.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
2642f4d62c pm: remove mention of FSM
FSM terminology was removed, clean some remaining occurances.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
eccda68418 power: trace power events
Trace PM transition sequence and events.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
7b9084cb4f ztest: set thread name to test name
Use the actual test name and not a hardcoded thread name. This is useful
for tracing test cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
b865c85ef4 tracing: fix test format
Add missing defines causing build errors in some scenarios.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 18:45:57 -04:00
Anas Nashif
009dee157d doc: fix doxygen grouping
Fix various grouping issues in doxygen and name groups correctly in some
cases.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2021-05-17 11:51:44 -04:00
Jukka Rissanen
d77290e235 testsuite: Allow user to override minimal logging
The testsuite was always forcing minimal logging. This is problematic
as it does not allow user to see full logging string. Allow user to
override the minimal logging if needed, the default is still to
enable minimal logging.

[DL: Commit 7f08061f0c reverts this.
     Since this is useful, let's re-apply this.]

Fixes #34696

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2021-05-17 10:58:27 -04:00
Trond Einar Snekvik
878043aff1 Bluetooth: Mesh: Change friend_cred decision point to friend selection
The network layer previously decided to use the friend credentials if
there was an established friendship. During the friendship setup phase,
the friendship is not considered established until the LPN receives the
first friend poll. Before this happens, the LPN should send a friend
poll message, encrypted with the friendship credentials. This wrongly
gets encrypted with the master credentials.

Change the decision point to whether the LPN has selected a friend,
which happens after the friend offer, and before the friend poll. This
will remain set for the duration of the friendship.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-05-17 13:36:24 +03:00
Pavel Vasilyev
22fabefdf2 Bluetooth: Mesh: Add VA flag to generic pending flags
This adds BT_MESH_SETTINGS_VA_PENDING to GENERIC_PENDING_BITS
as it should be stored by CONFIG_BT_MESH_STORE_TIMEOUT.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-05-17 13:23:30 +03:00
Pavel Vasilyev
3ae0f96acb Bluetooth: Mesh: Fix incorrect flag check in mesh settings
This bug was introduced in PR #31176, where setting's flags were
moved out from bt_mesh.flags to pending_flags.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
2021-05-17 13:23:30 +03:00
Jan Buenker
6815ef4a46 net: lwm2m: Only parse TLV from the first block
This was already implemented for firmware update packages.
For other opaque resources it failed to determine the target resource
id, which is now stored in the block_context.

Signed-off-by: Jan Buenker <jan.buenker@grandcentrix.net>
2021-05-13 22:07:25 -04:00
Vinayak Kariappa Chettimada
7897eae2b4 Bluetooth: controller: Fix PPIs use for nRF52805 SoC
Fix regression in PPIs use for nRF52805 SoC, which has
fewer of them. And the regression was introduced in
commit e603b9d59e ("Bluetooth: controller: Adjust PPI
used for nRF51x and nRF52x").

Fixes #35204.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-05-13 22:05:41 -04:00
Joakim Andersson
253350c6e7 Kconfig: Increase default thread analyzer stack size
Increase the default thread analyzer stack size. On ARM systems the
stack usage is higher with CONFIG_FPU enabled.
The default of 512 is not enough in this case and lead to stack
overflow.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-05-13 12:36:57 -04:00
Gerard Marull-Paretas
9b846351d9 pm: device: check for ENOSYS
If feature is not available -ENOSYS is used instead of -ENOTSUP.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-05-13 07:16:02 -05:00
Krzysztof Chruscinski
2a3a790a99 shell: log_backend: Fix fifo cleanup
When shell log backend was disabled fifo used only in
deferred mode was unconditionally flushed which lead to
errors in immediate mode where fifo was not present. On
the other hand, in case of LOG2_MODE_DEFERRED fifo (mpsc_pbuf)
was initialized in enable stage.

In order to clean things up, deferred v1 fifo flushing and
deferred v2 mpsc pbuf initialization were moved to fifo_reset
function which is called when shell log backend is enabled.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-13 14:04:08 +02:00
Krzysztof Chruscinski
f5be847e6d logging: Add missing va_end in log_msg2
Added missing va_end. Reported by coverity CID 232501

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-05-12 23:36:01 -05:00
Damian Krolik
643eb2080b openthread: shell: Do not execute OT commands when OT is not ready
OpenThread shell tries to execute commands without checking
if the shell has already been initialized. As a result, we
may hit an assertion in the OpenThread CLI code. It's
particularly painful in automated tests which spawn commands
very early in the firmware boot process.

Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
2021-05-12 08:31:08 -05:00