Commit graph

21541 commits

Author SHA1 Message Date
Meng xianglin
79df2b032d power: allow external definition of core devices
When try to enable CONFIG_DEVICE_POWER_MANAGEMENT for a board,
the #error directive in subsys/power/device.c requires that
"MAX_PM_DEVICE" and "core_devices[]" must be defined exactly in that
file, or a compile error will come up.
For flexibility, this patch move "PM_MAX_DEVICE" to Kconfig and define
a weak version of "z_mp_core_devices[]", so any board or SOC can define
these varibles in their own module.

Signed-off-by: Meng xianglin <xianglinx.meng@intel.com>
2020-09-09 21:21:45 -04:00
Robert Lubos
7242a80036 net: sockets: tls: Fix invalid variable initialization
The timeout variable in `dtls_rx()` was initialized improperly.

Coverity ID: 214219

Fixes #28161

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-09-09 14:10:29 +03:00
Robert Lubos
bff0f954a9 net: lwm2m: Make sure Sensor Type string isn't too long
The default string representing Sensor Type resource in Generic IPSO
object would not fit into the predefined buffer. Increase the buffer
size and add extra BUILD_ASSERT to detect this situation.

Coverity ID: 214225

Fixes #28164

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-09-09 14:10:29 +03:00
Lukasz Maciejonczyk
80b02ec884 net: config: Fix missing error log when timeout happens
The timeout log error message condition in wrong. When the timout
happens the "count == -1" and the condition is invalid.

This commit fixes it.

Signed-off-by: Lukasz Maciejonczyk <lukasz.maciejonczyk@nordicsemi.no>
2020-09-09 13:06:05 +02:00
David Leach
a775d73528 random: rand32_ctr_drbg: Fix missed device constify change
Device constify PR missed changes needed within the mbedtls
conditional code.

Fixes #28033

Signed-off-by: David Leach <david.leach@nxp.com>
2020-09-08 14:03:01 +02:00
Emil Obalski
7f43fec094 usb: Fix for is_ep_valid
is_ep_valid() function was incorrectly searching through
all used endpoints. All endpoints for class must be checked
if they match requested endpoint.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-07 16:44:54 +02:00
Vinayak Kariappa Chettimada
61b6534727 Bluetooth: controller: Scanning with unreserved window
Added a Kconfig option to enable scanner with unreserved
scan window when in continuous scan mode. This will permit
scanner to be always pre-empted by other roles, making it
the lowest in priority when it comes to using the radio.

Fixes #27414.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-07 15:11:33 +02:00
Anas Nashif
6f729383a8 tests: timestamp: minor cleanup
Minor cleanup and fixes.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-05 13:28:38 -05:00
Daniel Leung
0ffcfa9633 timing: introduce timing functions as a generic feature
Add timing functions and APIs.  This is now used with some of the tests
we have for performance and metrics and will be used whereever timing
informations are needed, for example for tracing, profiling and other
operations where timing info is critical.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2020-09-05 13:28:38 -05:00
Francois Ramu
9a94168e78 disk: sdhc: use the multiple block transfer for writing
The sdhc_spi_write_multi function is sending the CMD25
for multiple block write operation on the SD card
instead of looping the CMD24. This is improving
the transfer speed compared to the sdhc_spi_write function
when the nb of blocks to write is significant (more than 2).

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2020-09-05 11:07:04 +02:00
Luiz Augusto von Dentz
95cec8354c Bluetooth: GATT: Introduce bt_gatt_attr_get_handle
This introduces bt_gatt_attr_get_handle which can be used to resolve
handles of static attributes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-05 11:06:21 +02:00
Luiz Augusto von Dentz
5c4bde55d0 Bluetooth: GATT: Rework bt_gatt_attr_func_t
Make it actually give the original pointer to the attribute and its
resolved handle so static attributes don't need an extra lookup.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-05 11:06:21 +02:00
Luiz Augusto von Dentz
dde25a3d44 Bluetooth: GATT: Optimize static service handle resolution
This optimizes the lookups to skip ahead when attribute pointer is not
located within service array.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-05 11:06:21 +02:00
Luiz Augusto von Dentz
b8e9b6f88a Bluetooth: shell: Add iso module
This adds iso shell module which we can be used to exercise ISO related
APIs:

iso - Bluetooth ISO shell commands
Subcommands:
  bind        :[dir] [interval] [packing] [framing] [latency] [sdu]
  [phy] [rtn]
  connect     :Connect ISO Channel
  listen      :[security level]
  send        :Send to ISO Channel
  disconnect  :Disconnect ISO Channel

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-04 21:03:13 +02:00
Luiz Augusto von Dentz
d85d40c58e Bluetooth: hci_raw: Add support for ISO packets
This adds supports for ISO packets so then can be transmitted and
received with hci_raw driver.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-04 21:03:13 +02:00
Luiz Augusto von Dentz
c29e6ffa73 Bluetooth: monitor: Add support for ISO packets
This adds types for TX/RX ISO packets so the likes of btmon can decode
them properly.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-04 21:03:13 +02:00
Luiz Augusto von Dentz
81d34ecd19 Bluetooth: Audio: Initial ISO channel support
This adds initial code for handling ISO channels.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2020-09-04 21:03:13 +02:00
Jett Rink
1972f0b7f4 ec_host_cmd: add ec host command handler framework
Add a generic host command handler framework that allows users to
declare new host command handlers with the HOST_COMMAND_HANDLER macro
at build time. The framework will handle incoming messages from the
host command peripheral device and forwards the incoming data to the
appropriate host command handler, which is looked up by id.

The framework will also send the response from the handler back to the
host command peripheral device. The device handles sending the data on
the physical bus.

This type of host command communication is typically done on an embedded
controller for a notebook or computer. The host would be the main
application processor (aka AP, CPU, SoC).

Signed-off-by: Jett Rink <jettrink@google.com>
2020-09-04 14:50:45 -04:00
Guillaume Lager
f5cb887a79 bluetooth: Allow immediate logging with software-based LL
Some logging configuration are compatible with software-base Link
Layer. Currently only one configuration is supported:
RTT back-end in drop mode and no clean output

Signed-off-by: Guillaume Lager <guillaume.lager@gmail.com>
2020-09-04 18:48:32 +02:00
Kamil Piszczek
be7e2fc5ab bluetooth: services: ots: use multi-instance macro from gatt.h
Used multi-instance macro defined in gatt.h for OTS instance
definitions.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2020-09-04 18:37:27 +02:00
Joakim Andersson
48606a2dcd Bluetooth: shell: Add "add-subscription" command
Add the command add-subscription to the shell to test the
bt_gatt_add_subscription API.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-04 18:34:18 +02:00
Joakim Andersson
76119c526e Bluetooth: GATT: Allow application to add subscription.
Allow the application to add subscription without resubscribing.
This is needed for persistent bonds that can go to deep sleep and
turn of the RAM or power-cycle.
In this case the application as a GATT client must have a way to add
the subscription callbacks back to the stack before the GATT server
sends notifications.
This should preferable be able to be done before even connecting
since the notifications can arrive immediately after connecting to
the peer.
The stack cannot persist this on it's own since it must remember the
function pointers for the callback functions. Storing these in
persistent storage would not be compatible with a Device Firmware
Upgrade (DFU) solution.

Fixes: #21798

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-04 18:34:18 +02:00
Joakim Andersson
ae5489085f Bluetooth: GATT: Refactor gatt_sub_add to add withouth conn object
Refactor the gatt_sub_add function to be similar in structure to how
find_cf_cfg is implemented. This is so that a subscription can be added
without an active connection.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-04 18:34:18 +02:00
Emil Obalski
31587ca6ef usb: Do not check usb_dev.configured in is_dev_configured()
Flag name usb_dev.configured is misleading as it does not
mean the device is configured. This flag indicates whenever
endpoints for the device were enabled. For all classes
except for audio endpoints are enabled on set_configuration
request. This sets the configured flag true. For Audio this
will never happen as what enables audio endpoints is
set_interface request. Without this patch audio samples
will STALL all interface requests.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-04 17:51:45 +02:00
Gerson Fernando Budke
d18f12de23 mgmt: updatehub: Enable flash sha verification
Currently updatehub trust on MCUboot to test a new image. The process
is executed on next boot after a validate the downloaded image.  To
have a more reliable system, is recommended run the SHA-256 algorithm
to attest that firmware was properly stored on the flash memory.  This
implements the use of flash_img_check to achieve that, and as a
consequence, add a new level of trust that avoids an useless reboot
on the system.

Updatehub uses two SHA-256 verification.  One is used to check the
data stream at download.  The second one, realise the verification
reading from flash.  Users have the possibility to chose only one
option or keep both verifications.  However, it is adviced keep
always both verifications enabled to get consistent reports on
back end.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-09-04 17:32:29 +02:00
Gerson Fernando Budke
d0c3dfe093 mgmt: updatehub: Add hash var on context
Currently SHA-256 uses a temporary hash digest to calc final sha sum.
This moves temporary variable from local scope to updatehub context.
The motivation is to use the hash digest on future flash validation.

Signed-off-by: Gerson Fernando Budke <gerson.budke@ossystems.com.br>
2020-09-04 17:32:29 +02:00
Vinayak Kariappa Chettimada
94d7469172 Bluetooth: controller: Add DEBUG_PINS support in nRF5340DK
Add support for BT_CTLR_DEBUG_PINS for nRF5340DK board.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-04 17:17:07 +02:00
Vinayak Kariappa Chettimada
03852a5f02 Bluetooth: controller: Fix DEBUG_PINS_CPUAPP dependency
Remove the BT_LL_SW_SPLIT dependency for
BT_CTLR_DEBUG_PINS_CPUAPP when building CPUAPP application
that is using Zephyr BLE HCI controller on the CPUNET core.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-04 17:17:07 +02:00
Kamil Piszczek
0a7a8fd137 bluetooth: services: add Object Transfer service
Added GATT Object Transfer Service implementation.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2020-09-04 17:06:17 +02:00
Jukka Rissanen
3e5a4d79b2 net: tcp2: Make sure all incoming data is given to app at eof
When the connection is terminated, make sure that any pending
data is feed to the application.

Fixes #28057

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-09-04 11:04:27 -04:00
Dominik Ermel
1d0fb46165 mgmt: smp: Fix compilation problem
Fix problem with compilation due to incompatible type assignments.

Fixes #28031

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-09-04 16:35:37 +02:00
Emil Gydesen
9c5db74a6e Bluetooth: Remove _gatt_ infix for Device Information Service (DIS)
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-09-04 15:38:44 +02:00
Emil Gydesen
8d7b5ebd7a Bluetooth: Remove _gatt_ infix for Heart Rate Service (HRS)
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-09-04 15:38:44 +02:00
Emil Gydesen
b4a8229db6 Bluetooth: Remove _gatt_ infix for Battery Service (BAS)
The _gatt_ infix was determined to be unnecessary as
GATT is implied by it being a Bluetooth service.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-09-04 15:38:44 +02:00
Joakim Andersson
7ab35145fb Bluetooth: host: Add hardware error event handling
Add handling of the HCI_Hardware_Error event to log the hardware code.
This event was unmasked in set_event_mask.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-09-04 14:46:54 +02:00
Jordan Yates
4f54b4176d bluetooth: controller: add name to TX power choice
Add a name to the Kconfig choice that selects the controller TX power.
This allows board `*.defconfig` files to change the default TX power
as their certifications warrant. For example:

```
choice BT_CTLR_TX_PWR
	default BT_CTLR_TX_PWR_PLUS_4
endchoice
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-09-04 14:46:05 +02:00
Jordan Yates
1723e479ab Bluetooth: controller: preserve TX power
Preserve the TX power set with the `BT_HCI_OP_VS_WRITE_TX_POWER_LEVEL`
command for advertising and scanning procedures. As the TX power is no
longer overwritten on procedure start, the TX powers can now be set
before starting the procedure. This eliminates the chance for the first
transmissions to use the default TX power instead of the request TX
power.

Similar changes are not made to the connection advertising powers as
changing the TX power for a connection to device A should not change
the TX power for a future connection to device B using the same
`struct lll_adv` instance.

Fixes #27921.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2020-09-04 14:37:57 +02:00
Andrzej Kaczmarek
d8864d44f4 Bluetooth: controller: Add ADI support in AUX_SCAN_RSP
ADI field is optional in AUX_SCAN_RSP so by default it's disabled, but
now we'll have an option to include it.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
1b1ab16a64 Bluetooth: controller: Return current ADI when updating aux
When aux is upated, DID is changed and unlike SID it's only stored in
aux PDU. To allow quick access to new DID value, let's just optionally
return current ADI value after aux was updated. It will be useful e.g.
when updating scan response data if we want to put ADI there.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
09115429a1 Bluetooth: controller: Add non-connectable scannable
This enables processing of AUX_SCAN_REQ and sending back AUX_SCAN_RSP
on non-connectabe scannable advertising instances. Similar path will
be used for AUX_CONNECT_REQ so there are few references for connectable
as well, but this is not supported as for now.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
b47df3cc21 Bluetooth: controller: Add scan response data setting restrictions
This adds restrictions for setting scan response data as specified by
Core spec:
* on legacy, only complete data can be set
* on legacy, data cannot be longer than 31 octets
* on ext, if non-scannable, data can only be discarded
* if ext enabled, only complete data can be set
* if ext enabled, data cannot be discarded

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
60b8df94e1 Bluetooth: controller: Add support to set scan response data on ext
This allows to set scan response data using ext adv commands.

New AUX_SCAN_RSP can be created without analyzing previous PDU since
the only value that need to be copied from previous PDU is AdvA which
is placed at fixed location. TxPower is omitted since, if enabled, it
is already present in AUX_ADV_IND and does not need to be presed in
other PDUs. ADI support is to be added later.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
e49ef46677 Bluetooth: controller: Add AdvA to connectable and scannable aux
AdvA in aux is mandatory for any connectable and scannable set so make
sure it's always added.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
c34bd1c2c4 Bluetooth: controller: Add aux for connectable and scannable
Connectable and scannable instances always have aux so we need to force
AuxPtr to be included in primary PDU and have aux allocated even if no
data are set.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
bef663d5c0 Bluetooth: controller: Require aux for connectable or scannable
Connectable and scannable instances always have AuxPtr so we can return
error immediately if controller is configured with no aux.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Andrzej Kaczmarek
0274a6b26b Bluetooth: controller: Disallow setting AD on scannable instance
Scannable instance can only have scan response data set.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-09-04 14:30:21 +02:00
Morten Priess
8682e47eb0 Bluetooth: controller: Prevent incorrect lazy_current increment
Prevent redundant collision resolves and potential incorrect and harmful
increment of lazy_current.

During collision scenarios with high CPU load, the ticker_worker may be
called a second time before the ticker_job gets to run. This will cause
ticker operations on the previosly expired node (expected), and in some
cases increment lazy_current, even though the node was not sceduled to
execute via the req/ack mechanism.

By moving the request check before collision resolve, CPU time is saved,
and lazy_current will not incorrectly be incremented if node is in
collision.

The problem may be seen as a connection suddenly not receiving packets,
or MIC error on master, because the event counter goes out of sync.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-09-04 14:14:23 +02:00
Rubin Gerritsen
69867a48db bluetooth: controller: BT_CTLR_CONN_RSSI as a shared controller opt
Use a helper config BT_CTLR_CONN_RSSI_SUPPORT so that it is only
enabled when supported by the controller.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
2020-09-04 14:03:20 +02:00
Emil Obalski
0d8bd579a5 usb: hid: All hid_ops callbacks get device pointer.
This commit extends USB hid API callbacks by adding
'const struct device *dev' parameter. If the application
configured more than one HID device then it must specify
separate hid_ops for each device as its unable to determine
for which device the callback was called.

This patch makes it possible to have only one hid_ops within
the application and the application is aware for which device
the callback was called because of explicit device pointer.

Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
2020-09-04 12:27:44 +02:00
Vinayak Kariappa Chettimada
42d59c95f2 Bluetooth: controller: Fix periodic advertising cond. compile
Fix missing conditional compilation around the periodic
advertising feature implementation.

Fixes #28017.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-09-04 11:59:23 +02:00