Commit graph

21541 commits

Author SHA1 Message Date
Hubert Miś
ade40136ea net: resolve literal IP addresses even when DNS is disabled
With this patch the resolver module can resolve literal IPv6
and IPv4 addresses even when DNS client is not presnet in
the system.

Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
2020-12-22 15:44:00 +02:00
Michael Rosen
1c89837e79 usb: dfu: add separate pid for dfu mode
Refactor the file structure for USB DFU class to facilitate
separate PID for USB DFU when in DFU mode. As required by USB DFU
1.1 Section 2, the PID in the USB device descriptor must be
different between the Run-time and DFU mode device descriptor to
avoid problems caused by the host OS caching the remaining
descriptors when switching to DFU mode, thus hiding the new
interface descriptors from applications on the host and reporting
the Run-time descriptors when the device is in DFU mode.

To avoid adding too much clutter to the root USB class Kconfig and
CMakeLists files, move the DFU class files into their own directory
with dedicated Kconfig and CMakeLists.txt.

Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
2020-12-20 13:04:45 -05:00
Michael Rosen
d92ee92c95 usb: dfu: change device descriptors after reset
The USB device descriptors for DFU mode should only change after a
USB reset, not in appDETACH as the device is still in run-time mode
until reset; thus should still return the run-time descriptors when
requested.

Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
2020-12-20 13:04:45 -05:00
Michael Rosen
c58d201086 usb: dfu: add timer for appDETACH
In accordance with USB DFU 1.1 Section 5.1, a device should only
stay in appDETACH for a given period of time, either from the
DFU_DETACH request (wValue ms) or from the wDetachTimeout property,
after which the device should return to appIDLE.

Signed-off-by: Michael Rosen <michael.r.rosen@intel.com>
2020-12-20 13:04:45 -05:00
Andrzej Kaczmarek
f8c8cac714 Bluetooth: controller: Use PHY_xxx symbols consistently
We have convenient PHY_1M, PHY_2M and PHY_CODED symbols defined but
they are not used too much in the code. This replaces all usages of
magic numbers and other symbols as PHY constants with those symbols.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-20 13:04:13 -05:00
Emil Gydesen
9a3f863637 Bluetooth: host: Assert conn ref counter on unref
Adds an assert on the "old" ref counter when doing unref, that
checks if there indeed is a reference to unref. This prevents
any underflows of the ref counter.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-20 13:02:44 -05:00
Martin Jäger
6fd8cbb9b4 storage: stream: flash: update log output
LOG_DBG is more appropriate for this logging output than LOG_INF.

Signed-off-by: Martin Jäger <martin@libre.solar>
2020-12-20 12:40:19 -05:00
Emil Gydesen
47aa17bb5c Bluetooth: controller: Implements ULL Sync ISO ticker
Implements the ull_sync_iso_setup function which starts the
ticker for ISO sync. Furthermore, ll_big_sync_terminate
will not stop the ticker as well.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-20 13:36:50 +01:00
Emil Gydesen
9d4d6d06a0 Bluetooth: controller: Implements BIG sync commands in the ULL
Implements handling of the BIG sync commands in the ULL.
LLL support and handling of ACAD (biginfo) remaining.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2020-12-20 13:36:50 +01:00
Vinayak Kariappa Chettimada
e603b9d59e Bluetooth: controller: Adjust PPI used for nRF51x and nRF52x
Adjust the PPI used by nRF51x and nRF52x so that PPI 0-5 is
available for application's use or for SW PWM driver use.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-20 13:36:09 +01:00
Morten Priess
467fd155a8 Bluetooth: controller: Make must-expire runtime configurable
Under CONFIG_BT_TICKER_EXT configuration, the ticker interface has been
extended to support enabling/disabling must-expire scheduling. This
means that conn and slave ticker start calls can now omit must-expire
default-on configuration, relying on LLL updating the mode as needed.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2020-12-20 13:35:58 +01:00
Dominik Ermel
d83875f32a power: Idle depends on system clock when power management enabled
The idle, when power management is enabled, requires system clock to
be present.
This commit adds dependency, to PM option, on SYS_CLOCK_EXISTS.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2020-12-19 21:05:45 -05:00
Kumar Gala
82767ef3bb bluetooth: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 20:01:42 -05:00
Kumar Gala
4dd7aa6392 usb: Convert DEVICE_AND_API_INIT to DEVICE_DEFINE
Convert drivers to DEVICE_DEFINE instead of DEVICE_AND_API_INIT
so we can deprecate DEVICE_AND_API_INIT in the future.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-19 16:58:00 -05:00
Rafał Kuźnia
3bf526beea net: openthread: add shell dependency to OPENTHREAD_SHELL
This commit replaces the 'select SHELL' statement with
'depends on SHELL' in OPENTHREAD_SHELL config option.

This ensures, that shell will not be implicitly enabled
when OpenThread stack is built.

Signed-off-by: Rafał Kuźnia <rafal.kuznia@nordicsemi.no>
2020-12-18 12:56:33 -05:00
Kumar Gala
d47721d5cd usb: audio: Convert drivers to new DT device macros
Convert usb audio drivers from:

    DEVICE_AND_API_INIT -> DEVICE_DT_DEFINE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-18 07:50:49 -06:00
Joakim Andersson
cc470a2bd6 Bluetooth: host: Use smaller alignment for slab.
The slabs in ATT are using a slab alignment of 16, when only
4 is required on 32-bit.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-18 10:29:59 +01:00
Robert Lubos
ae35d3000f net: openthread: Fix missed logging macro usage
During recent upmerge OPENTHREAD_CONFIG_PLAT_LOG_FUNCTION__COUNT_ARGS
macro was renamed to OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME__COUNT_ARGS
but the code wasn't updated where the macro is actually used.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-12-17 20:58:00 +02:00
Joakim Andersson
adeca565f8 Bluetooth: host: Use uintptr when checking for valid index
Align bt_le_per_adv_sync_get_index, bt_conn_index and
bt_le_ext_adv_get_index in use of uintptr_t.

This fixes an issue where the cast to uint8_t happened before the
assert for a valid index, which could lead to invalid pointers passing
this assert.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 17:16:34 +02:00
Joakim Andersson
9fee4d7ffd Bluetooth: SMP: Improve logging of unspecified pairing failure
Improve logging of pairing procedure when it fails with error code
unspecified. Since this is returned in many places debugging this
failure is not easy without adding additional debugging.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Joakim Andersson
a01a619480 Bluetooth: SMP: Check return value of bt_rand
Add check of bt_rand return value and do not proceed in case of error.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Joakim Andersson
d138790826 Bluetooth: SMP: Fix parallel pairing needing DHKey at the same time
Fix parallel pairing procedures using LE SC requiring the DHKey
calculation at the same time. This would otherwise end all other
pairing procedures with the SMP error code "unspecified" since
the call to bt_gen_dh_key would fail.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Joakim Andersson
ad96ae0398 Bluetooth: SMP: Set allowed commands before sending the SMP packet
Set the allowed command bitmask before sending the SMP packet. This
avoids a race-condition in case the sending of the PDU made the
current thread not ready and would not be scheduled back in time
to set the bit before receiving the next SMP packet.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Joakim Andersson
d04e19731e Bluetooth: host: Improve multiple DHKey handling
Improve multiple DHKey handling by allowing the next DHKey calculation
to be started in the dhkey ready callback.
Return error code EALREADY if the provided callback is the current
callback generating the DHKey.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-17 12:42:22 +01:00
Andrzej Kaczmarek
07bb612875 Bluetooth: controller: Call lll_adv_aux initialization funcs
lll_adv_aux_init and lll_adv_aux_reset were not called anywhere.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
07ebf3d06d Bluetooth: controller: Release resources on failed AUX_CONNECT_RSP
We allocate nodes on receiving AUX_CONNECT_REQ, but we can only use
them if AUX_CONNECT_RSP is sent successfully. If that fails, we need
to release those nodes.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
3fc74be7e7 Bluetooth: controller: Allow to simply release node allocated in LLL
If we allocate a node in LLL and it turns out that we don't need it
(e.g. allocated connection on AUX_CONNECT_REQ, but connection handshake
did not complete and we don't need it) we still need to send it to ULL
to be released. We can use existing NODE_RX_TYPE_DC_PDU_RELEASE node
type for this purpose, but we just need to make sure it's passed from
LLL to ULL properly.

Also, since this now does not only release DC PDUs, let's change its
name to a more generic one.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
98d7adc30d Bluetooth: controller: Stop aux after connected
After slave connection is created only adv instance is stopped, we also
need to stop aux separately if enabled.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
88a8fc1d5e Bluetooth: controller: Make global helper to get aux handle
Just make local function a global one, we need this in other files
as well.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
01448bf378 Bluetooth: controller: Fix phy initialization when enabling adv
Make sure phy is properly initialized to 1M when ext adv is supported
and legacy advertising instance is being enabled.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
dd102e61c0 Bluetooth: controller: Add support for connectable ext adv
This adds handling for received AUX_CONNECT_REQ PDU which enables slave
connection with extended advertising.

Once AUX_CONNECT_REQ is received, standard checks are performed to
determine if we have resource to create connection, however unlike for
CONNECT_IND an rx node is temporarily kept in LLL until AUX_CONNECT_RSP
is successfully sent. This is to prevent creating a connection in case
response PDU was not sent for whatever reason.

A separate scratch buffer is created for AUX_CONNECT_RSP since default
radio scratch buffer is already used by received AUX_CONNECT_REQ.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
2709c2c79a Bluetooth: controller: Initialize conn for connectable ext adv
Connection structs need to be initialized when advertising is enabled
on connectable extended advertising instance.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
f5d3a637a4 Bluetooth: controller: Use proper phy when initializing slave conn
Connection created from extended advertising instance uses the same phy
as on secondary channels.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
384b64508c Bluetooth: controller: Use proper channel sel algorithm
Connections created from extended advertising instance always use CSA2.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
6c8c97a26e Bluetooth: controller: Use proper transmitWindowDelay for slave
transmitWindowDelay is either 2.5ms or 3.75ms when AUX_CONNECT_REQ is
used (for 1M/2M and Coded respectively). It also uses the same unit
as transmitWindowOffset (1.25ms) so we can just simply add both.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
68723274da Bluetooth: controller: Use decoded AdvA/TargetA for conn ind helper
The same helper will be used for legacy and extended advertising so we
better pass AdvA and TargetA directly instead of complete advertising
PDU. This is because those fields are at different locations in legacy
and extended advertising PDUs so caller can figure them out.

Also, we can now check for directed advertising using TargetA since it
will be only supplied for such advertising (NULL otherwise).

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Andrzej Kaczmarek
ffb320504c Bluetooth: controller: Add public helper to process connection ind
We will use the same code for auxes so let's make it public.

Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@codecoup.pl>
2020-12-17 11:36:25 +01:00
Vinayak Kariappa Chettimada
a46d090328 Bluetooth: controller: Release blocking LF clock request
Release the LF clock requested in blocking mode used to wait
to settle, which has already been asynchronously requested.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:24:19 +01:00
Vinayak Kariappa Chettimada
da18345b08 Bluetooth: controller: nRF5x: Fix lll LF clock wait
Fix lll_clock_wait function to wait for LF clock to settle
only once after power up.

Regression introduced in commit 2b4763076e ("bluetooth:
controller: Adapt to onoff clock control").

Fixes #30480.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:24:19 +01:00
Vinayak Kariappa Chettimada
35c397fc46 Bluetooth: controller: Remove unused lll scan struct member
Remove the unused LLL scan context struct member,
conn_ticks_slot.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:23:36 +01:00
Vinayak Kariappa Chettimada
6f22ac2851 Bluetooth: controller: Cleanup included header files
Clean up included header files, remove including
zephyr/types.h and other deprecated or redundant
header files.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:23:18 +01:00
Vinayak Kariappa Chettimada
17c006ce4a Bluetooth: controller: Add extended scan filter duplicates
Added implementation to filter out duplicates in generated
extended advertising reports.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2020-12-17 11:23:03 +01:00
Alexander Wachter
05275ecf6e drivers: can: rework zcan_frame and zcan_filter
Reordering of the struct elements to match the Linux format.
The __packed() is not necessary anymore.
std_id and ext_id is merged to id in the frame and filter.
Additionally, the frames are ready for CAN-FD.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-12-17 11:07:53 +01:00
Alexander Wachter
8b6c1bd4b7 drivers: can: Rework can_configure API
The previous API can't change the sampling-point and only allowed
bitrates that fit the time segments.
The new API allows for shifting the sampling-point and adjusts the
number of time quantum in a bit to all more possible bitrates.
The functions to calculate the timings are moved to the can_common file.
They can be used for all drivers.

Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
2020-12-17 11:07:53 +01:00
Eduardo Montoya
f0379e7ccb net: openthread: enable new CSL and TREL config options
Enable new OpenThread configuration options:
- OPENTHREAD_CONFIG_RADIO_LINK_IEEE_802_15_4_ENABLE
- OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE
- OPENTHREAD_CONFIG_CSL_SAMPLE_WINDOW
- OPENTHREAD_CONFIG_CSL_RECEIVE_TIME_AHEAD

Update OPENTHREAD_CONFIG_PLAT_LOG_MACRO_NAME

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2020-12-16 18:06:47 +01:00
Lingao Meng
5b11c053ef Bluetooth: Mesh: Fixes Friend Queue store message
If the SRC field of the received message is a unicast
address of an element of the Low Power node, then the
message shall not be stored in the Friend Queue.

Otherwise, lpn will discard this message, eventually
it breaks friendship.

Fixes: #30657

Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2020-12-16 14:27:12 +01:00
Kumar Gala
07d1e4a45b disk: sdhc: Convert drivers to new DT device macros
Convert sdhc drivers from:

	DEVICE_AND_API_INIT -> DEVICE_DT_INST_DEFINE
	DEVICE_DECLARE -> DEVICE_DT_INST_DECLARE

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-12-15 15:17:59 -06:00
Seppo Takalo
f684b7c6cd net: getaddrinfo: Fix getaddrinfo() to respect socket type hints
If getaddrinfo() was called with AI_PASSIVE flag in hints,
returned address defaulted to SOCK_STREAM and IPPROTO_TCP.
Fixed so that SOCK_DGRAM leads to correct address type
that can be fed to bind() directly.

Same hard coding was visible when numerical IPv4 address string
was converted to binary. That is also fixed to respect hints now.

Also, added functionality to get IPv6 address, when hints contained
AF_INET6.

Fixes #30686

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2020-12-15 19:22:50 +02:00
Joakim Andersson
39e14580e9 Bluetooth: controller: Validate disconnect reason in disconnect command
Validate the disconnect reason in the disconnect command, according
to the the core specification.

7.1.6 Disconnect command:
Authentication Failure error code (0x05), Other End Terminated Connec-
tion error codes (0x13 to 0x15), Unsupported Remote Feature error code
(0x1A), Pairing with Unit Key Not Supported error code (0x29) and Unac-
ceptable Connection Parameters error code (0x3B).

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-15 11:20:34 +01:00
Joakim Andersson
9205fe0a3a Bluetooth: host: Return error code if disconnect has invalid parameters
Return the error code from the disconnect command to the application
when an invalid disconnect reason has been provided.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-12-15 11:20:34 +01:00