Commit graph

627 commits

Author SHA1 Message Date
Ali Hozhabri 98d6dbf787 drivers: bluetooth: hci: Add Bluetooth driver for ST HCI SPI protocol
Copy ST specific SPI protocol code from spi.c to a vendor specific file.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2024-01-10 15:07:36 +01:00
Ali Hozhabri ccc97125f8 drivers: bluetooth: hci: Fix uninitialized array index, issue #66806
Fix issue #66806, caused by PR #65172.

Return -EINVAL from bt_spi_get_header if op is neither SPI_READ nor
SPI_WRITE.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2024-01-04 09:42:50 +01:00
Sylvio Alves f68fbd6984 driver: ble: esp32: implement deinit function
Current ESP32 BLE interface does not allow disabling
BLE. This PR adds proper deinit call.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2023-12-22 09:54:00 +01:00
Erwan Gouriou 098df08bbc drivers: bluetooth: stm32wba: Configure flash manager
Configure flash manager at BLE init.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-12-21 09:19:24 +01:00
Erwan Gouriou 54d7793e82 drivers: bluethooth: stm32wba: Add HCI driver for STM32WBA
Add HCI Driver for STM32WBA devices.
Based on B91 HCI driver.

Signed-off-by: Erwan Gouriou <erwan.gouriou@st.com>
2023-12-18 17:31:08 +00:00
Aaron Ye d385150bb0 drivers: bluetooth: Add Ambiq HCI driver for Apollo4 Blue Plus.
This commits create the dts binding for Ambiq BT HCI instance.
And create the SPI based common HCI driver for Ambiq Apollox
Blue SoC and the extended soc driver for HCI.

Signed-off-by: Aaron Ye <aye@ambiq.com>
2023-12-18 14:54:53 +01:00
Ali Hozhabri e3ec41e15c drivers: bluetooth: hci: Remove config BT_SPI_BLUENRG
Remove BT_SPI_BLUENRG Kconfig parameter as it is redundant according to
the new changes introduced by ST SPI protocol V1 and V2.

Remove "config BT_SPI_BLUENRG" from the boards that were using it.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-12-11 23:57:49 +00:00
Ali Hozhabri a67bc25b5f drivers: bluetooth: hci: Introduce ST SPI protocol V2
Introduce STMicroelectronics SPI protocol V2 which is used in BlueNRG-1
and successor devices.

Change the size of the variable "size" to 16 bits as it is necessary for ST
BlueNRG-1 and successor devices.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-12-11 23:57:49 +00:00
Ali Hozhabri 810df7cef9 drivers: bluetooth: hci: Remove header acquisition from bt_spi_send
Replace the header acquisition scope in bt_spi_send with bt_spi_get_header.

Add WRITE_DATA_CONDITION in order not to retransmit data without reading
the header as it is meaningless for ST BlueNRG devices.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-12-11 23:57:49 +00:00
Ali Hozhabri 36b0e26e64 drivers: bluetooth: hci: Restructure spi.c to handle different protocols
Update structure of spi.c to have a better and cleaner separation
between STMicroelectronics and Zephyr SPI protocol.

Introduce bt_spi_get_header to separate algorithms well for
header acquisition in different protocols.

Remove header acquisition from bt_spi_rx_thread to make it simpler.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-12-11 23:57:49 +00:00
Jonathan Rico ea04fd95f9 Bluetooth: ATT: remove BT_ATT_ENFORCE_FLOW
Enforcing the peer's behavior is not strictly necessary. All the host
should do is make sure it is resilient to a spec-violating peer.

Moreover, a growing number of platforms were disabling the check, as the
spec allows "batching" HCI num complete packets events, stalling ATT RX.

Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-12-06 17:53:54 +00:00
Armin Brauns b8856aed0d drivers: bluetooth: add more documentation for BT_HCI_SET_PUBLIC_ADDR
Hopefully this should now aid driver developers as well as application
developers.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-12-06 16:42:41 +02:00
Armin Brauns 281f27ec38 drivers: bluetooth: fix and clean up BlueNRG HCI setup() function
If no public address was set, it should just do nothing instead of
erroring. The function should also be static and there's no need to copy
the address struct.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-12-06 16:42:41 +02:00
Abderrahmane Jarmouni 3ce60d2d34 drivers: bluetooth: hci: ipm_stm32wb: naming fix
STM32CubeWB v1.18.0 replaces Master with Central & Slave with Peripheral
in the file app_conf.h (modified in the commit updating lib/stm32wb)

Signed-off-by: Abderrahmane Jarmouni <abderrahmane.jarmouni-ext@st.com>
2023-12-06 12:10:08 +00:00
Michele Sardo 0f44d62740 drivers: bluetooth: hci: handle event with high priority flag
Make sure that events flagged as high priority are handled when
CONFIG_BT_RECV_BLOCKING is not defined.

Fix for #65892.

Signed-off-by: Michele Sardo <msmttchr@gmail.com>
2023-12-04 14:18:20 +01:00
Armin Brauns 4321f86f1e drivers: allow setting BlueNRG public address
The zephyr bluetooth stack expects the controller to know its public
address, if any. At least for BlueNRG, the public address is forgotten with
every reset/power cycle, so there needs to be a way to set it from within
zephyr. This is accomplished using the `Aci_Hal_Write_Config_Data` HCI
command, as described in PM0237.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +01:00
Armin Brauns 57b04c1eb0 drivers: refactor BlueNRG SPI driver for more config options
"LL only" is not the only config option of potential interest, e.g. the
public address is also important.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +01:00
Armin Brauns 5b1b260f80 bluetooth: add HCI driver parameter to set controller's public address
This allows HCI drivers to expose vendor-specific functions to set the
public address.

Signed-off-by: Armin Brauns <armin.brauns@embedded-solutions.at>
2023-11-29 10:44:25 +01:00
Jordan Yates e1cd9f335d bluetooth: hci: spi: handle interrupt return code
Handle the GPIO module failing to configure the interrupt line.

Fixes #65583

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-25 08:53:49 -05:00
Jordan Yates 8b95376625 bluetooth: hci: increase SPI driver stack size
Increase the SPI RX driver stack size by 128 bytes. Overflows have
previously been observed on real hardware at the default stack size of
512.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-25 08:53:49 -05:00
Krzysztof Chruściński 1f0320441b drivers: bluetooth: hci: cyw43xxx: Add dependency to UART runtime config
Force enabling of the UART runtime configuration for CYW43XXX.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2023-11-15 10:02:18 +01:00
Nazar Palamar 5c3abe9197 drivers: bluetooth: rename BT_CYW43XXX to BT_AIROC
rename BT_CYW43XXX to BT_AIROC to be compatible with
WIFI_AIROC

Signed-off-by: Nazar Palamar <nazar.palamar@infineon.com>
2023-11-08 15:07:37 +00:00
Jordan Yates 2283b02ce4 bluetooth: hci: spi: delay between header and data
The HCI receive path has a delay between reading the header and payload
from the controller to give the controller time to setup the SPI
peripheral for the next transaction. Add the same delay on the transmit
path for the same reasons.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-06 10:11:33 +01:00
Jordan Yates 0f903f04ac bluetooth: hci: spi: log TX retransmissions
Add log output when the HCI interface is forced to retransmit a packet
because the controller is not ready.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-11-06 10:11:33 +01:00
Ali Hozhabri 396e1ce9b0 drivers: bluetooth: hci: Use macros instead of hard-coding
Replace hard-coded values with suitable macros.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-11-03 11:45:38 +01:00
Ali Hozhabri 7038e03695 drivers: bluetooth: hci: SPI configuration
Modify SPI configuration to match the features introduced in PR #63437.

Set the property "controller-data-delay-us" to zero for boards
which are using BlueNRG-MS.

Fix Chip Select configuration for stm32l562e_dk board.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-11-03 11:45:38 +01:00
Ali Hozhabri 8265213d8b drivers: bluetooth: hci: Omit configure_cs
Remove redundant configure_cs as it is performed by SPI initialization.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-11-03 11:45:38 +01:00
Ali Hozhabri 1bd2a4f049 drivers: bluetooth: hci: Replace printk with LOG_HEXDUMP_DBG
Use LOG_HEXDUMP_DBG for SPI message logging instead of printk.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-11-03 11:45:38 +01:00
Carles Cufi 9cf07bbdb5 bluetooth: Rename rpmsg HCI driver and sample to ipc
The existing driver and sample:

- drivers/bluetooth/hci/rpmsg
- samples/bluetooth/hci_rpmsg

are no longer correctly named, since they now use the IPC subsystem to
send and receive data. The IPC subsystem can use RPMsg as a transport,
but that is one of several selectable backends.

I initially wanted to deprecated both the BT_RPMSG Kconfig option as
well as the zephyr,bt-hci-rpmsg-ipc chosen node in Devicetree. However,
this proved to be undoable in the case of the Kconfig option. This is
because it's a choice option, and those have special behavior. In
particular, the only practical way to deprecate would've been to keep
the old Kconfig option outside the choice (much like it's done in this
commit) but then also add a 'depends on !BT_RPMSG' on each of the
remaining choice symbols *except* on the new BT_HCI_IPC one. This, however,
only works correctly for .conf files. If a board instead sets the
default BT_HCI_BUS_TYPE in the Kconfig.defconfig file then the Kconfig
tree parsing would fail, because it'd try to set it to a value
(BT_RPMSG) that is no longer part of the choice.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-11-02 08:32:20 +02:00
Benedikt Schmidt 9247f0e07b drivers: bluetooth: fix thread function signatures
Fix thread function signatures to avoid a stack corruption on thread exit.

Signed-off-by: Benedikt Schmidt <benedikt.schmidt@embedded-solutions.at>
2023-10-30 12:24:34 +01:00
Jordan Yates 322d4c1f98 bluetooth: hci: spi: avoid rxmsg re-use
Don't re-use the `rxmsg` buffer in the `bt_spi_send` function. This
buffer is still used by the RX thread after releasing the SPI semaphore.
The current re-use can result in buffer corruption if the RX thread is
swapped out as a result of the `k_sem_give`.

Moving the semaphore release later can result in deadlocks due to
buffer allocation being performed while holding the semaphore, so
instead just eliminate the re-use entirely.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-10-23 18:19:58 +02:00
Jordan Yates 00e67753ac bluetooth: hci: spi: extract message handling to func
Extract the HCI message handling out to a dedicated function to simplify
the main thread function. This also solves a bug as a side effect.

Previously `discardable` and `timeout` were never being reset after
an advertising report was received, resulting in ALL events after the
first advertising report being treated as discardable.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-10-23 18:19:58 +02:00
Aleksander Wasaznik f187d1bdf4 Bluetooth: drivers/rpmsg: Ensure coop prio bt_recv
Ensure that the Bluetooth rpmsg driver thread is temporarly in
cooperative mode using `k_sched_lock`.

The previous commit added the documentation on `bt_recv` stemming from
the general consensus among maintainers that `bt_recv` may not be called
from preemptible priorites.

Many uses may be affected by this race condition, since the default
configuration of rpmsg driver selects a preemtible priority.

Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
2023-10-09 19:03:59 +03:00
Carles Cufi c0a349eac4 drivers: bluetooth: rpmsg: Send reset only when the Host is included
The rpmsg_close() call uses the HCI reset command to reset the
controller. But when building as controller-only we do not bring in the
infrastructure to send HCI commands (nor should we) and rpmsg_close()
will not be called anyway.

Fixes #63534.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-10-06 16:18:58 +03:00
Pawel Osypiuk 7bc93a62b8 drivers: bluetooth: rpmsg: implement .close()
Add .close() implementation for the HCI RPMsg driver.

When running on the nRF5340 application core, it will power-cycle the
network core.

Signed-off-by: Pawel Osypiuk <pawelosyp@gmail.com>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
2023-09-29 13:53:13 +02:00
Jordan Yates c667b43697 bluetooth: hci: enable backends by default
Enable backends by default, instead of requiring some other module to
turn them on. This aligns with the behaviour of sensor drivers and
`BT_RPMSG`.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 16:43:42 +02:00
Jordan Yates ca5931065c testsuite: boards: unit_testing: default HCI bus
Be explicit about the HCI backend that Bluetooth unit tests require.
Some unit tests depend on `BT_HAS_HCI_VS`, so also enable that.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-25 16:43:42 +02:00
Gerard Marull-Paretas 691facc20f include: always use <> for Zephyr includes
Double quotes "" should only be used for local headers.

Signed-off-by: Gerard Marull-Paretas <gerard@teslabs.com>
2023-09-14 13:49:58 +02:00
Markus Fuchs ba57c1880c drivers: bluetooth: slz_hci: Set Number of Completed Packets threshold
Configure the Number of Completed Packets event threshold to 1, so the
SiLabs Bluetooth controller will always send the Number of Completed
Packets HCI event to the host, even for small numbers of transmitted
packets.

Fixes #62279

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2023-09-12 11:23:14 +02:00
Markus Fuchs c33492655f drivers: bluetooth: slz_hci: Adapt to library BLOBs version 4.2.4
Make HCI driver compatible to the updated versions of the
EFR32 Bluetooth library BLOBs consisting of:
* libbluetooth_controller
* libbgcommon
* librail

Signed-off-by: Markus Fuchs <markus.fuchs@ch.sauter-bc.com>
2023-09-12 11:23:14 +02:00
Jordan Yates 72c94d982c bluetooth: hci: spi: warn about l2cap MTU values
`CONFIG_BT_L2CAP_TX_MTU` drives the maximum supported MTU on a Bluetooth
connection, but the SPI backend also imposes its own hidden limits.

Display a warning if a value is chosen that can result in failures to
send. This is done here instead of as a range on `BT_L2CAP_TX_MTU` as
ranges on that symbol are already defined in terms of software features,
which would conflict with this check.

Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
2023-09-05 11:41:33 +02:00
Ali Hozhabri be5cf2ddb9 driver: bluetooth: hci: fix potential "block forever" issue
Interrupt is enabled before reset is released to make sure that the
first IRQ edge is captured, and rx thread can process it.

Remove delay in spi_open as it was redundant due to the "sem_initialised"
semaphore.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-09-01 13:22:08 +02:00
Ali Hozhabri 6d9f2a9143 drivers: bluetooth: hci: spi: Revert to edge sensitive interrupt. (#59459)
Solved also a mutex issue with SPI access.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2023-09-01 13:22:08 +02:00
Victor Chavez 80d4c76a1f Bluetooth: Userchan: Parse multiple hci packets
After conducting tests with a a virtual Bluetooth controller
over TCP it was noticed that some HCI packets may arrive on the
same buffer if sent over a short period of time.
This update ensures the hci packets are parsed correctly in the case
multiple packets are in the same recieving buffer according to
the Bluetooth Spec v5.4 Part E.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-08-30 10:18:41 +02:00
Nick Ward 2d65acca3a drivers: gpio: use gpio_is_ready_dt helper function
Update `struct gpio_dt_spec` use with gpio_is_ready_dt()

Signed-off-by: Nick Ward <nix.ward@gmail.com>
2023-08-28 08:48:35 -05:00
Victor Chavez 33c922a771 Bluetooth: Userchan: Add support for TCP Connection
Added support to connect to an HCI TCP Server. This
allows to do integration tests with other frameworks
that support a virtual hci interface.

Signed-off-by: Victor Chavez <chavez-bermudez@fh-aachen.de>
2023-08-22 15:50:56 +02:00
Daniel Leung e3ecca5784 bluetooth: fixes shadow variables
Massaging code to fix shadow variables found by -Wshadow.

Signed-off-by: Daniel Leung <daniel.leung@intel.com>
2023-08-17 13:00:09 +02:00
Carles Cufi 6f8a1669cc drivers: bluetooth: hci: spi: Check and propagate return values
Check and propagate return values from GPIO calls.

Fixes https://github.com/zephyrproject-rtos/zephyr/issues/59529.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2023-08-04 11:56:48 +03:00
Antoine Bout dbea999347 soc/arm/silabs: Kconfig: add SOC_GECKO_USE_RAIL kconfig option
Currently on zephyr, RAIL is used only for bluetooth. RAIL library is
needed to use efr32 radio regardless of the protocol used. We add
SOC_GECKO_USE_RAIL kconfig option to indicate if we use radio.
FPU is needed when using RAIL, we configure it if SOC_GECKO_USE_RAIL
is set.

Signed-off-by: Antoine Bout <antoine.bout@silabs.com>
2023-07-31 09:05:17 +00:00
Marek Matej 6b57b3b786 soc: xtensa,riscv: esp32xx: refactor folder structure
Refactor the ESP32 target SOCs together with
all related boards. Most braking changes includes:

- changing the CONFIG_SOC_ESP32* to refer to
  the actual soc line (esp32,esp32s2,esp32s3,esp32c3)
- replacing CONFIG_SOC with the CONFIG_SOC_SERIES
- creating CONFIG_SOC_FAMILY_ESP32 to embrace all
  the ESP32 across all used architectures
- introducing CONFIG_SOC_PART_NUMBER_* to
  provide a SOC model config
- introducing the 'common' folder to hide all
  commonly used configs and files.
- updating west.yml to reflect previous changes in hal

Signed-off-by: Marek Matej <marek.matej@espressif.com>
2023-07-25 18:12:33 +02:00