Commit graph

21541 commits

Author SHA1 Message Date
Marcin Niestroj
02fa7be52d net: mqtt: check mqtt_abort() function parameters before locking
Function parameters can be checked without MQTT instance lock being
held. Additionally if NULL parameter would be passed (which this check
tries to handle), then function would return without releasing lock.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-09-02 19:36:03 -04:00
Pavlo Hamov
6975d92324 net: socket: fix significant buffer tls send
Sending of > 2k buffers leads to split socket writes.
Current implementation is not checking for full buffer size.
ztls_sendmsg_ctx proceeds to next iov on sucessful write.

Solution: Add loop into ztls_sendmsg_ctx to process whole buffer
before proceeding to next iov.

Signed-off-by: Pavlo Hamov <pasha.gamov@gmail.com>
2021-09-02 19:35:50 -04:00
Gerson Fernando Budke
529d9149d3 mgmt: updatehub: Use coap_packet_get_payload function
The #36758 fixes coap_packet_get_payload function by normalizing
offset value in the library.  That change create a regression on
UpdateHub.  However, the UpdateHub can now use coap_packet_get_payload
function instead manually compute payload start and payload size.
This refactors the current code in favor of coap_packet_get_payload
and fixes the regression.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2021-09-02 16:54:15 +02:00
Nicholas Lowell
cc8ab95760 tracing: Add user-definable tracing interface
Create a new tracing option TRACING_USER that allows
the user to define certain user_sys_trace_... functions
to perform whatever work desired for tracing when
tasks are swiched in/out, during isr enter/exit, and when
cpu is idle.

This infrastructure can be useful for plugging into
locally defined tracing tools or any user-specific
debugging environment.

Signed-off-by: Nicholas Lowell <nlowell@lexmark.com>
2021-09-02 06:54:35 -04:00
Emil Gydesen
3a77308c97 Bluetooth: ISO: Add sent callback
Add a sent callback to bt_iso_chan_ops so that the application
can be notified when an SDU has been sent. This can help the
application decide whether to queue up multiple, or only
have a single ISO PDU enqueue for reduced latency.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-02 05:58:39 -04:00
Yong Cong Sin
c1a45596c6 subsys/shell: Use use_colors flag for shell instance
Patches the instance_init to use the use_colors flag

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2021-09-02 10:47:57 +02:00
Evgeniy Paltsev
60fdec616b ARC: MWDT: get rid of MWDT startup libs
__cxa_atexit implementation provided by MWDT startup code calls
malloc which isn't supported right now. As we don't support
calling static destructors in Zephyr let's provide our own
__cxa_atexit stub and get rid of MWDT startup libs
entirely.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-09-01 17:08:32 -04:00
Kumar Gala
a3480cf87c usb: Fix building error in usb_descriptor with misra test
When we build tests/kernel/common/kernel.common.misra on
bl654_usb we get the following error:

subsys/usb/usb_descriptor.c:313:2: error: ISO C90 forbids array
'hwid' whose size cannot be evaluated [-Werror=vla]

Fix by removing use of usblen variable in array.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-09-01 12:34:01 -05:00
Kumar Gala
13ba7c7825 Bluetooth: ISO: Fix build on native_posix_64 with debug
On native_posix_64 we get the following compile error in CI:

error: format %u expects argument of type unsigned int

Fix by using %zu instead of %u as type is of size_t.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-09-01 12:27:41 -04:00
Emil Gydesen
93bfe7a2c9 Bluetooth: ISO: Update BIS index to start from 0x01
The HCI spec defines the BIS index range as starting from
index 0x01. We had previously implemented it such that it
starts from 0x00, and then simply adding 1 to the index
when sending over HCI. However, this may cause issue with
other HCI, or other SIG defined specification, commands
and events, and thus it is probably simpler if we just
use the HCI defined range.

This commit disallows BIT(0) (representing the BIS
index 0x00) to be set, and removes the addition
of 1 when sending over HCI.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-01 10:57:07 -04:00
Markus Fuchs
05a1a5c41d logging: fs: Remove littlefs dependency
Remove littlefs dependency as FS backend works with any file system as
long as it is (manually or automatically) mounted.

Fixes #36851

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2021-09-01 08:39:24 -04:00
Vinayak Kariappa Chettimada
ced2116428 Bluetooth: Controller: Fix null pointer dereferencing in periodic sync
Fix null pointer deferencing in Periodic Synchronization
when ULL execution context could not assign an auxiliary
context when in LLL scheduling to receive chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
a63158fdde Bluetooth: Controller: Fix null pointer dereferencing in Extended Scan
Fix null pointer dereferencing in Extended Scanning when
there are more peer devices than the allocated auxiliary
contexts.

When LLL scheduling does not get an auxiliary context
assigned in the ULL execution context, then further chain
reception is aborted, access to `lll->lll_aux` which is
NULL causes null pointer dereferencing in
`ull_scan_aux_release`.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
b26c27f307 Bluetooth: Controller: Use lll_aux param for aux context release
When Extended Initiating a connection, release auxiliary
context memory referenced by the lll_aux pointer.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Vinayak Kariappa Chettimada
a633c00096 Bluetooth: Controller: Update Periodic Sync drift compensation
Update Periodic Advertising Synchronization's drift
compensation to save radio ready and address capture on
AUX_SYNC_IND reception, restore and apply at the end of
reception of all AUX_CHAIN_IND PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-09-01 08:38:37 -04:00
Emil Gydesen
0c7eda9777 Bluetooth: ISO: Pointer check in bt_iso_connected was incorrect
Instead of checking `if (iso == NULL)` it simply checked
`if (iso)` which is the opposite of what it should have done.

This completely blocks iso from connecting channels.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2021-09-01 08:38:12 -04:00
Eric Johnson
20b710a78e usb: class: cdc_acm: Add check for tx_irq_ena in tx_ready function
cdc_acm_irq_tx_ready was not checking if its interrupt was enabled.
This causes spurious tx irq handler calls.

Signed-off-by: Eric Johnson <eric@liveathos.com>
2021-09-01 11:50:59 +02:00
Eduardo Montoya
36459a95ea net: openthread: allow to enable/disable TCP
Allow to enable/disable the OpenThread TCP implementation. Disable
it by default.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-09-01 10:37:41 +02:00
Kumar Gala
6c98d41ba6 shell: Fix builds for platforms without uart
We get build issues due to the removal of the Kconfig symbol
CONFIG_UART_SHELL_ON_DEV_NAME on platforms that didn't have a uart
set as we'd get a default value for those platforms.  Update the
Kconfig logic to only enable SHELL_BACKEND_SERIAL if we have
zephyr,shell-uart specified in the devicetree to address the issue.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2021-08-31 16:31:57 -05:00
Michał Narajowski
e93b41a21a Bluetooth: host: Fix Limited Advertising timeout cancel
Timeout cancel should only be done for connections established in
peripheral role.

Enhanced connection complete event could still be delivered without
extended advertising support (i.e no advertising set terminated event)
so this handling should be moved to the common conn complete function.

Fixes #37467

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-31 15:35:47 -04:00
Trond Einar Snekvik
c5757ca4a1 Bluetooth: Mesh: Initialize UUID in shell's mod_pub_set
PR #35774 introduced a uuid field in the bt_mesh_cfg_mod_pub structure.
The shell does not initialize this pointer before passing it to the
access layer. Add a line to initialize this pointer.

Fixes #38016.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Trond Einar Snekvik
4eb047d1af Bluetooth: Mesh: Remove lpn timeout param check
param can never be NULL here, so the check is redundant. Coverity is
complaining because param is accessed before the NULL check.

Fixes #37949.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Trond Einar Snekvik
fd6f51c410 Bluetooth: Mesh: Remove krp param check
param can never be NULL, so this check is redundant. Coverity complains
about this, as the param variable is accessed before the check, which
would be wrong if param could be NULL.

Fixes #37948.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-08-31 11:03:06 -04:00
Vinayak Kariappa Chettimada
5f55d8ef78 Bluetooth: Controller: Fix uninitialized pointer read of SR ADI
When Extended Scan Response data of length zero is set, the
Scan Response do not have the Common Extended Payload Format
and hence no ADI field. Fix uninitialized pointer to Scan
Response Data's ADI to avoid copy of ADI from primary
channel PDU.

Fixes #38015.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-31 14:04:28 +02:00
Carlo Caione
4b5bab2bc1 ipc: rpmsg_multi_instance: Re-organize the init function
The rpmsg_mi_ctx_init() function is long and complex. Split it into
several logical units.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-08-30 13:42:45 -04:00
Carlo Caione
f0a8c5fd77 ipc: rpmsg_multi_instance: Remove useless return
Remove redundant return call.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-08-30 13:42:45 -04:00
Carlo Caione
7fcb329951 ipc: rpmsg_multi_instance: Fix wrong return value
The rpmsg_mi_configure_shm() function is not returning anything and it
is not marked as static. Fix this changing the return type to 'static
void'.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-08-30 13:42:45 -04:00
Carlo Caione
6d39c6ec70 ipc: rpmsg_multi_instance: Fix misleading types
When possible use 'size_t' for sizes and 'uintptr_t' for generic
addresses instead of relying on uint*_t types.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-08-30 13:42:45 -04:00
Lingao Meng
faf9efcb47 Bluetooth: host: Fix missing attr when indicate
When call bt_gatt_indicate with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
notify --> gatt_indicate --> bt_gatt_check_perm

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-30 13:41:03 -04:00
Lingao Meng
6ebdbe5974 Bluetooth: Fix missing rewrite attr
When call `bt_gatt_notify_cb` with param->attr set to null.
and attr->uuid set to given uuid, the internal notify will
search uuid, but not assigned to param->attr, which cauce
null point reference when:
   notify --> gatt_notify  --> bt_gatt_check_perm

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-30 13:41:03 -04:00
Johann Fischer
797d8d6a44 usb: dfu: add __fallghrough to DFU_UPLOAD/dfuIDLE case
Add __fallghrough to DFU_UPLOAD/dfuIDLE case.

Coverity-CID: 239607

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-30 13:40:46 -04:00
Gerson Fernando Budke
2797afb749 debug: thread_info: Add posix thread status
Add missing THREAD_INFO_OFFSET_T_STACK_PTR information for arch posix.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
2021-08-30 13:18:04 -04:00
Johann Fischer
9d45581735 usb: cdc_acm: prefix ringbuffers with cdc_acm
Prefix ringbuffers with cdc_acm because it is not possible
to use static specifier with RING_BUF_*_DECLARE_* macros
to avoid conflicts.

Fixes: #36608

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-30 09:33:09 -04:00
Filip Kokosinski
19fc1ee77c subsys/random: change parameters for timer-based PRNG
PR #36996 disabled running mem_protect/stack_random test on qemu_riscv32
platform because of this test consistently failing on said platform.
This test starts new threads in equal time intervals, and because of
that we get repeating values after performing the modulus operation when
calculating the stack pointer address.

This can be solved by changing the value of the _RAND32_INC constant
that is used to increase the value returned by the timer-based PRNG.

This commit decreases the value of the mentioned constant from
1000000013U to 1000000003U.

Fixes #37006.

Signed-off-by: Filip Kokosinski <fkokosinski@antmicro.com>
2021-08-30 09:32:36 -04:00
Michał Narajowski
a9db9a3aa8 Bluetooth: host: Cancel limited adv timeout when advertising stopped
Advertising might stop when:
- it was stopped by application
- device connected to a peer
- extended advertising reached stop condition
  defined in BT_LE_EXT_ADV_START_PARAM - this is handled in ll

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-30 14:41:20 +02:00
Michał Narajowski
cca76f157c Bluetooth: host: Fix advertise stop in adv_timeout()
Call bt_le_adv_stop() if adv == bt_dev.adv (Meaning it is the legacy
advertiser and was started with bt_le_adv_start()), otherwise use
bt_le_ext_adv_stop(), because it was started with bt_le_ext_adv_start().

Failing to stop advertising shouldn't result in assert.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-30 14:41:20 +02:00
Przemyslaw Bida
f77c7dc2c8 manifest: Regular upmerge to bring the openthread CSL fixes.
Periodic upmerge of OpenThread.

Signed-off-by: Przemyslaw Bida <przemyslaw.bida@nordicsemi.no>
2021-08-30 13:32:53 +02:00
Torsten Rasmussen
c6aded2dcb linker: align _image_rodata and _image_rom start/end/size linker symbols
Cleanup and preparation commit for linker script generator.

Zephyr linker scripts provides start and end symbols for each larger
areas in the linker script.

The symbols _image_rom_start and _image_rom_end corresponds to the group
ROMABLE_REGION defined in the ld linker scripts.

The symbols _image_rodata_start and _image_rodata_end is not placed as
independent group but covers common-rom.ld, thread-local-storage.ld,
kobject-rom.ld and snippets-rodata.ld.

This commit align those names and prepares for generation of groups in
linker scripts.

The symbols describing the ROMABLE_REGION will be renamed to:
_image_rom_start -> __rom_region_start
_image_rom_end   -> __rom_region_end

The rodata will also use the group symbol notation as:
_image_rodata_start -> __rodata_region_start
_image_rodata_end   -> __rodata_region_end

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2021-08-28 08:48:03 -04:00
Flavio Ceolin
d9d5c41294 pm: device: Remove transitional states
PM_DEVICE_STATE_RESUMING and PM_DEVICE_STATE_SUSPENDING
are transitional states and are only used in device runtime. Remove it
and use device flag to keep track of a transition.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-27 17:47:10 -04:00
Flavio Ceolin
2549160d69 pm: device: Remove PM_DEVICE_STATE_FORCE_SUSPEND
This is not a state but an action. Just remove it.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2021-08-27 17:47:10 -04:00
Andrzej Kaczmarek
f2f99c0784 Bluetooth: Controller: Remove redundant local variable
'err' is already defined in parent scope, we can use. Just need to set
it back to 0 before returning from function.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
b308192bb1 Bluetooth: Controller: Add todos for per adv chain scan
Add todos for few useful improvements that can be done later.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
993838edbf Bluetooth: Controller: Make lll_create_iq_report static again
This was changes when sync chain handling was done in lll_scan_aux, we
can now revert to original code.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
1e6c69bc89 Bluetooth: Controller: Update BT_CTLR_ADV_EXT_RX_CNT for ea and df
We need more RX nodes when scanning either extended/periodic advertising
trains and CTE samples so pudate those values based on observer and DF
features enabled.

The number of nodes for non-DF allows to scan complete chain for each
aux scan set (assuming max data length and optimal fragmentation by
advertiser), for DF it allows to scan max possible PDUs and CTE samples.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
11da89cff1 Bluetooth: Controller: Remove unused flag
This seems not to be needed anymore, it's only written.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
88b4f45eae Bluetooth: Controller: Move aux sync scanning to lll_sync
Periodic advertising train scanner implemented in lll_scan_aux adds lots
of branches that cannot be compiled out with periodic advertising sync
disabled.

This commit moves sync parts of the code from lll_scan_aux to lll_sync.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
f353202eb7 Bluetooth: Controller: Fix DF for per adv chains scanning
This updates DF to properly receive CTE in per adv chains scanning.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
0723e7dc5e Bluetooth: Controller: Rework support for periodic adv reports
Periodic advertising PDUs are now dispatched immediately one by one
(i.e. without list of PDUs as when flushed from aux context) so we
do not need to iterate such a list.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
139711fd74 Bluetooth: Controller: Fix parsing sync report PDU
AdvA, TargetA, ADI and SyncInfo are RFU in periodic advertising PDUs so
we should ignore them when present in PDU.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00
Andrzej Kaczmarek
846f5e7b4a Bluetooth: Controller: Dispatch rx nodes for sync immediately
Periodic advertising reports can be reated directly from single PDU
as they do not require any information from superior PDU, so we can
dispatch them immediately instead of buffering in aux context and
flushing at the end of chain.

This also resolves proper order of Periodic advertising and IQ reports.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2021-08-27 11:46:31 -04:00