You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "LingaoM (via GitHub)" <gi...@apache.org> on 2026/10/22 03:56:33 UTC

[PR] Fix/sim timer and bluetooth flow control [nuttx]

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

   ## Summary
   
   Fix two runtime issues discovered while testing NuttX Bluetooth Hosts against BSWorld's Python Controller. Both firmware configurations built successfully, but failed during runtime initialization.
   
   1. **Deliver sim oneshot ticks in interrupt context.**
   
      The sleep-driven timer path directly calls its handler from IDLE. Timer expiry therefore runs in task context, where the ownership check introduced by e65ca9912808 rejects application timers and suppresses their notifications.
   
      Register the timer IRQ handler in both modes and dispatch sleep-driven ticks through `sim_doirq()`. This preserves the ownership check and restores correct interrupt context. The issue caused NimBLE's HCI receive polling callout to stop firing.
   
   2. **Check Controller to Host flow control capabilities.**
   
      The Bluetooth Host unconditionally sends optional flow-control commands, causing initialization to fail on Controllers that do not support them. It also reports completed ACL packets when flow control is inactive.
   
      Read Local Supported Commands before configuring flow control. Warn and continue when support is unavailable, and skip these commands when disabled by configuration. Wait for Host Buffer Size completion before enabling flow control, and report completed packets only after successful activation.
   
   ## Impact
   
   - Restores POSIX timer notifications in sleep-driven sim, including ordinary sim and BabbleSim-enabled configurations.
   - Allows the native Bluetooth Host to initialize with Controllers lacking optional Controller to Host flow control.
   - Preserves flow-control setup and completed-packet reporting for supported Controllers.
   - No changes to public APIs, configuration options or build requirements.
   - The timer change is confined to `arch/sim`; the Bluetooth change affects the native Host stack.
   
   ## Testing
   
   Environment:
   
   - Host: Ubuntu 22.04, x86_64.
   - Compiler: GCC 14.3.0.
   - Targets: `sim:bthcisock` and `sim:nimble`.
   - Bluetooth tests used BabbleSim time and Python Controllers through Unix sockets.
   
   ### Timer regression
   
   With BabbleSim disabled, ran a standalone POSIX `SIGEV_THREAD` timer with a 10 ms period and inspected its callback count after 150 ms.
   
   Before:
   
   ```text
   TIMER_PROBE fired=0
   ```
   
   After:
   
   ```text
   TIMER_PROBE fired=14
   ```
   
   The existing BSWorld NimBLE integration test failed before the timer fix with repeated initialization resets:
   
   ```text
   Resetting state; reason=19
   ```
   
   After the fix, discovery, connection, GATT discovery and subscription passed with the timer ownership check retained.
   
   ### Bluetooth integration and flow control
   
   Built the native Host with Controller to Host flow control both enabled and disabled.
   
   Passed:
   
   - BTSak advertising and scanning.
   - NimBLE discovery, connection, GATT discovery and subscription.
   - Eight protocol-injection cases covering supported/unsupported capabilities, configuration disabling, truncated responses and rejected setup commands.
   
   The injection tests also verified command ordering and completed-packet reporting through the actual ACL receive buffer release path.
   
   ```text
   test_btsak_discovers_advertiser PASSED
   test_nimble_connects_and_subscribes PASSED
   ```
   
   ```text
   ============================== 8 passed in 1.53s ===============================
   ```
   
   `git diff --check` and `tools/checkpatch.sh` passed for both commits.


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix/sim timer and bluetooth flow control [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #20879:
URL: https://github.com/apache/nuttx/pull/20879#discussion_r4345146875


##########
wireless/bluetooth/bt_hcicore.h:
##########
@@ -97,6 +97,7 @@ struct bt_dev_s
 
   /* Controller buffer information */
 
+  bool host_flow_control_enabled;

Review Comment:
   flow_control_enable



-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix/sim timer and bluetooth flow control [nuttx]

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20879:
URL: https://github.com/apache/nuttx/pull/20879


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix/sim timer and bluetooth flow control [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20879:
URL: https://github.com/apache/nuttx/pull/20879#issuecomment-6338005929

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report &middot; [Explore what changed →](https://membrowse.com/public/apache/nuttx?commit_sha=04a6d971626ccabaeeb025e913bb41ad6432cd15)
   
   
   *No memory changes detected for:*
   - [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   - [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=04a6d971626ccabaeeb025e913bb41ad6432cd15&base=a46119d43726b69bb91805af45ec94c5024c95d2)
   
   ---
   <sub>Catch memory regressions in CI with [MemBrowse](https://membrowse.com). Free for open source.</sub>
   


-- 
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: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org