Skip to content

Commit

Permalink
Bluetooth: Controller: Add device tree dependency to selection
Browse files Browse the repository at this point in the history
This commit makes the device tree configuration decide
which link layer is compiled in. We do this to avoid
hard-to-understand linker errors referencing device tree nodes.

The following configuration creates a difficult to parse
linker error:
* BT_LL_CHOICE contains multiple entries, BT_LL_SW_SPLIT
  is selected.
* Each BT_LL_CHOICE has its own unique device tree node with its
  own "compatible".
* Only one of the link layer device tree nodes has status "okay",
  but not the one corresponding to BT_LL_SW_SPLIT.

The linker error indicates that code using the HCI driver fails
to link with the controller. This because the HCI driver device
tree node references the link layer selected in devicetree which
is not compiled in.

By adding a dependendency to the device tree node, this can no longer
happen. Instead, if BT_LL_SW_SPLIT is now selected in a configuration
file, a Kconfig warning will be issued:

```
warning: The choice symbol BT_LL_SW_SPLIT
(defined at subsys/bluetooth/controller/Kconfig:129) was
selected (set =y), but BT_LL_SOFTDEVICE (defined at
/home/ruge/ncs/nrf/subsys/bluetooth/controller/Kconfig:11)
ended up as the choice selection.
```

This should be easier to understand than:

```
...(hci_core.c.obj):(.data.bt_dev+0x16c):
undefined reference to `__device_dts_ord_132'
```

After this commit we should consider getting rid of link layer
selection from Kconfig completely as the link layer is in practice
selected through device tree.

Unit tests have been updated to satisfy the dts dependency.

Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
  • Loading branch information
rugeGerritsen authored and fabiobaltieri committed Sep 26, 2024
1 parent 2668476 commit 417a9e8
Show file tree
Hide file tree
Showing 28 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions subsys/bluetooth/controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ choice BT_LL_CHOICE

config BT_LL_SW_SPLIT
bool "Software-based BLE Link Layer"
depends on DT_HAS_ZEPHYR_BT_HCI_LL_SW_SPLIT_ENABLED
help
Use Zephyr software BLE Link Layer ULL LLL split implementation.

Expand Down
9 changes: 9 additions & 0 deletions tests/bluetooth/controller/common/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

# The link layer requires a corresponding device tree node to be enabled
# The corresponding Kconfig entry is not generated for unit tests,
# so we add it here.
config DT_HAS_ZEPHYR_BT_HCI_LL_SW_SPLIT_ENABLED
bool
default y
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_api/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_chmu/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_cis_create/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_cis_terminate/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_collision/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_conn_update/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_cte_req/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_data_length_update/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_encrypt/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_feature_exchange/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_hci/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_invalid/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_isoal/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,6 @@ config BT_CTLR_ISOAL_SN_STRICT
depends on BT_CTLR_ADV_ISO || BT_CTLR_CONN_ISO
default y

source "tests/bluetooth/controller/common/Kconfig"

source "Kconfig.zephyr"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_le_ping/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_min_used_chans/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_phy_update/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_sca_update/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
7 changes: 7 additions & 0 deletions tests/bluetooth/controller/ctrl_sw_privacy/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
7 changes: 7 additions & 0 deletions tests/bluetooth/controller/ctrl_sw_privacy_unit/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_terminate/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_tx_buffer_alloc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_tx_queue/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_unsupported/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
7 changes: 7 additions & 0 deletions tests/bluetooth/controller/ctrl_user_ext/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
2 changes: 2 additions & 0 deletions tests/bluetooth/controller/ctrl_version/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,7 @@ config ENTROPY_NRF_FORCE_ALT
config ENTROPY_NRF5_RNG
default n

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"
7 changes: 7 additions & 0 deletions tests/bluetooth/controller/ll_settings/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "tests/bluetooth/controller/common/Kconfig"

# Include Zephyr's Kconfig
source "Kconfig"

0 comments on commit 417a9e8

Please sign in to comment.