Commit graph

11328 commits

Author SHA1 Message Date
Krzysztof Chruscinski eb9814c626 testsuite: ztest: Fix concatenation in macro
Use UTIL_CAT which resolves input arguments instead of direct
preprocessor concatenation.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-02-01 08:16:10 -05:00
Joakim Andersson 743b0583fc Bluetooth: controller: Enable debug pins with TF-M enabled
Enable debug pins when TF-M has been enabled for the image.
This would otherwise produce an error message as the DEBUG_SETUP would
not have been defined for the non-secure image.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2022-02-01 11:31:36 +01:00
Vinayak Kariappa Chettimada b5ab2f1353 Bluetooth: Controller: Fix missing ISO data packet receive
Fix missing ISO Data packet received by Synchronized
Receiver due to incorrect check on sink handle that did
not permit handle value of 0.

Fixed function to get ISO stream context to check for
valid ISO sync context, i.e. not being terminated.

Regression introduced in commit 7c89f1fe9f ("Bluetooth:
controller: Support for separate ISO RX data path").

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-31 18:12:10 +01:00
Dominik Ermel 8a4c58618b mgmt/mcumgr/lib: Return error on bad SMP header
The changes smp_process_request_packet to return MGMT_ERR_ECORRUPT
in case when failed to read header.
This helps to recognize that there will not be any response sent
from mcumgr to the buffer given to smp_process_request_packet as
it has not been recognized as valid request.
It also removes redundant check on mgmt_streamer_init_reader which
always returns 0 (no failure) in Zephyr.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 17:22:03 +01:00
Robert Lubos f4a18e471b net: sockets: tls: Fix ZSOCK_POLLHUP detection
The previous approach to detect if the underlying transport was closed
(by checking the return value of `mbedtls_ssl_read()` was not right,
since the function call does not request any data - therefore 0 as a
return value is perfectly fine.

Instead, rely on the underlying transport ZSOCK_POLLHUP event - if it
reports that the connection ended, forward the event to the application.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-31 17:20:55 +01:00
Robert Lubos f8751629c7 net: sockets: Report ZSOCK_POLLHUP when socket is in EOF state
Report ZSOCK_POLLHUP event if peer closed the connection, and thus the
socket is in EOF state.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-31 17:20:55 +01:00
Dominik Ermel e83b074128 mgmg/mcumgr/lib: Image upload size no longer needs flash alignment
The mcumgr image upload uses buffed flash writes with use of stream
flash, which makes flash alignment check unneded.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-31 16:22:55 +01:00
Vinayak Kariappa Chettimada 3f37210cd6 Bluetooth: Controller: Fix parsing empty ADV_EXT_IND and ADV_SYNC_IND
Fix implementation to check for empty ADV_EXT_IND and
ADV_SYNC_IND PDUs, and not parse them incorrectly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-31 12:13:08 +01:00
Vinayak Kariappa Chettimada faa89c779c Bluetooth: Controller: Fix Periodic Adv Report to scan max data length
Fix implementation to limit Periodic Advertising data to a
configurable maximum length when generating HCI reports.

Bluetooth Test Specification defines Scan_Max_Data value
in IXIT. When HCI LE Periodic Advertising Report events are
generated by assembling the chain PDUs, the test cases
expect that if the data length is no more than
Scan_Max_Data, then at least once the IUT shall not
truncate the data in the advertising report.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Vinayak Kariappa Chettimada 93d6d1e114 Bluetooth: Controller: Minor fix isr_done context parameter passed
Remove redundant parameter pass of lll_aux to isr_done as
the auxiliary context use is always for scan context as the
parent.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Vinayak Kariappa Chettimada 1fe80ec62a Bluetooth: Controller: Minor refactor for consistent variable names
Minor refactor of auxiliary scanning implementation to use
consistent variable naming and assignment close to its
locality of reference.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Vinayak Kariappa Chettimada 3c1277b49d Bluetooth: Controller: Rename per_scan field to periodic
Rename per_scan field in scan context to periodic field to
avoid confusing with abbreviation for peripheral.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Vinayak Kariappa Chettimada 77e810e4b8 Bluetooth: Controller: Rename flag to sync_term to is_term
Rename the flag sync_term to is_term to be consistent with
other flags.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-28 19:13:56 -05:00
Rubin Gerritsen 4e88c91964 Bluetooth: Host: Fix address and SID in the sync established cb
When the periodic advertiser list is used,
the address and SID may not be identical to those passed in by
the application.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2022-01-28 15:42:25 +01:00
Andy Ross 0c30db1ec5 subsys/pm: C99-legalize declaration of CPU power states
The CPU power states were declared with a typecast array literal,
which is a GNU extension.

Unfortunately some compilers (xt-xcc even in very recent versions,
when used with -fdata-sections) will die with a compiler error when
those rvalues are used in an expression that also takes their address,
e.g.:

    /* this all by itself crashes xcc -fdata-sections */
    int *foo = (int[]){0};

Declare the array elments in two steps, making the code standard C.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2022-01-27 16:26:27 -05:00
Aleksander Wasaznik 30098c881f Bluetooth: Host: Detect deadlock in bt_att_req_alloc
`gatt_req_alloc` will wait until a `req` is free (or until timeout).
`req`s are freed on the BT RX thread in calls into bt_att_recv.

When `gatt_req_alloc` called on the BT RX thread itself when there are
no free `req`s, it will block the BT RX thread and deadlock. The
deadlock lasts until timeout.

This change detects this condition and returns the failure early.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/39624 where
if `bt_gatt_write` is called from BT RX thread (as can happen if it is
called from a bluetooth callback), the BT RX thread can be blocked and
prevented from processing the request responses and unblocking itself.
This was the cause of a soft 30s deadlock until gatt_req_alloc timeouts.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-01-27 16:04:24 +01:00
Aleksander Wasaznik 8d5be19e0b Bluetooth: Host: Handle req alloc failure in bt_gatt_unsubscribe
`gatt_write_ccc` may fail if it is unable to allocate a `bt_att_req`.
This change adds handling of this case to `bt_gatt_unsubscribe`.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2022-01-27 16:04:24 +01:00
Krzysztof Chruscinski 3fd3793c76 testsuite: tc_util: Limit include range
tc_util.h is also included by unit tests and in that case it
cannot have dependencies to subsystems. Including log_ctrl.h
only for ARCH_POSIX where it is needed to flush logs before
exit.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-27 09:58:08 -05:00
Vinayak Kariappa Chettimada 4e5290948e Bluetooth: Controller: Fix Periodic Advertising to setup Power Amp
Fix Periodic Advertising implementation to setup Power
Amplifier (PA) GPIO toggle for transmission instead of
incorrect Low Noise Amplifier (LNA) setup which is for
reception.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-27 14:02:01 +01:00
Vinayak Kariappa Chettimada e1a3606391 Bluetooth: Controller: Define EVENT_SYNC_B2B_MAFS_US
Define EVENT_SYNC_B2B_MAFS_US to use the Kconfig option
used to configure the MAFS between Periodic Advertising
chain PDUs.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-27 14:02:01 +01:00
Vinayak Kariappa Chettimada 2d953b6b9e Bluetooth: Controller: Fix Periodic Advertising ADI feature bits
Fix Periodic Advertising ADI Support feature bits so that
it is return back in the Read Local Supported Features.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-27 14:01:54 +01:00
Vinayak Kariappa Chettimada 7bc3fdc856 Bluetooth: Controller: Fix Periodic Sync LLL scheduling flag
Fix Periodic Advertising Sync LLL scheduling flag to not be
set when chain PDUs use LLL scheduling, only set when
primary AUX_SYNC_IND PDU received use LLL scheduling.

Without the fix, spurious EVENT_DONE_EXTRA_TYPE_SYNC would
be generated when chain PDUs are failed to be received. This
can cause Sync Lost message to be generated.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-27 14:01:41 +01:00
Andries Kruithof 54314322c9 Bluetooth: controller: llcp: update lll_scan_aux for new LLCP
The lll_scan_aux.c file does not compile when the new LLCP is
selected due to missing conditional compiles.
Conditional compile and proper tx_times are selected with this
commit

Signed-off-by: Andries Kruithof <Andries.Kruithof@nordicsemi.no>
2022-01-27 13:11:07 +01:00
Emil Gydesen 102dcca6a4 Bluetooth: Audio: Add BT_WARN for missing stream callbacks
If any specific stream callback is attempted
to be called but is missing, a BT_WARN log statement
is added.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Emil Gydesen 9140a8ac46 Bluetooth: shell: Add LE Audio shell commands
Adds audio.c which covers all the LE Audio shell commands.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Emil Gydesen cf06fa85f2 Bluetooth: Audio: Add BAP broadcast sink support
Add support for the BAP broadcast sink role. This role
allows a device to sync to a broadcast ISO stream.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Emil Gydesen ab87e0a2ba Bluetooth: Audio: Add BAP broadcast source support
Add the BAP broadcast source implementation. This role
allows a device to broadcast ISO data.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Emil Gydesen 59bafc430f Bluetooth: Audio: Add BAP unicast client support
Add the BAP unicast client implementation. This role
can discover BAP unicast server services and initiate
BAP audio streams.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Emil Gydesen 03862b3db5 Bluetooth: Audio: Add BAP unicast server support
Add the Basic Audio Profile (BAP) unicast server
functionality. This allows a device to act as the
unicast server role, which can accept unicast streams
initiated by a unicast client.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2022-01-27 12:01:34 +02:00
Krzysztof Chruscinski 157c48e4eb logging: log_output: Fix immediate output for big endian
Pointer to int was passed to a function which expected pointer to
uint8_t. There was an unexpected content for big endian as the
highest byte was read instead of the lowest which contained valid char.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-27 10:02:21 +01:00
Krzysztof Chruscinski a40ca6fd1c logging: printk: Fix LOG_PRINTK for v2
Fixed a dependency from printk.h to logging headers which in
certain configurations could lead to circular dependencies.
Cleaned up printk.c to call z_log_vprintk from vprintk.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-27 10:02:21 +01:00
Krzysztof Chruscinski 8850954c6d testsuite: ztest: Add logs flushing after suite
Flushing logs here is especially vital if LOG_PRINTK is enabled.
In that case printk goes to log and without flushing after all
tests are run you will not get the final report out.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-27 10:02:21 +01:00
Krzysztof Chruscinski b85689ba42 testsuite: tc_util: Flush logs before posix_exit
Flush all logs before terminating test in posix.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2022-01-27 10:02:21 +01:00
Vinayak Kariappa Chettimada 8a5f0b50eb Bluetooth: Controller: Restrict Extended Adv Report to max data length
Add implementation to limit Extended Scanned data to a
configurable maximum length when generating HCI reports.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2022-01-26 17:07:32 +01:00
Thomas Ebert Hansen f10daf7c4a Bluetooth: host: Fix DB hash calculation
When hashing attributes for the UUID cases:
    BT_UUID_GATT_PRIMARY_VAL
    BT_UUID_GATT_SECONDARY_VAL
    BT_UUID_GATT_INCLUDE_VAL
    BT_UUID_GATT_CHRC_VAL
    BT_UUID_GATT_CEP_VAL

where (handle || UUID || value) is to be hashed, the worst case size of
attribute value can be deduced from the associated union that describes
all the attribute values in the given cases.

Update the data array to accommodate for the worst case size.

Fixes #39131

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2022-01-26 13:10:29 +01:00
Johann Fischer 388001456c usb: bluetooth: check buffer tailroom before copying
If HCI packet length is greater than endpoint MPS or currently
received data block (over USB), next block could be larger
than allocated net_buf buffer.

Check buffer tailroom before copying data using net_buf_add_mem().

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-01-26 11:54:31 +01:00
Johann Fischer 0be729de8a bluetooth: hci_raw: avoid possible memory overflow in bt_buf_get_tx()
Function bt_buf_get_tx(), which is used to allocate buffer from
fixed-size pool, does not check size argument before copying
the data with the length size into fixed-size buffer, wich may
not be large enough.

Check immediately before copying if the tailroom of the buffer
is large enough.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2022-01-26 11:54:31 +01:00
Robert Lubos e718c8c2dc net: if: Leave all IPv4 mcast groups when interface goes down
In a similar way as its done for IPv6. This allows to rejoin the group
once the interface is up again.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Robert Lubos 4da1a75a6c net: llmnr: Rejoin IPv4 multicast group when iface is brought up
When network interface is brought up, rejoin the IPv4 multicast group
used by LLMNR service.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Robert Lubos 6f19b6e59e net: mdns: Rejoin IPv4 multicast group when iface is brought up
When network interface is brought up, rejoin the IPv4 multicast group
used by mDNS service.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-26 10:50:24 +01:00
Maureen Helm 1a7bc06086 debug: Remove deprecated CONFIG_OPENOCD_SUPPORT
CONFIG_OPENOCD_SUPPORT was deprecated in favor of
CONFIG_DEBUG_THREAD_INFO in Zephyr v2.6.0 and can now be removed.

Signed-off-by: Maureen Helm <maureen.helm@intel.com>
2022-01-24 10:23:20 -05:00
Yong Cong Sin 4b40dce981 net: mgmt: Use mutex for net_mgmt_lock
Conceptually the net_mgmt_lock should be a mutex instead of a
semaphore. It is easier to identify the owner of a mutex and
debug when deadlock happens, so convert it.

Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
2022-01-22 16:56:09 -05:00
Wealian Liao 7467dc4c12 tracing_user: Add ISR nest level parameter
For tracing_user, the sys_trace_isr_enter() & sys_trace_isr_exit()
block any nest interrupts & most SMP interrupts for the user. It is
hard to analyze the IRQ preemption(e.g., each IRQ counter and execution
time). This commit adds ISR nest level for each CPU to the user instead
of blocking user call back when nest interrupts.

Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com>
2022-01-21 14:38:35 -05:00
Dominik Ermel 643e4d65c6 mgmt/mcumgr/lib: Fix bug in file download chunk size config
The commit fixes bug in compile time calculation of file download
chunk, FS_MGMT_DL_CHUNK_SIZE, that is permitted within selected
mcumgr buffer size, where the mcumgr header length has not been
taken into account.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 13:17:59 -05:00
Dominik Ermel 2f7c2333c8 mgmt/mcumg/lib: Use Kconfig options directly in img mgmt
The commit removes internal names given to Kconfig options,
in img_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:34:38 -05:00
Dominik Ermel 6bbc261402 mgmt/mcumg/lib: Use Kconfig options directly in fs mgmt
The commit removes internal names given to Kconfig options,
in fs_mgmt_config.h, and modifies code to use the Kconfig options
directly.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2022-01-21 11:32:56 -05:00
Ryan Erickson c6ace45a6c net: lwm2m: add uCIFI Battery object (3411)
Add the uCIFI Battery object to support
monitoring a devices battery.

Signed-off-by: Ryan Erickson <ryan.erickson@lairdconnect.com>
2022-01-21 11:32:08 -05:00
Robert Lubos 4557d183b9 net: http_client: Set body_start pointer unconditionally
Set `body_start` pointer regardless of the body position in the recv
buffer. In result, the pointer shall indicate correctly position of the
body for each fragment, it's also explicit now that if the pointer is
not set for a fragment, there's no body in that particular fragment.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-21 11:31:49 -05:00
Robert Lubos d002f8a524 net: lwm2m: Fix attribute sanity check
Validate the respective attribute parameters only if both are provided
at given level. This prevents from comparing for instance unset pmax
value (equal to 0) with some new pmin value sent by the server.

Additionally, fix the sanity check for the `pmax` value set on observer,
after fetching the attribute value at all levels (including the default
value at from the server object). Instead of using wrong max(pmin, pmax)
formula, set the pmax value only if it's a valid one (>= pmin),
otherwise ignore the value and set it to 0. This makes the notification
engine ignore the pmax value set for observation.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2022-01-21 11:31:20 -05:00
Piotr Pryga 4d3985f93c Bluetooth: Controller: Enable PDU CP bit when CTE RX is enabled
The CP bit is read in DF connected mode while interpreting
LL_CTE_RSP PDU, hence it must be available in struct pdu_data
type.

There were missing two Kconfig options in new LLCP tests.
They were reponsbile for disable of CP bit instruct pdu_data.
That caused tests to fail during compilation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2022-01-21 09:30:23 -05:00