Skip to content

Commit 9ac0d91

Browse files
jplexerclaude
andcommitted
bluetooth-fw: select controller via Kconfig and use wscript_build
Move the Bluetooth controller selection out of the root wscript and the --bt_controller option into a Kconfig choice (BT_FW_NIMBLE / BT_FW_QEMU / BT_FW_STUB), defaulted from the SoC. The nimble options/defines (BT_REQUIRE_EARLY_BONDINGS and the GH3X2X tuning service) also move into Kconfig. With controller selection and those defines now expressed in Kconfig, the bluetooth-fw wscripts no longer need options/configure, so convert the parent and the qemu/stub/nimble controllers to bare-body wscript_build. The --bt_controller override is replaced by --kconfig-override CONFIG_BT_FW_<X>=y. The unused BT_CONTROLLER_NRF52 and BT_CONTROLLER_QEMU defines are dropped, and BT_CONTROLLER_SF32LB52 becomes CONFIG_SOC_SF32LB52. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Joshua Jun <lets@throw.rocks>
1 parent 69b93fc commit 9ac0d91

19 files changed

Lines changed: 122 additions & 156 deletions

File tree

src/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
rsource "fw/Kconfig"
5+
rsource "bluetooth-fw/Kconfig"

src/bluetooth-fw/Kconfig

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# SPDX-FileCopyrightText: 2026 Core Devices LLC
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
menu "Bluetooth"
5+
6+
choice BT_FW
7+
prompt "Bluetooth backend"
8+
default BT_FW_STUB
9+
help
10+
Which Bluetooth backend implementation to build. The default is
11+
derived from the SoC (see each src/fw/soc/<soc>/Kconfig.defconfig);
12+
the stub is the fallback when no SoC default applies.
13+
14+
config BT_FW_NIMBLE
15+
bool "NimBLE"
16+
17+
config BT_FW_QEMU
18+
bool "QEMU transport"
19+
20+
config BT_FW_STUB
21+
bool "Stub (no backend)"
22+
23+
endchoice
24+
25+
config GH3X2X_TUNING_SERVICE_ENABLED
26+
bool "GH3X2X tuning service"
27+
depends on HRM_GH3X2X
28+
help
29+
Build the GH3X2X heart-rate sensor tuning GATT service, used to
30+
tune the sensor over BLE. Off by default.
31+
32+
endmenu

src/bluetooth-fw/nimble/init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ static const uint32_t s_bt_stack_start_stop_timeout_ms = 10000;
2727

2828
extern void pebble_pairing_service_init(void);
2929
extern void nimble_discover_init(void);
30-
#ifdef BT_CONTROLLER_SF32LB52
30+
#ifdef CONFIG_SOC_SF32LB52
3131
extern void ble_transport_ll_wake_lcpu(void);
3232
#endif
3333

@@ -59,7 +59,7 @@ static void prv_sync_cb(void) {
5959

6060
static void prv_reset_cb(int reason) {
6161
PBL_LOG_D_WRN(LOG_DOMAIN_BT, "NimBLE host reset (reason: 0x%04x)", (uint16_t)reason);
62-
#ifdef BT_CONTROLLER_SF32LB52
62+
#ifdef CONFIG_SOC_SF32LB52
6363
// Controller stopped answering HCI. Keep the LCPU reachable and crash so the
6464
// coredump captures LCPU RAM; the reboot cold-recovers the controller.
6565
ble_transport_ll_wake_lcpu();
@@ -148,14 +148,14 @@ bool bt_driver_start(BTDriverConfig *config) {
148148
pebble_pairing_service_init();
149149
ble_svc_bas_init();
150150

151-
#ifdef GH3X2X_TUNING_SERVICE_ENABLED
151+
#ifdef CONFIG_GH3X2X_TUNING_SERVICE_ENABLED
152152
gh3x2x_tuning_service_init();
153153
#endif
154154

155155
ble_hs_sched_start();
156156
f_rc = xSemaphoreTake(s_host_started, milliseconds_to_ticks(s_bt_stack_start_stop_timeout_ms));
157157
if (f_rc != pdTRUE) {
158-
#ifdef BT_CONTROLLER_SF32LB52
158+
#ifdef CONFIG_SOC_SF32LB52
159159
// Keep the LCPU reachable so the coredump captures its RAM.
160160
ble_transport_ll_wake_lcpu();
161161
#endif

src/bluetooth-fw/nimble/wscript

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
excludes = []
2+
if not bld.env.CONFIG_GH3X2X_TUNING_SERVICE_ENABLED:
3+
excludes.extend(['gh3x2x_tuning_service.c'])
4+
5+
driver_source = bld.path.ant_glob(['*.c'], excl=excludes)
6+
7+
bld.objects(
8+
source=driver_source,
9+
target='bt_driver',
10+
use=[
11+
'nimble',
12+
'freertos',
13+
'fw_includes',
14+
'pbl_includes',
15+
],
16+
)
17+
18+
# vim:filetype=python

src/bluetooth-fw/qemu/wscript

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from resources.types.resource_definition import ResourceDefinition
2+
from resources.types.resource_object import ResourceObject
3+
4+
sources = bld.path.ant_glob('**/*.c')
5+
bld.stlib(source=sources,
6+
target='bt_driver',
7+
use=[
8+
'fw_includes',
9+
'freertos',
10+
'pbl_includes',
11+
])
12+
13+
# vim:filetype=python

src/bluetooth-fw/stub/wscript

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from resources.types.resource_definition import ResourceDefinition
2+
from resources.types.resource_object import ResourceObject
3+
4+
sources = bld.path.ant_glob('**/*.c')
5+
bld.stlib(source=sources,
6+
target='bt_driver',
7+
use=[
8+
'fw_includes',
9+
'freertos',
10+
'pbl_includes',
11+
])
12+
13+
# vim:filetype=python

src/bluetooth-fw/wscript

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)