Commit Graph

9214 Commits

Author SHA1 Message Date
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
Jordan Yates df66cca6b6 lorawan: always wait for MAC ops to complete
Wait for MAC operations to complete when transmitting. Unconfirmed
messages still open receive windows and can cause error conditions,
which are currently dropped.

It is also possible for a second send to be requested before the first
one has finished processing, which results in `LORAMAC_STATUS_BUSY`.
Empty frames (due to insufficient payload space) now also block until
the MAC layer is ready to accept new commands.

This change means the application no longer needs to guess-and-check
when it is possible to send unconfirmed messages.

Fixes #33456.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2021-04-20 12:42:56 +02:00
Robert Lubos 0b63a9618b net: telnet: Fix character mode handling
If the telnet client operates in a character mode, it may send
individual characters in packets. Such packets were dropped in the
telnet shell backend instead of being process by the shell engine.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2021-04-19 17:12:23 +02:00
Krzysztof Chruscinski 320f7c3808 net: lib: openthread: logging: Refactor logging function
Refactor logging function to avoid multiple macro calls.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski 7bae59481e shell: Add support for logging v2
Extended shell to support logging v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski bb64419a29 logging: Adapt ADSP backend to v2
Added support for v2 backend interface to ADSP.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski da31e09f2b logging: Add v2 support to RTT backend
Add support for logging v2 to RTT backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski e767bf6377 logging: Add v2 support to native_posix backend
Add support for logging v2 to native_posix backend.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski 7ce3f7a25a logging: backend_uart: Adapt to support v2 api
Adapted to handle processing of v2 log messages.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski f1bb20f6b4 logging: Adapt logger to support both versions
Adapted to be able to switch between v1 and v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski 902ccd7235 logging: log_output: Extend to support log_msg2 parsing
Added parsing of log_msg2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski f6a40ae183 logging: Add logging v2 implementation for log_msg
Added implementation of log_msg2 which is creating log messages
using cbprintf packaging and storing them in circular ring buffer
(mpsg_pbuf).

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski ba1aa75c66 logging: Refactor in preparation for logging v2
Refactor and cleanup in preparation for v2.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski 67fade04a0 net: l2: bluetooth: Add cast to forward declared struct
Logging v2 is using _Generic keyword for detecting type of
log message arguments. Apparently, it does not support handling
of pointers to forward declared structures. Added casting to void *.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Krzysztof Chruscinski b3c5496159 bluetooth: Add cast to forward declared struct
Logging v2 is using _Generic keyword for detecting type of
log message arguments. Apparently, it does not support handling
of pointers to forward declared structures. Added casting to void *.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-04-19 10:59:23 -04:00
Vinayak Kariappa Chettimada 41e9493ae1 Bluetooth: controller: Fix missing encryption procedure state check
Fix a missing encryption procedure state check which allowed
out of order receive of START_ENC_RSP PDU, which made the
controller to believe its already in an encryption procedure
in progress state.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:59:01 -04:00
Asbjørn Sæbø 22068d4967 Bluetooth: services: Do not set current object until selected
Do not make the first object added to the object transfer server the
current (=selected object).  This leads to the server having no
current object until one is selected by the client.

This solves a startup issue where the selected callback is not called
by the server if the first object selected by the client happens to be
the same object as the object that was first added to the server.  In
that case, the user of the OTS does not know which object is selected,
and therefore may not be able to supply the correct data later.

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2021-04-19 16:18:16 +02:00
Vinayak Kariappa Chettimada 82925a8c99 Bluetooth: controller: Avoid sizeof to access ULL/LLL struct member
Avoid using sizeof to access ULL and LLL struct members.
Based on the alignment requirements of structures, due to
padding between structure members, use of sizeof of previous
struct member to access next struct member is incorrect.

Continue to use explicitly stored parent pointer to access
ULL context. Combine event header and ULL header so that
the parent pointer point directly to the combined ULL
struct.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Vinayak Kariappa Chettimada e395c6ce2c Bluetooth: controller: Fix uninitialized ULL reference count
Fix missing initialization of reference count in
ull_hdr_init function.

This has not caused issues so far, but when the ref member
of the struct ull_hdr if placed in the beginning of a
context that is allocated using mem_acquire function then
first few bytes used would make the ref member to have
uninitialized value when such context is allocated by
mem_acquire. First few bytes are the next pointer and free
count stored by the mem module.

The issue was discovered in subsequent commits that
restructure the ULL context structures.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Vinayak Kariappa Chettimada 624e003064 Bluetooth: controller: Fix auxiliary scan context release
Fix the auxiliary scan context release to be performed in
the disabled_cb callback after the ULL reference count is
decremented.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Vinayak Kariappa Chettimada 3a80785947 Bluetooth: controller: Fix connection terminate to happen on event done
Fix conn_cleanup to be performed in the event done. The
regression was introduced in
commit 5412f61ac6 ("Bluetooth: controller: Introduce
separate done memq").

Now that done event is handled asynchronously outside the
handling of the terminate node rx type, it is necessary that
terminate node rx type is generated after the done event.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-04-19 10:26:38 +02:00
Wolfgang Puffitsch 13b4d441b3 Bluetooth: controller: Fix dependency of ISO TX buffer Kconfig
Synchronized Receiver does not require TX buffers.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-04-19 10:22:59 +02:00
Wolfgang Puffitsch 88db0d4b45 Bluetooth: controller: Consolidate ISO role Kconfigs
Consolidate Kconfigs for ISO roles to make compilation guards more
concise. Just introduces aliases, does not change functionality.

Signed-off-by: Wolfgang Puffitsch <wopu@demant.com>
2021-04-19 10:22:59 +02:00
Carles Cufi f86e8a66d8 random: rand32_timer: Avoid alignment faults by using memcpy
The previous implementation assumed that the dst pointer was always
aligned to a 4-byte boundary in platforms that require alignment for
storage of 32-bit integers. Since this is required for certain platforms
(eg. Arm Cortex-M0), use memcpy() instead, which always takes
alignment into account.

Fixes #33969.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2021-04-16 15:34:59 -04:00
Trond Einar Snekvik 286d9c22cd Bluetooth: Mesh: Convert beacon timer to delayable work
Moves the beacon_enabled check in the beacon work handler to check the
beacon flag before sending anything, in case a cancel call fails.

Split out from #33782.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-16 15:34:30 -04:00
Jonathan Rico 545938ea55 Bluetooth: host: Accept keypress notifications as responder
Ignore peer keypress notifications as a responder, allowing the pairing
procedure to continue instead of being aborted.

The Bluetooth LE specification does not specify a behavior, the
implementation has the choice of ignoring or aborting.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2021-04-16 15:34:06 -04:00
Trond Einar Snekvik 777718ea6e Bluetooth: Mesh: move lpn logic for msg_received inside lpn.c
The Transport layer implements some checks surrounding the
lpn_msg_received call, with an accompanying comment that explains the
logic. Move this inside the msg_received call instead.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-16 15:33:09 -04:00
Trond Einar Snekvik f54ca2fefd Bluetooth: Mesh: LPN: Rework poll timeout scheduling
Switch to the new delayed work API. Puts the scheduling for the next
poll in the response_received function instead of cancelling it, then
optionally scheduling it again later.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2021-04-16 15:33:09 -04:00