Commit graph

21541 commits

Author SHA1 Message Date
Vinayak Kariappa Chettimada
fcc15f713a Bluetooth: Controller: Fix resolving index from being overwritten
When generating LE Extended Advertising Report the device
address can be either in primary or auxiliary channel PDU,
do not overwrite resolving list index if present in primary
channel PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2021-08-04 10:36:46 +02:00
Johann Fischer
4b79912dc7 usb: check request direction in request handlers
Check request direction in standard device,
interface, and endpoint request handlers.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
af3e1096f5 usb: cleanup standard interfave request handler
Cleanup standard device request handler.
Pass pointer to setup packet as argument where
it is reasonable.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
49745250e4 usb: cleanup standard endpoing request handler
Cleanup standard endpoint request handler.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
d2ff6f4fdc usb: cleanup standard device request handler
Cleanup standard device request handler.
Pass pointer to setup packet as argument where
it is reasonable.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
961d4a63fd usb: hid: obtain the requested length from wLength
Obtain the requested length from wLength and assign the
possible length to len argument.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
315e148864 usb: dfu: halt endpoint on flash API error or block mismatch
Halt endpoint on flash API error or block mismatch.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
d6e2c8afa1 usb: dfu: check control request direction
Check control request direction and split class request handler
by request direction.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
7aeed96e5d usb: msc: additionally check control request direction
Rework class control request handler and add control
request direction check.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
4e6bf5b567 usb: bt_h4: return -ENOTSUP on vendor requests
This class does not handle any vendor request,
therefore just return -ENOTSUP on any vendor request.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
4adde81b43 usb: bluetooth: additionally check control request direction
HCI commands are always directed to controller and should be
host-to-device class control requests.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
78b9acf852 usb: audio: additionally check control request direction
Rework mute request handling and add checks for
control request direction.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
37d8236be4 usb: rndis: return error on incorrect/unsupported request
Return ENOTSUP if request is unsupported and pass on the error
from encapsulated command/response functions.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
a5493a5c71 usb: cdc_ecm: return error on incorrect/unsupported request
Control request handler from CDC ECM implementation does not
care at all about returning errors when a request is not supported.
Return EINVAL/ENOTSUP if request is incorrect/unsupported.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
e9f9138997 usb: loopback: use class internal buffer to store request data
Use internal buffer to store request data and not
the data OUT stage buffer.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
5698e17aa0 usb: cdc_acm: enhance verification of the class control requests
Rework CDC ACM class control request handling and
check the control transfer direction.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
781c367730 usb: set data stage length variable to zero by default
Set data stage length variable to zero as a precaution
so that no trouble happens if control request handler
does not check the request values sufficiently.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:05:44 -04:00
Johann Fischer
ae074e81d4 usb: remove Kconfig option CONFIG_USB
The USB configuration option is actually a global switch
to enable USB drivers in general, but currently only
the device controller drivers are meant.

USB device controller drivers also have USB_DEVICE_DRIVER option.
Thus the option USB is actually redundant and can be replaced
by the self-explanatory option USB_DEVICE_DRIVER.
The name USB itself is not unique and should not be used as an
configuration option.

With these changes the option USB_DEVICE_DRIVER generally
enables USB device controller drivers. The option USB_DEVICE_STACK
enables USB device support. It is sufficient to enable only option
USB_DEVICE_STACK because it selects USB_DEVICE_DRIVER.

CONFIG_USB Kconfig option is temporary added to subsys/usb/Kconfig.
This is necessary to pass CI and will be removed again
when the USB configuration has been adapted in modules.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 19:00:12 -04:00
Krzysztof Chruscinski
12f366c954 logging: Add resetting of dropped_cnt to init
It is mainly for testing purposes where logging is multiple times
reinitialized.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-08-03 16:11:49 -05:00
Joakim Andersson
72bd8da095 Bluetooth: host: Fix key distribution not calling pairing complete
Fix key distribution not calling pairing complete callback when
distributing encryption information when not bonding.
Encryption information is only distributed in legacy pairing so issue
was only seen during legacy pairing.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2021-08-03 18:47:01 +02:00
Maik Vermeulen
7a2a28b9d5 net: lwm2m: Synchronized functions mutating the RD client's state
A mutex is used to syncrhonize the start, stop and service() functions
of the RD client. Previously it could happen that while service() was
working on e.g. bootstrapping, a stop() call by another thread would
close the socket. Then the bootstrapping process would detect it as a
network error, and restart the process.

Fixes #37170.

Signed-off-by: Maik Vermeulen <maik.vermeulen@innotractor.com>
2021-08-03 10:22:10 -04:00
Lingao Meng
3911ce8d40 Bluetooth: Mesh: Mark as internal function
Marks funcs:`show_faults` as internal, avoiding conflict.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-08-03 10:21:16 -04:00
Michał Narajowski
e167ca6539 Bluetooth: Mesh: Refactor Mesh Model Extensions
The existing extension tree does not support all the features that are
defined by the specification (e.g. multiple parents).

This patch approaches this problem by defining a circular single-linked
list of extension models. So for a given model, all models that are on
the same list as that model are in some extension relationship with that
model. All models on a list represent a single connected component of an
extension graph but without defining specific relationships between each
pair of models. This list is used to manage a shared subscription list
as per the Mesh Profile Specification:

```4.2.4 Subscription List

Within an element, each model has a separate instance of a Subscription
List, unless the model extends another model on that element. Instances
of models that extend other models (i.e., all models within an extension
relation tree) shall share a single instance of a Subscription List per
element.
```

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2021-08-03 10:20:52 -04:00
Piotr Pryga
ca26e7a3f7 Bluetooth: controller: Fix wrong CTE type in per adv report
The Bluetooth Core spec 5.2 requires to provide CTE type in
periodic advertising report.
The implementation of le_per_adv_sync_report assigned
value zero to be default CTE type. The assigned value
in Bluetooth Core spec 5.2 means "AoA Constant Tone
Extension". In case there is no CTE attached to periodic
advertising PDU, CTE type should contain value 0xFF.

This commit fixes the issue.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-03 13:58:51 +02:00
Piotr Pryga
fc7ead4b9f Bluetooth: host: df: Fix compilation warning in direction.c
Fix compilation warning in hci_df_set_cl_cte_rx_enable function.
The struct bt_hci_cp_le_set_cl_cte_sampling_enable *cp variable
was used just to evaluate size in bt_hci_cmd_create call.

The variable is moved to prepare_cte_rx_enable_cmd_params
function and size of the buf is evaluated directly from type.

Code is simpler and prepare_cte_rx_enable_cmd_params does not
require passing additional argument.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-03 13:58:02 +02:00
Johann Fischer
6408d40fd6 usb: use new USB framework header
Replace all macros and types with the new ones from
usb/usb_ch9.h header.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
2021-08-03 13:20:07 +02:00
Abe Kohandel
dcaac1e7af bluetooth: ots: Make OTS Object Reads use POSIX parameter types
It is desirable to have the read and write like functions follow the
POSIX read and write parameter types.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2021-08-03 13:16:51 +02:00
Piotr Pryga
2863bbcdd7 Bluetooth: controller: Add init and reset of LLL per adv in lll_adv.c
There were missing calls to periodic advertising functions:
lll_adv_sync_init() and lll_adv_sync_reset() corresponding
functions in lll_adv.c.

Lack of those calls didn't introduce any harm.
I've added them to have complete init and reset patch,
similar to extended advertising implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-03 13:16:10 +02:00
Piotr Pryga
162691c918 Bluetooth: controller: Add reset of per adv for HCI_Reset command
There is missing handling of periodic advertising reset for
HCI_Reset command. That makes impossible to execute e.g.
qualification tests without rebooting of the DUT
for periodic advertising and direction finding.

This commit adds missing implementation.

Signed-off-by: Piotr Pryga <piotr.pryga@nordicsemi.no>
2021-08-03 13:16:10 +02:00
Abe Kohandel
997bbcb000 bluetooth: ots: Add object write procedure
Add the ability to perform an OTS Write Procedure with only Patch
support configuration.

Signed-off-by: Abe Kohandel <abe.kohandel@gmail.com>
2021-07-31 23:16:11 -04:00
Dominik Ermel
75e9fa8274 subsys/mgmt/mcumgr: Add missing static to function storage_erase
The local function has been missing static specifier.
The commit also removes unused STORAGE_MGMT_ID_ERASE define.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2021-07-30 21:50:45 -04:00
Carlo Caione
abb2321d6d ipc: Fix struct name
s/rpsmg_mi_ctx_cfg/rpmsg_mi_ctx_cfg/

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-07-30 20:06:14 -04:00
Carlo Caione
a9fc1d6c4d ipc: Make the IPM instance index starting from 0
In the current code the naming of the
CONFIG_RPMSG_MULTI_INSTANCE_?_IPM_{TX,RX}_NAME symbol is 1-based. While
this is not currently an issue, it could easily become such if the
symbol is programmatically used as part of a preprocessor enumeration
(for example when using DT_INST_FOREACH_STATUS_OKAY(...) & co).

To avoid trouble, just make the index starting from 0 instead than 1.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-07-30 20:06:14 -04:00
Carlo Caione
20a2aa3faf ipc: Create ipc_service sub-directory for backends
Move the ipc_service backends into an ipc_service sub-directory.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-07-30 20:06:14 -04:00
Carlo Caione
e13213cafb ipc: Cleanup ipc_service and rpmsg_multi_instance code
No functional changes. Only a bit of code cleanup and refactoring.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
2021-07-30 20:06:14 -04:00
Krzysztof Chruscinski
6024bbc601 logging: Split log_core into two files
Extract functions which are managing logging sources
and backends into separate file: log_mgmt.

So far those functions were in log_core mixed with functions
specific to log message creation and log processing.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-30 19:58:13 -04:00
Saleh Mehdikhani
36f934113f Bluetooth: Host: direction: Fixing the bug to support 1us slot
There was an issue with receiving CTE packets when the time
slot has changed from 2us to 1us. After receiving the packets
when it tries to enable receiving of CTE, the validator
returns EINVAL error.

Source of the problem is "validate_cte_rx_params" function,
it calls DF_AOA_RX_1US_SUPPORT(df_ant_info.switch_sample_rates)
which is expanded to:
((df_ant_info.switch_sample_rates) & BIT((BT_HCI_LE_1US_AOA_RX)))

And due to definition of BT_HCI_LE_1US_AOA_RX in hci.h it will be:
((df_ant_info.switch_sample_rates) & BIT(BIT(2)))

So the BIT operation has executed two times.

Signed-off-by: Saleh Mehdikhani <saleh.mehdikhani@unikie.com>
2021-07-30 19:54:42 -04:00
Gerard Marull-Paretas
6c3beb928e pm: adjust busy check API call return types and naming
Busy check APIs now return boolean type. Due to that change, the
function names have also been adjusted. The common name pattern for
boolean check type APIs is "PREFIX_is_CONDITION". For example,
"pm_device_is_busy".  pm_device_busy_check has been renamed to
pm_device_is_busy and pm_device_any_busy_check to pm_device_is_any_busy.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Gerard Marull-Paretas
77728e16df pm: device: improve usage of the atomic flags field
- Use an enum for the available flags
- Use ATOMIC_DEFINE macro to declare the flag bit field
- Improve naming

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Gerard Marull-Paretas
70322853a8 pm: device: move device busy APIs to pm subsystem
The following device busy APIs:

- device_busy_set()
- device_busy_clear()
- device_busy_check()
- device_any_busy_check()

were used for device PM, so they have been moved to the pm subsystem.
This means they are now prefixed with `pm_` and are defined in
`pm/device.h`.

If device PM is not enabled dummy functions are now provided that do
nothing or return `-ENOSYS`, meaning that the functionality is not
available.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
2021-07-30 09:28:42 -04:00
Pieter De Gendt
4192c8b83e net: coap: coap_next_token single sys_rand_get call
Improve coap_next_token by using a single sys_rand_get call.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
2021-07-29 11:47:51 -04:00
Evgeniy Paltsev
f54d0b7aa5 ARC: 64BIT: increase LOG_PROCESS_THREAD stack size
Increase LOG_PROCESS_THREAD_STACK_SIZE for ARCv3 64 bit to
fix failing test
tests/subsys/logging/log_core_additional/logging.add.async
due to stack overflow.

Signed-off-by: Eugeniy Paltsev <Eugeniy.Paltsev@synopsys.com>
Signed-off-by: Evgeniy Paltsev <PaltsevEvgeniy@gmail.com>
2021-07-29 11:47:25 -04:00
Eduardo Montoya
cf57b86363 net: openthread: add three configuration options
Enable to configure:
- `OPENTHREAD_CONFIG_CLI_MAX_LINE_LENGTH`
- `OPENTHREAD_CONFIG_IP6_MAX_EXT_UCAST_ADDRS`
- `OPENTHREAD_CONFIG_IP6_MAX_EXT_MCAST_ADDRS`

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2021-07-29 11:00:19 -04:00
Lingao Meng
9042f76b8b Bluetooth: Mesh: Add pointer conversion for prov->uri
`prov_sd[0].data` and `prov->uri` have different point type.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Lingao Meng
baf0d58a67 Bluetooth: Mesh: Fix wrong use log_strdup
Should use `bt_hex` instead of `log_strdup`.

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Lingao Meng
cce921dad5 Bluetooth: Fix Wrong format when debug
Fix wformat build warning

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-29 10:59:20 -04:00
Krzysztof Chruscinski
ffc4a6c928 testsuite: Add busy simulator module
Busy simulator is using counter device and entropy device to
generate random cpu load. Counter device cofiguration can be
used to set cpu load interrupt priority and optional pin that
can be set during the load.

Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
2021-07-29 10:59:00 -04:00
Krzysztof Kopyściński
779e67c0fc Bluetooth: host: disallow MPS decrease for multiple CIDs in Reconf Req
When in le_ecred_reconf_req multiple CIDs are received host should
return  0x0002 error (Reconfiguration failed - reduction in size of
MPS not allowed for more than one channel at a time).

This affects test L2CAP/ECFC/BI-04-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-07-29 15:21:10 +02:00
Krzysztof Kopyściński
4f80fe814c Bluetooth: host: introduce timeout in limited advertising
In limited advertising advertising should end after certain timeout.
Previously, limited advertising was just general advertising with
BT_LE_AD_LIMITED flag set. Now, if this flag is set the work is
scheduled, that will disable advertising after timeout.

This affects tests GAP/DISC/LIMM/BV-03-C and GAP/DISC/LIMM/BV-04-C

Signed-off-by: Krzysztof Kopyściński <krzysztof.kopyscinski@codecoup.pl>
2021-07-29 15:20:54 +02:00
Lingao Meng
55145beee0 Bluetooth: Mesh: Add more explain for ADV_STACK_SIZE
Add explanatory statement for config `BT_MESH_ADV_STACK_SIZE`

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2021-07-28 15:44:34 +02:00