When processing LE Extended Advertising Report events in
is_hci_event_discardable(), the evt_type field of adv_info[0] may
reside at an unaligned address. This occurs because evt_data can
point to shared memory (e.g., IMU buffer) at an odd address, and
the evt_type (uint16_t) ends up at an odd offset after the packed
struct layout.
On Cortex-M33 with UNALIGN_TRP enabled, this causes a HardFault.
Use sys_le16_to_cpu() to read the evt_type field, which ensures
the compiler generates byte-level access (LDRB) for the packed
struct member, avoiding the unaligned LDRH instruction.
Signed-off-by: Gang Li <gang.li_1@nxp.com>
Extend bflb_rf_init() to support WiFi mode (WL_API_MODE_ALL) with
TX power targets and country code configuration when CONFIG_BFLB_WIFI
is enabled.
Add WiFi platform glue: MAC ISR wiring, task creation, low-power
stubs, wl80211 RTOS primitives (heap, RNG, timers), and the linker
section for WiFi shared RAM.
Introduce CONFIG_BFLB_BL61X_WL_RMEM_SIZE for PHY/RF retention memory
sizing.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Add STM32WBAx suspend-to-RAM support and hook the SoC-specific
implementation into the build when CONFIG_PM_S2RAM is enabled.
Select the custom S2RAM marking capability and add the STM32WBAx S2RAM
support source file.
Update the suspend-to-RAM path to clear the hardware standby flag as early
as possible after resume. Use standby_entered as a software indicator to
track whether standby was effectively entered and cleared, so resume
handling only restores radio state when needed.
Signed-off-by: Romain Jayles <romain.jayles@st.com>
Mesh uses legacy packets with extended advertiser.
Dropping of ext adv events is normal behavior.
However, mesh samples ara spammed these error messages
on some platforms.
Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
Add error logging on the device-not-ready, HCI_RESET and firmware
download failure paths, and include the image size in the firmware
download debug message, to make bring-up failures easier to diagnose.
Assisted-by: Copilot:claude-opus-4.8
Signed-off-by: Sreeram Tatapudi <sreeram.praveen@infineon.com>
Default overrides in Kconfig can makeuse of configdefault instead of
config to preserve the dependency checks.
Signed-off-by: Josuah Demangeon <me@josuah.net>
Make sure to have enough even packets for every ACL TX packets we want to
respond. Declare (BT_EVT_RX_COUNT) as (BT_ACL_TX_COUNT + 1).
Signed-off-by: Josuah Demangeon <me@josuah.net>
Add new KConfig BT_STM32WBA_BASIC_PLUS_LIB specifying the
configuration of the stm32wba ble library for bluetooth
basic plus features.
Signed-off-by: Vincent Tardy <vincent.tardy@st.com>
Each BLE controller blob variant reports a fixed number of ACL TX
packets in the HCI LE Read Buffer Size response (extracted from the
binaries): 2 to 16 for BL70x, 2 or 8 for BL60x, 2 to 8 for BL70xL and
4 or 10 for BL61x. Set the BT_BUF_ACL_TX_COUNT default per selected
variant so the host allocates exactly as many bt_conn_tx contexts as
the controller has buffers, silencing the hci_core mismatch warning
and using the controller queue fully.
Signed-off-by: William Markezana <william.markezana@gmail.com>
The bt_hci_driver_api send() contract requires that the buffer
reference is only consumed (unreffed) on success. On error, the
caller retains ownership and is responsible for unreffing the buffer.
bt_bflb_send() was unconditionally calling net_buf_unref() at a
goto done label, incorrectly consuming the buffer on all error paths.
Fix by returning early on each error path (without unreffing), and
unreffing only on the success path.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
The bt_hci_driver_api send() contract requires that the buffer
reference is only consumed (unreffed) on success. On error, the
caller retains ownership and is responsible for unreffing the buffer.
bt_hci_bee_send() was unconditionally calling net_buf_unref() at a
goto done label, incorrectly consuming the buffer on error paths too.
Additionally, buf->len was accessed after the unref, constituting a
use-after-free.
Fix by returning early on each error path (without unreffing), and
unreffing only on the success path.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Add HCI driver for Realtek Ameba BT controller. The driver bridges
the Realtek HAL HCI transport to the Zephyr BT HCI driver API.
Signed-off-by: minyuan xue <minyuan_xue@realsil.com.cn>
Replace the two-line pattern:
net_buf_unref(buf);
buf = NULL;
with net_buf_drop(&buf) which performs both operations
atomically in a single step. Since net_buf_drop() also handles NULL
pointers checks for those before the call can be removed.
Assisted-by: GitHub Copilot:claude-sonnet-4.6
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
This code snippet was originally removed by #109163 but then incorrectly
re-introduced by #107850 (most likely due to a rebasing error).
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
WiseConnect zeros the BT half of its cached coex performance profile
on every Wi-Fi disconnect, leaving BT out of power save and preventing
the NWP from sleeping after re-association.
Delegate Wi-Fi power-save to siwx91x_nwp_apply_power_profile(), which
already owns both BT and Wi-Fi halves of the coex profile. Extend the
helper to accept an optional sl_wifi_performance_profile_v2_t override
so the Wi-Fi driver can pass its tailored profile (listen_interval,
dtim_aligned_type, monitor_interval); BT-only and init call sites pass
NULL to keep their current behaviour.
Signed-off-by: Tejus Subramanya <ters@silabs.com>
Add code comments to make sure the common data/config fields stay in the
correct place in the driver-specific struct if those structs ever get
modified.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
There's no point in having driver specific data structs if the only thing
they contain is the common data struct. Just declare the common data struct
directly as dev->data.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
Now that we have a common data struct, we can take advantage of it and
move the recv callback into it. This way the common layer takes care of
assigning, dispatching and clearing the callback. Drivers now have to use
the new bt_hci_recv() API to pass data to the layer above them (typically
a host stack). Additionally, the drivers no longer get a recv parameter as
part of their open() callback, since that's all handled by the common
layer.
Signed-off-by: Johan Hedberg <johan.hedberg@silabs.com>
When there are multiple zephyr,bt-hci-uart nodes, we currently use the
reset-assert-duration-ms property from the first one for all of them due
to a typo in the initializer macro. Fix it.
Fixes: 9f44b011de ("bluetooth: hci: h4: optional reset pin")
Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Replace manual pointer transfer with net_buf_take() for better
readability and atomic operation.
Signed-off-by: Dharun krithik k <dharunkrithik@aerlync.com>
Provide the necessary changes for the ST HCI SPI Bluetooth driver
to support X-NUCLEO-WBA25A1 shield.
Update ST BLE shields' overlays with the new properties.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Route the ESP32_BT_* defaults through the generic BT_CTLR_* symbols
so a standard BT_CTLR_* toggle reaches the vendor knobs without
further user intervention. Select the matching BT_CTLR_*_SUPPORT
capabilities from BT_ESP32, and add Kconfig entries for the BLE 5.x
feature gates, controller power placement and light-sleep XTAL.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
Defining a Kconfig symbol several times is dangerous. It is better to use
configdefault for the CMSIS related symbols.
Bluetooth configdefault depends on NWP driver. It is more accurate to
depend on the Si91x Bluetooth driver.
Finally, configdefault is supposed to be only used in Kconfig.defconfig
files. So, relocate BT_HCI_ACL_FLOW_CONTROL.
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
This commit fixes the command packet size allocation. It allocates an
'hci_cmd_buf' buffer to store the HCI command packet to send. The buffer
size supports the maximum command packet size and the maximum event size.
This commit also fixes an issue where the buf argument was not unreferenced
when bt_buf_get_evt() failed in the BT_HCI_H4_CMD command case.
Signed-off-by: Vincent Tardy <vincent.tardy@st.com>
Having an interface library named "mbedTLS" and the real library named
"mbedtls" (as provided by the Mbed TLS module) is misleading.
This commit replaces:
- mbedTLS -> mbedtls_iface for the CMake library. "mbedTLS" is still
available as alias to "mbedtls_iface" for backward
compatibility, but this should be removed in the future.
- mbedTLS -> Mbed TLS in comments and documentation.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
PatchRAM records store the HCI opcode as a little-endian value in the
firmware image. Read it with sys_get_le16() instead of casting the byte
pointer to uint16_t, which can fault on targets that do not allow
unaligned accesses.
Signed-off-by: Matthias Ringwald <matthias@ringwald.ch>
Extend the shared BFLB HCI driver with BL60x (BL602) support: BL60x
include paths, controller init macros, IRQ setup, and platform shim
forward declarations.
Kconfig adds BT_BFLB_BL60X with two controller variant choices
(m1s1, m8s1) and smart defaults based on enabled BT roles.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Introduces K_MEM_SLAB_DEFINE_TYPE() and K_MEM_SLAB_DEFINE_STATIC_TYPE()
helpers to allow the user to declare slabs for types without having to
manually ensure the alignment is correct.
Manual slab alignment was very error-prone and this change fixes several
instances of misalignment that would be trapped by the undefined
behavior sanitizer when running on 64-bit targets.
Signed-off-by: Egill Sigurdur <egill@egill.xyz>
Extend the shared BFLB HCI driver with BL61x (BL616/BL618) support:
BL61x include paths and RF init routing through bflb_rf_init().
Kconfig adds BT_BFLB_BL61X with four controller variant choices, a
configurable PHY/RF retention memory size, and a 64 KB exchange memory
option for the BR/EDR variant.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Implements a method for discarding fragmented extended advertising. In
order to acheive this, we need to consider past and future fragments
of the advertising report we discard.
The future fragments are on its way from the controller, and will result
in either a complete- or incomplete event. These are handled by tracking
the adv SID and address until the controller sends either a complete or
incomplete event. Once an advertising report is marked as discarded,
consecutive fragments will be silently discarded.
The past fragments are either already in the reassembler (in scan.c),
or on their way through the rx_queue. To handle these, and allow the
reassembler to recover from a in-progress reassembly which is discarded,
we add a work item which is rescheduled when each consecutive fragment
is received. The timeout is configurable through the new Kconfig option
`CONFIG_BT_EXT_ADV_REASSEMBLY_TIMEOUT`. On timeout, the reassembler will
change its state to discard incoming fragments from the same advertiser.
The reassembler will start assembling new fragments if it recognises a
new advertiser, or if a final fragment (either marked as complete
or incomplete) from the advertiser it is currently tracking is received.
This functionality needs to be added at a HCI driver level by using the
new `hci_ext_adv_report_process` function. It is added the the
IPC HCI driver to fixzephyrproject-rtos/zephyr#50786
Signed-off-by: Håvard Reierstad <haavard.reierstad@nordicsemi.no>
Add new inline function entropy_get_default_device which returns
the "zephyr,entropy" device or the architectural entropy device,
if the former is not set, and use that in all places to query the
entropy device.
This allows using architectural drivers which do not have a DT
node.
Signed-off-by: Christoph Busold <cbusold@qti.qualcomm.com>
-Add inband independent reset support for IW612, IW416 and IW610
-Add kconfig option to enable/disable IR support
Signed-off-by: Vinit Mehta <vinit.mehta@nxp.com>
Replace the placeholder help text for BT_STM32_IPM with a short
description of the driver. This makes the option clearer in Kconfig
interfaces and avoids leaving a visible TODO in user-facing text.
Signed-off-by: Manaam Rehan <manaamrehan2k19@gmail.com>
Calculate the future time correctly to avoid negative value for "value_ms".
Register the pm_policy_event when HAL_RADIO_TIMER_SetRadioTimerValue
returns success.
Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
Since bt_hci_evt_hdr is a variable sized struct, it shall be
located at the end of the struct.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Merge the separate BL70X and BL70XL HCI drivers (hci_bflb_bl70x.c,
hci_bflb_bl70xl.c) into a single hci_bflb.c. Both SoCs share the
same on-chip HCI interface; platform differences (controller API
names, includes, RF calibration) are resolved via macros in a
single #if/#elif block at the top of the file.
Add BL70XL Kconfig (silicon revision, BLE variant selection) and
update depends lines to use the unified DT_HAS_BFLB_BT_HCI_ENABLED
combined with the SoC series.
Signed-off-by: William Markezana <william.markezana@gmail.com>
Fix two issues in the NXP HCI firmware upload code:
1. In fw_upload_wait_length(), the length complement was incorrectly
read from the same buffer offset as the length field. It should be
read from offset 2 to properly validate the length field.
2. In fw_upload_write_hdr_and_payload(), replace the call to
fw_upload_send_ack() with a direct call to fw_upload_write_data()
to send the V1_REQUEST_ACK. This ensures the ACK is sent using the
correct write function.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>