Skip to content

feat: add BLE support for ESP32-C3 via BTDM VHCI - #58

Merged
deadprogram merged 1 commit into
mainfrom
ble-again-july
Jul 29, 2026
Merged

feat: add BLE support for ESP32-C3 via BTDM VHCI #58
deadprogram merged 1 commit into
mainfrom
ble-again-july

Conversation

@deadprogram

Copy link
Copy Markdown
Member

Bring up the ESP32-C3 ROM BTDM controller behind a Virtual HCI transport so the tinygo bluetooth package can drive it. Verified by scanning: advertising reports arrive continuously with correct addresses, names and RSSI.

Requires PR tinygo-org/tinygo#5559 for the linker symbols to resolve.

Once merged, the bluetooth package will require a PR to incorporate this PR.

But scanning is working!

$ tinygo flash -target xiao-esp32c3 -tags espradio -size short -monitor ./examples/scanner/
   code    data     bss |   flash     ram                                           
 284442   16840   42920 |  301282   59760                                           
Connecting to /dev/ttyACM0...                                                       
Connected.                                                                          
Detected chip: ESP32-C3                                                             
USB-JTAG/Serial interface detected, disabling watchdogs                                                                                                                  
Loading stub loader...                                                              
Stub running.                                                                       
Erasing flash...                                                                    
[##################################################]  100.0%                        
Flash erased.                                                                                                                                                            
Attaching SPI flash...                                                              
Configuring flash size...                                                           
Auto-detected flash size: 4MB                                                       
Flash params set to 0x022F                                                          
SHA digest in image updated                                                         
Attaching SPI flash...                                                              
Switching to 460800 baud...                                                         
Running at 460800 baud.                                                             
Compressed 301376 bytes to 193128 (64%)                                             
Flash begin: 193128 bytes at 0x00000000 (12 compressed blocks)                      
[##################################################]  100.0%                        
Flash complete. Verifying...                                                        
MD5 verified: 1d9fa004d2c534212688b0fb2e407618                                      
                                                                                    
Device reset.                                                                       
Connected to /dev/ttyACM0. Press Ctrl-C to exit.
Starting BLE                                                                        
scanning...                                                                         
found device: F4:FD:9C:36:05:50 -71 SM-0550                                         
found device: F1:54:0E:7B:D7:4B -68 SM-D74B                                         
found device: F4:FD:9C:36:05:50 -70 SM-0550  
found device: F1:54:0E:7B:D7:4B -68 SM-D74B                                         
found device: F4:FD:9C:36:05:50 -78 SM-0550                                         
found device: F1:54:0E:7B:D7:4B -72 SM-D74B                                         
found device: F4:FD:9C:36:05:50 -79 SM-0550

Comment thread ble.go Outdated
@deadprogram

deadprogram commented Jul 28, 2026

Copy link
Copy Markdown
Member Author

Tested on Xiao-ESP32C3 with my local bluetooth branch and heartrate and heartrate-monitor both working. Also, the current WiFi still working as well.

tinygo-org/tinygo#5560 is needed to be merged, and then this PR is fully ready for review/merge.

UPDATE: tinygo-org/tinygo#5560 has been merged.

@deadprogram
deadprogram marked this pull request as ready for review July 28, 2026 11:03
@deadprogram

Copy link
Copy Markdown
Member Author

Any more feedback here @soypat or anyone else?

Bring up the ROM BTDM controller behind a Virtual HCI transport so the
tinygo bluetooth package can drive it (scanning, advertising, and central
GATT). Fixes several ROM bring-up defects along the way (CPU frequency,
PHY calibration, scan tables, interrupts) and a scheduler race that broke
central GATT. Adds unit tests for the VHCI RX ring buffer.

Signed-off-by: deadprogram <[email protected]>
@deadprogram

Copy link
Copy Markdown
Member Author

Squashed into a single commit. Ready to go!

@deadprogram

Copy link
Copy Markdown
Member Author

Last call for feedback!

@deadprogram

Copy link
Copy Markdown
Member Author

OK, merging. Thanks for review @soypat

@deadprogram
deadprogram merged commit 2e21d40 into main Jul 29, 2026
1 check passed
@deadprogram
deadprogram deleted the ble-again-july branch July 29, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants