ViezeVingertjes opened a new pull request, #22446:
URL: https://github.com/apache/nuttx/pull/22446

   ## Summary
   
   Since 038e17eb46 ("wireless/bluetooth: Check Controller to Host flow
   control support"), Host Buffer Size and Set Controller To Host Flow
   Control are sent synchronously and a failure of either is fatal.  Before,
   Host Buffer Size was sent without waiting for its result.
   
   The ESP32-S3 BLE controller lists these commands as supported, but
   rejects Host Buffer Size with status 0x11 (Unsupported Feature or
   Parameter Value) unless the host takes ACL packets of at least 251 bytes,
   the maximum LE data length.  The NuttX host buffer is smaller (74 bytes),
   so since that commit the Bluetooth host fails to initialize on ESP32-S3
   and no Bluetooth interface is registered.
   
   Controller to Host flow control is optional, so treat a rejection of
   either command (-EIO: the controller returned an error status) like a
   controller that does not support it: warn and continue without flow
   control.  Other errors, such as a timeout, stay fatal.
   
   ## Impact
   
   * Is new feature added? Is existing feature changed? NO: bug fix 
(initialization no longer fails when the controller rejects optional flow 
control commands).
   * Impact on user (will user need to adapt to change)? NO
   * Impact on build (will build process change)? NO
   * Impact on hardware (will arch(s) / board(s) / driver(s) change)? YES: 
Bluetooth works again on controllers that reject Host Buffer Size (seen on 
ESP32-S3).
   * Impact on documentation (is update required / provided)? NO
   * Impact on security (any sort of implications)? NO
   * Impact on compatibility (backward/forward/interoperability)? NO: 
controllers that accept the commands behave as before.
   
   ## Testing
   
   I confirm that changes are verified on local setup and works as intended:
   * Build Host(s): Linux x86_64, xtensa-esp-elf GCC 15.2.0 
(esp-15.2.0_20251204), riscv32-esp-elf GCC 15.2.0, host GCC for sim.
   * Target(s): Waveshare ESP32-S3-Touch-AMOLED-2.16 (ESP32-S3), with the 
board's BLE configuration (board support is in a separate PR); btsak.
   
   A probe of the controller (temporary code, not part of this PR) sent Host
   Buffer Size with several ACL lengths: 27 and 74 (the NuttX value) were
   rejected with status 0x11, 251 and 1021 were accepted.
   
   Builds (each on current master plus this PR only):
   
   * PASS sim:bthcisock (warnings: 0)
   * PASS esp32s3-devkit:ble (warnings: 0)
   * PASS esp32c3-devkit:ble (warnings: 0)
   * PASS esp32s3-devkit:ble + CONFIG_BLUETOOTH_CNTRL_HOST_FLOW_DISABLE=y 
(warnings: 0)
   * checkpatch: no issues
   
   Testing logs before change:
   
   ```
   hci_cmd_done: WARNING: status 17
   bt_hci_cmd_send_sync: ERROR:  Failed get return parameters
   hci_initialize: ERROR:  bt_hci_cmd_send_sync failed: -5
   bt_initialize: ERROR:  hci_initialize failed: -5
   bt_netdev_register: ERROR:  bt_initialize() failed: -5
   esp32s3_ble_initialize: bt_driver_register error: -5
   nsh> bt bnep0 info
   ERROR:  ioctl(SIOCGBTINFO) failed: 19
   ```
   
   Testing logs after change:
   
   ```
   hci_cmd_done: WARNING: status 17
   bt_hci_cmd_send_sync: ERROR:  Failed get return parameters
   hci_initialize: WARNING: Controller to Host flow control is not available
   nsh> bt bnep0 info
   Device: bnep0
   BDAddr: xx:xx:xx:xx:xx:xx
   Flags:  0000
   Free:   20
     ACL:  20
     SCO:  0
   nsh> bt bnep0 scan start
   nsh> bt bnep0 scan get
   Scan result:
    1.  addr:            xx:xx:xx:xx:xx:xx type: 0
        rssi:            -81
    ...  (5 results, addresses removed)
   nsh> bt bnep0 advertise start
   ```
   
   The "btsak" advertisement is seen by a Linux host (bluetoothctl scan on).
   
   ## PR verification Self-Check
   
   * [x] This PR introduces only one functional change.
   * [x] I have updated all required description fields above.
   * [x] My PR adheres to Contributing Guidelines and Documentation (git commit 
title and message, coding standard, etc).
   * [ ] My PR is still work in progress (not ready for review).
   * [x] My PR is ready for review and can be safely merged into a codebase.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to