Commit Graph

74361 Commits

Author SHA1 Message Date
Emil Gydesen 0f394c5958 Bluetooth: Audio: Shell: Add missing metadata type
In handle_metadata_update the metadata type was never copied,
causing it to always be 0.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:25 +01:00
Emil Gydesen 5357bd5d0f Bluetooth: Shell: add pa_ad_init for cmd_per_adv_data
Similar to the ad_init that automatically adds advertising data
from other modules, pa_ad_init has been added to do the same
for periodic advertising.

The only use case so far is the BAP broadcast source
data, if enabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen d115bafd40 Bluetooth: Audio: Shell: Split audio_ad_data_add into two
The call to audio_ad_data_add will now either call
connectable_ad_data_add for connectable advertising, or
unconnectable_ad_data_add for unconnectbale advertising.

Most service UUIDs etc. does not make sense to advertise if
not connectable.

This also adds the BAP broadcast advertising data to
unconnectable.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Emil Gydesen f0b104346a Bluetooth: Audio: Shell: Fix off-by-one issue with the HAS uuid
If the advertising is connectable, and we have privacy,
then according to the HAP spec, we should not advertise
the HAS uuid.

This was done by simply truncating the advertising data, but
it was only truncated by 1, instead of by the size of the
UUID.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 14:34:15 +01:00
Alberto Escolar Piedras 1e7d2c83aa tests: bsim_bt compile: Provide more info during errors
As we are now compiling in parallel all apps, build errors
are not anymore next to the compile line, so let's tell
developers for app we are printing the build output
to ease debugging.

Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
2023-01-24 14:20:33 +01:00
Kumar Gala 8f04408725 tests: Add newlib filter for some testcases that dont have it
Not all toolchains support newlib so tests that require newlib need
to have a filter to we don't try and build those tests on those
testcases.  Some newer tests are missing:

	filter: TOOLCHAIN_HAS_NEWLIB == 1

so add that to testcases that needed.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
2023-01-24 11:10:27 +00:00
Morten Priess 60b1f2b36b Bluetooth: controller: Reduce ISO peripheral CIS establishement delay
New LLCP will process the CIS establishement in the TX path, meaning it
will only process once every ACL connection interval.
If ACL connection interval is significantly longer than the ISO
interval, CIS packets corresponding to the ACL connection interval will
be lost. This may cause latency in audio rendition.

By processing the CIS establishment in the RX path, notification will be
sent immediately, and audio path is enabled fast to reduce latency.

When a CIS fails to establish, the controller shall complete the
procedure by sending a CIS_ESTABLISHED event containing the error.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess 90d0d93a9c Bluetooth: controller: Fix missing CIS disconnect on MIC failure
Disconnect CIS immediately if event done extra status indicates MIC
failure. Return reason BT_HCI_ERR_TERM_DUE_TO_MIC_FAIL.

Fixes EBQ test /LL/CIS/PER/BV-27-C.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess 78c3bf569b Bluetooth: controller: Implement CIS offset equivalent calculation
When the 'instant' of a CIS is postponed by increasing the conn_event of
the CIS_RSP compared to CIS_REQ, the CIS offset shall be calculated as
an equivalent window offset by an integer number of ISO intervals.
This is obtained by increasing the CIS_Offset_Min and CIS_Offset_Max by
the modulus of the connection interval delay time.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Morten Priess a982c9f9f6 Bluetooth: controller: Start CIG immediately if instant is next event
To be able to timely start the first CIS/CIG, if the requested instant
is the next connection event, call ull_peripheral_iso_start directly
from rp_cc_state_wait_rx_cis_ind instead of waiting for next time
through the state machine.

To enable ULL/LLL to prevent adding latency when LLCP is waiting for
instant, local- and remote procedures with instant now expose a function
for checking this state.

Fixed event_counter function to prevent one-off in RX path. Unified to
use single function ull_conn_event_counter.

Fixed LLCP unit tests and added new mock function.

Signed-off-by: Morten Priess <mtpr@oticon.com>
2023-01-24 11:09:51 +00:00
Emil Gydesen 1af16d896c samples: Bluetooth: Broadcast audio source add packing field
Set the packing field when creating the broadcast source. This
is currently missing, and in uninitialized.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 09:44:09 +01:00
Emil Gydesen 64f3bccdb7 tests: Bluetooth: Add per_adv sync with privacy
Add test where privacy is enabled and where
the two devices are bonded and have exchanged IRK
before doing the periodic advertising sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 09:43:59 +01:00
Emil Gydesen 11945688fb tests: Bluetooth: Add per_adv connection tests
Expand the periodic advertising tests with connections,
to verify that two devices can simultaneously be connected
and keep a periodic advertising sync.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 09:43:59 +01:00
Emil Gydesen 2db5d4d790 tests: Bluetooth: Add per_adv BSIM tests
Adds a test suite exclusively for testing
periodic advertising sync.

The first test added is a simple test that does a periodic
advertising sync, and passes afterwards.

The test suite will be expanded with testing PA syncs
with PAST (both from remote and local transfer) as well
as privacy handling.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-24 09:43:59 +01:00
Aleksandr Khromykh 83207d4a9a tests: Bluetooth: Mesh: use overlays for mesh bsim
Add the overlays usage for bsim mesh configurations instead of
multiple configurations that duplicate each other a lot.

Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
2023-01-24 09:43:38 +01:00
Sam Hurst 6b4b7a02e7 usb-c: tcpc: Enable ISR Hard Reset sent bits
This change enables the ISR Hard Reset sent bits, so that
an interrupt is generated when a Hard Reset is sent or
the Hard Reset failed.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Sam Hurst 603ac13145 usb-c: tcpc: Correctly detect Hard Reset sent detection
The Hard Reset sent signal was tested twice in the same
"if else" structure but only handled in the last test. This
change removes the first detection so that Hard Reset can
be correctly detected.

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Sam Hurst e3365e961d usb-c: tcpc: Simplify Hard Reset complete logic
This change simplifies the Hard Reset complete logic

Signed-off-by: Sam Hurst <sbh1187@gmail.com>
2023-01-24 09:43:20 +01:00
Tomasz Moń 7608f54433 usb: device_next: Do not leak memory on set address
USB stack did leak memory on every SET ADDRESS request. UDC control
allocator could cope with up to 13 leaked allocations. Therefore,
issuing bus reset 13 times in a row (in addition to automatic reset
after connecting the USB cable) was enough to exhaust memory and
thus drive USB stack inoperable.

Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
2023-01-24 09:43:00 +01:00
Erwan Gouriou 7b221fbe45 drivers: clock_control: stm32: Can't get MSI freq
Update driver to allow MSI frequency retrieval.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-24 09:42:51 +01:00
Erwan Gouriou e7a60e30b9 boards: stm32h747i_disco_m7: Fix USB domain clock
On board stm32h747i_disco_m7, USB clock is updated to enable USB1ULPI
clock.
Doing so, it should not delete 48MHz domain clock setting.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-24 09:42:51 +01:00
Erwan Gouriou 3b97a481c4 dts: stm32l4: Use HSI48 as 48MHz clck source when available
On STM32L4 that probvide HSI48 clock, use it as 48MHz domain clock.
This impacts following devices:
-SDMMC
-RNG
-USB
Otherwise, when HSI48 is not available MSI is used.

Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-24 09:42:51 +01:00
Erwan Gouriou e67b2fa60d drivers/disk: sdmmc stm32: Fix compilation issues
Fix a bunch of issues which were blocking driver compilation.


Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
2023-01-24 09:42:51 +01:00
Jordan Yates 9eaf1f8b44 tests: pm: power domains: test supported device
Validate the powered state and transitions for an arbitrary device
hanging off a power domain.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-24 09:42:11 +01:00
Jordan Yates addf405fe6 power_domain: gpio: only run actions for children on domain
Only run the `PM_DEVICE_ACTION_TURN_ON` and `PM_DEVICE_ACTION_TURN_OFF`
actions for child devices that have refered to the domain via the
`power-domain` property.

This prevents multiple actions being run for devices that refer to
several power domains, e.g.

```
	test_dev: test_dev {
		compatible = "test-device-pm";
		status = "okay";
		power-domain = <&test_reg_1>;
		alternate-domain = <&test_reg_chained>;
	};
```

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-01-24 09:42:11 +01:00
Mahesh Mahadevan 3b7e7575a9 drivers: usb: Enable High speed Kconfig for NXP controllers
Enable the USB_DC_HAS_HS_SUPPORT Kconfig for NXP controllers
that support High speed.

Signed-off-by: Mahesh Mahadevan <mahesh.mahadevan@nxp.com>
2023-01-23 19:40:44 -08:00
Benjamin Lindqvist 7ffc200820 drivers: sensor: bmi270: don't force val2 > 0
The struct sensor_value type does NOT require val2 to be positive. The
removed code is in fact a rather serious bug, probably put in place
because it makes printing sensor_values easier.

Signed-off-by: Benjamin Lindqvist <benjamin@eub.se>
2023-01-23 12:02:30 -08:00
Emil Gydesen 728384992f Bluetooth: Audio: Unicast client add disabled callback for sink ASE
The sink ASE does not have a disabling state, but since the
stream callbacks does not necessarily match the ASE states,
we need to do our own check to see if a sink ASE has been
disabled.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:55:49 -08:00
Emil Gydesen 13a48de72f Bluetooth: Audio: HAS: Fix notifications/indications
Before this commit we simply always notified/indicated
all presets and active index to any bonded device, even
if they never subscribed to anything, or even if we never
registered HAS.

This commit modifies that, so that only the proper
connected clients will get the notifications/indications,
and that we only send them if something has changed.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen 50a0f62df2 Bluetooth: Audio: HAS: Remove unused control_point_work_sync
Remove unused control_point_work_sync field in the has_client
struct.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen ea858f26c5 Bluetooth: Audio: HAS: Fix active_preset_work initialization
The security_changed callback may be called before
bt_has_register has been called, thus making the active_preset_work
handler uninitailized, causing an ASSERT when the work is submitted
in the security changed callback.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Emil Gydesen d6055f9938 Bluetooth: Audio: Fix HAS double register
Calling bt_has_register multiple times would cause attempts
to register a HAS multiple times. Fixed by adding a check
and return with EALREADY if it is already registered.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
2023-01-23 11:54:21 -08:00
Trent Piepho c45bc68e5c drivers/sensor: lsm6dso: Remove busy wait on bank change
It's not necessary to busy wait 150 µs after changing register banks.
Nothing in the data sheet nor app note suggests this.  ST's own HAL,
which is used by this driver, does not delay when changing banks.  It
does a bank change around every function that accesses a non-user bank
register (it's quite inefficient).

So if it was necessary it would be broken now, as most of the bank
changes have no delay.

One of the few page changes that did have this delay are the those done
before and after reading a sensor sample.  Which is where the speed is
significant and is limiting the update rate the driver is capable of.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 0cfe9560d9 drivers/sensor: lsm6dso: Remove unneeded read/modify/write in shub read
The code in the ST HAL does a read/modify/write to change the bits in
the LSM6DSO_FUNC_CFG_ACCESS register that control which register bank is
active.

All the other bits in the register are defined as zero.  It's possible
to simply set the register to the desired value without reading the
contents first.

This bank switch needs to be done twice for every sensor read when the
sensor hub is used.  The driver as it is can not keep up with the higher
update rates of the lsm6dso.  So any speed increase in this code allows
for a higher update rate as well as reduced latency.

Previously, a read of the lsm6dso's accel and gyro on a 400 kHz I2C bus
with a 3-axis magnetometer on the sensor hub takes 2.69 ms.  This drops
that to 2.26 ms.  This is enough to support the 417 Hz ODR.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 8e80661db7 drivers/sensor: lsm6dso: Fix shub init and configuration failures
There is a flaw with I2C communication to peripherals behind the shub
that causes sporadic failures.  Especially calls to configure a device
after the lsm6dso initialization is finished, e.g. to set the ODR, can
fail to work correctly.

Access to shub peripheral registers is done by putting the parameters of
the operation into SLV0 and then waiting for the lsm6dso to perform the
xfer on the shub I2C bus.  The lsm6dso does this in sync with the
accelerometer update rate.  Once the shub is enabled, it peforms the
xfer repeatedly as the accelermeter is sampled.

The wait has a problem:  It might detect that a previous shub xfer has
finished, which was done before SLV0 was programmed with new parameters.

The shub status register is read-to-clear.  This isn't in the data sheet
or app note, but it is.  By reading the status before enabling the
sensor and after programming SLV0, we can be sure when it becomes set it
has finished the current operation and not a previous one.

Also set the write-once flag before shub init.  This causes the shub to
only perform I2C writes once instead of continuously.  This was set at
the end of init, so any writes done during it would repeat until the
shub was disabled.

Put a timeout in the code that polls for the sensor hub op complete.  It
could possibly poll forever.  More importantly, if there is no device
connected to the sensor hub, the lsm6dso does not timeout on the
operation for ~13 seconds.  Since the shub init does a probe for devices
on startup, this will happen if shub support is enabled but a lsm6dso
has no sensor hub devices.  There could be multiple devices, some with
additional sensors and some without.  Initialization of the devices
without additional sensors takes tens of seconds without this timeout
being added.

Add a 300 µs wait after disabling the sensor hub.  This is necessary
according to the ST app note AN5192 §7.2.1.

Read the shub status from the main bank register instead of the shub
bank register.  This avoids an extra bank switch before and after each
status poll.  Actually two bank switches on each side, since the lsm6dso
driver switched banks and then the ST HAL function to get the status
register switches again.

The wait for the shub I2C transaction to finish is not needed when the
shub is enabled at the end of init.  We aren't starting a new I2C write
or reading the result of a read.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho c379f86dbd drivers/sensor: lsm6dso: Set to user bank on init
The lsm6dso initialization will fail if the device is not already set to
the user register bank.  All the registers used will be the wrong ones
from whatever bank it is in, e.g. sensor hub bank.  This includes the
registers to reset the device!

The bank will default to the user bank on reset, but the chip has no
hardware reset line.  On a reboot it will be in whatever bank it was
last in.  If the sensor hub is enabled, it will switch banks on every
sample, so it's entirely possible to reset or reboot when it happens
to be set to the sensor hub bank, which will cause the driver to
fail to initialize.  It will not work again until the lsm6dso is power
cycled.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 25579d95b1 drivers/sensor: lsm6dso: Disable sensor hub before reset
Per an ST app note, the sensor hub I2C controller should be disabled
before doing a software reset.  Possibly, this is because the sensor hub
could be in the middle of the an I2C transaction to a sensor when it is
reset.  Disabling it and then waiting makes sure it has quiesced before
resetting.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho 7cf6d75a11 drivers/sensor: lsm6dso: Move interrupt config to after chip reset
The initialization code would configure the lsm6dso interrupt, then
configure the rest of the chip.  The chip init includes a reset that
would undo the register setting done during interrupt configuration.

It's also not a good idea to enable the interrupt on the SoC when the
lsm6dso has not yet been reset or configured.  It might be generating
interrupts.

The lsm6dso has no hardware reset line, so it will not be reset on
reboot unless a power cycle is involved.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Trent Piepho d14732b541 drivers/sensor: lsm6dso: Set thread name
When the driver creates its own thread, set the name.

Signed-off-by: Trent Piepho <trent.piepho@igorinstitute.com>
2023-01-23 11:52:39 -08:00
Tom Burdick 58312e6104 dma: Repeated start/stop support for gpdma
Allows for repeatedly calling start/stop on designwares gpdma.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Tom Burdick a684714d5c soc: intel_adsp: Correct HDA parameter docstrings
The parameter doc string for hda was incorrect as the parameters
had been updated to take the IP base address, block size, and stream id
instead. Updates all doc string comments to account for the change.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Tom Burdick b14296af38 dma: HDA ignore repeated start/stop requests
The DMA API contract specifies that start/stop may be called multiple
times. Prior to adding power management this was perfectly fine as it was.
In adding power management, there are additional side effects that can
cause issues. Instead check the state of the channel prior to start/stop
and do nothing if already in the desired state.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Tom Burdick b1e1b5e7b4 dma: Test repeatedly calling start/stop
Ensures that the documented behavior of the API is met by implementations
through testing. By calling stop on a stopped channel the expectation is no
error occurs and is checked.

Calling start after a channel has been started is difficult to test for
as there is transfer timing involved. A once shot transfer may have
completed and the channel transition to an inactive state by itself by
the time the second start call is performed. This isn't supported by at
least gpdma today and isn't documented behaviorally so should not be
tested.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Tom Burdick ec9d94e06d dma: Document expected behavior of start/stop
The DMA API expects drivers in effect to maintain their own internal
state of channels. A channel that is already started may have dma_start
called on it again without effect. A channel that is already stopped may
have dma_stop called on it without effect.

In essence, start and stop are expected to act like events a DMA channels
finite state machine reacts to and if the state is already at the desired
one then nothing is to be done and no error has occurred.

Signed-off-by: Tom Burdick <thomas.burdick@intel.com>
2023-01-23 11:51:21 -08:00
Quang Bui Trong ad19019b29 samples: watchdog: board s32z270dc2_r52 only build and not running
Currently, the s32z270dc2_r52 board only supports running on RAM,
 so samples or tests watchdogs that perform SoC reset will not produce
 results. Set the build only for these samples and tests until the
 reset SoC function is supported.

Signed-off-by: Quang Bui Trong <quang.buitrong@nxp.com>
2023-01-23 11:46:43 -08:00
Chris Friedt 7f192c30dc include: posix: add c++ extern scope
`<fcntl.h>`, `<net/if.h>`, and `<netinet/tcp.h>` were missing
`extern "C" { .. }"` which is required to avoid C++ name
mangling.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt c2a62f4ad7 net: sockets: conditionally include zephyr/posix/fcntl.h
Only include `<fcntl.h>` for `CONFIG_ARCH_POSIX`. Otherwise,
include `<zephyr/posix/fcntl.h>`.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt ab6102f70f tests: posix: existence tests for standard POSIX includes
Add a trivial suite that simply ensures headers exist and that
they supply standard symbols and constants.

These tests are intended to be ordered exactly as the respective
feature appears in the respective specification at

https://pubs.opengroup.org/onlinepubs/9699919799

Over time, as POSIX support improves, we can enable additional
checks.

If `CONFIG_POSIX_API=n`, then we simply ensure that the header
can be included, that constants and structures exist, including
the existence of required fields in each structure.

We check that a constant exist, by comparing its value against
an arbitrary number. If the constant does not exist, it would
of course be a compile error.

```
zassert_not_equal(-1, POLLIN);
```

We check that a structure contains required fields by
comparing the field offset with an arbitrary number. If
the field does not exist, of course, there would be a
compile error.

```
zassert_not_equal(-1, offsetof(struct pollfd, fd));
```

For non-scalar constants, we simply attempt to assign
a value to the specific type:

```
struct in6_addr any6 = IN6ADDR_ANY_INIT;
```

If `CONFIG_POSIX_API=y`, then we additionally check that required
functions are non-NULL (limited to what is currently supported in
Zephyr).

```
zassert_not_null(pthread_create);
```

Note: functional verification tests should be done outside of this
test suite.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt 6ac402bb3a net: socket: additional POSIX constants
The POSIX spec requires that `SO_LINGER`, `SO_RCVLOWAT`,
and `SO_SNDLOWAT`, and `SOMAXCONN` are defined in
`<sys/socket.h>`. However, most of the existing socket
options and related constants are defined in
`<zephyr/net/socket.h>`.

For now, we'll co-locate them. It would be
good to properly namespace things.

Additionally, a no-op for setsockopt for `SO_LINGER` to
make things Just Work (TM) for now.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00
Chris Friedt b059f512f5 posix: netdb: provide NI_MAXSERV for reasonable app defaults
The `<netdb.h>` header typically defines `NI_MAXSERV` as a
reasonable default buffer size to use in applications that
use `getnameinfo()` to query a service name.

Most GNU and BSD systems define it by default so provide
it as a convenience so applications and 3rd-party libraries
do not encounter a compile error.

Signed-off-by: Chris Friedt <cfriedt@meta.com>
2023-01-23 09:57:31 -08:00