Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions samples/bluetooth/observer/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ If the used Bluetooth Low Energy Controller supports Extended Scanning, you may
enable :kconfig:option:`CONFIG_BT_EXT_ADV` in the project configuration file. Refer to the
project configuration file for further details.

Building Extended Scanning support for BBC Micro Bit board
**********************************************************

.. code-block:: console

west build -b bbc_microbit . -- -DCONF_FILE='prj_extended.conf' -DEXTRA_CONF_FILE='overlay_bbc_microbit-bt_ll_sw_split.conf'

Thread Analysis for BBC Micro Bit board
***************************************

Due to resource constraints on the BBC Micro Bit board, thread analysis can be enabled to profile
the RAM usage and thread stack sizes be updated to successfully build and run the sample.

.. code-block:: console

west build -b bbc_microbit . -- -DCONF_FILE='prj_extended.conf' -DEXTRA_CONF_FILE='debug.conf;overlay_bbc_microbit-bt_ll_sw_split.conf'

Requirements
************

Expand Down
5 changes: 5 additions & 0 deletions samples/bluetooth/observer/debug.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Enable thread analysis
CONFIG_THREAD_ANALYZER=y
CONFIG_THREAD_ANALYZER_AUTO=y
CONFIG_THREAD_ANALYZER_AUTO_INTERVAL=5
CONFIG_THREAD_NAME=y
7 changes: 7 additions & 0 deletions samples/bluetooth/observer/dts/arm/nordic/override.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* Keep default IRQ priority low for peripherals to reduce Radio ISR latency.
* ARM Cortex-M4 lowest priority value of 5, i.e. considering Zephyr reserved 2
* levels for Exceptions and ZLI (if enabled).
* ARM Cortex-M0 lowest priority value of 3, i.e. we use it as Zephyr has no
* support for ZLI on Cortex-M0.
*/
#define NRF_DEFAULT_IRQ_PRIORITY 3
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Adjust Stack Sizes for reduce RAM usage
CONFIG_MAIN_STACK_SIZE=1024
CONFIG_IDLE_STACK_SIZE=128
CONFIG_ISR_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=1024

# Enable Extended Scanning
# CONFIG_BT_EXT_ADV=y

# Set maximum scan data length for Extended Scanning
CONFIG_BT_EXT_SCAN_BUF_SIZE=192

# Zephyr Bluetooth LE Controller needs 16 event buffers to generate Extended
# Advertising Report for receiving the complete 1650 bytes of data.
# Use 4 to be able to receive a minimal extended advertising with chains.
CONFIG_BT_BUF_EVT_RX_COUNT=4

# Use Zephyr Bluetooth Low Energy Controller implementation
CONFIG_BT_LL_SW_SPLIT=y

# Set maximum scan data length for Extended Scanning in Bluetooth LE Controller.
CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=192

# Increase Zephyr Bluetooth LE Controller Rx buffer to receive complete chain
# of PDUs. Need 9 for maximum of 1650 bytes, but we use 3 as minimum to receive
# at least a primary PDU, an auxiliary PDU and a chain PDU.
CONFIG_BT_CTLR_RX_BUFFERS=3

# Enable advanced features
CONFIG_BT_CTLR_ADVANCED_FEATURES=y

# Adjust execution context priorities to achieve lower Radio ISR latencies
CONFIG_BT_CTLR_LLL_PRIO=0
CONFIG_BT_CTLR_ULL_HIGH_PRIO=1
CONFIG_BT_CTLR_ULL_LOW_PRIO=1

# Use just-in-time collision resolution in ticker and LLL pipeline
CONFIG_BT_CTLR_LOW_LAT=n
CONFIG_BT_CTLR_LOW_LAT_ULL_DONE=n
CONFIG_BT_TICKER_LOW_LAT=n

# Increase the below to receive interleaved advertising chains
CONFIG_BT_CTLR_SCAN_AUX_SET=3
CONFIG_BT_CTLR_LOW_LAT_ULL=y
# CONFIG_BT_CTLR_SCAN_AUX_USE_CHAINS=y
# CONFIG_BT_CTLR_SCAN_AUX_CHAIN_COUNT=3

# Use unreserved timespace scanning
CONFIG_BT_CTLR_SCAN_UNRESERVED=y

# Code size reduction
CONFIG_ISR_TABLES_LOCAL_DECLARATION=y
CONFIG_LTO=y
19 changes: 16 additions & 3 deletions samples/bluetooth/observer/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,33 @@ sample:
tests:
sample.bluetooth.observer:
harness: bluetooth
tags: bluetooth
platform_allow:
- qemu_cortex_m3
- qemu_x86
- nrf52840dk/nrf52840
integration_platforms:
- qemu_cortex_m3
tags: bluetooth
- nrf52840dk/nrf52840
sample.bluetooth.observer.extended:
harness: bluetooth
extra_args: CONF_FILE="prj_extended.conf"
tags: bluetooth
extra_args:
- CONF_FILE="prj_extended.conf"
platform_allow:
- qemu_cortex_m3
- qemu_x86
- nrf52840dk/nrf52840
tags: bluetooth
integration_platforms:
- qemu_cortex_m3
- nrf52840dk/nrf52840
sample.bluetooth.observer.extended.bbc_microbit.bt_ll_sw_split:
harness: bluetooth
tags: bluetooth
extra_args:
- CONF_FILE="prj_extended.conf"
- EXTRA_CONF_FILE="debug.conf;overlay_bbc_microbit-bt_ll_sw_split.conf"
platform_allow:
- bbc_microbit
integration_platforms:
- bbc_microbit
5 changes: 3 additions & 2 deletions samples/bluetooth/observer/src/observer.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,11 @@ static struct bt_le_scan_cb scan_callbacks = {

int observer_start(void)
{
/* 30 ms continuous active scanning with duplicate filtering. */
struct bt_le_scan_param scan_param = {
.type = BT_LE_SCAN_TYPE_PASSIVE,
.type = BT_LE_SCAN_TYPE_ACTIVE,
.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
.interval = BT_GAP_SCAN_FAST_INTERVAL,
.interval = BT_GAP_SCAN_FAST_INTERVAL_MIN,
.window = BT_GAP_SCAN_FAST_WINDOW,
};
int err;
Expand Down
21 changes: 18 additions & 3 deletions subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,12 @@ static void isr_tx(void *param)
radio_pkt_rx_set(node_rx->pdu);

/* assert if radio packet ptr is not set and radio started rx */
LL_ASSERT(!radio_is_ready());
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
LL_ASSERT_MSG(!radio_is_address(), "%s: Radio ISR latency: %u", __func__,
lll_prof_latency_get());
} else {
LL_ASSERT(!radio_is_address());
}

#if defined(CONFIG_BT_CTLR_PRIVACY)
if (ull_filter_lll_rl_enabled()) {
Expand Down Expand Up @@ -1211,7 +1216,12 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
radio_pkt_tx_set(pdu_tx);

/* assert if radio packet ptr is not set and radio started tx */
LL_ASSERT(!radio_is_ready());
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
LL_ASSERT_MSG(!radio_is_address(), "%s: Radio ISR latency: %u", __func__,
lll_prof_latency_get());
} else {
LL_ASSERT(!radio_is_address());
}

if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
lll_prof_cputime_capture();
Expand Down Expand Up @@ -1343,7 +1353,12 @@ static inline int isr_rx_pdu(struct lll_scan *lll, struct pdu_adv *pdu_adv_rx,
radio_pkt_tx_set(pdu_tx);

/* assert if radio packet ptr is not set and radio started tx */
LL_ASSERT(!radio_is_ready());
if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
LL_ASSERT_MSG(!radio_is_address(), "%s: Radio ISR latency: %u", __func__,
lll_prof_latency_get());
} else {
LL_ASSERT(!radio_is_address());
}

if (IS_ENABLED(CONFIG_BT_CTLR_PROFILE_ISR)) {
lll_prof_cputime_capture();
Expand Down
3 changes: 2 additions & 1 deletion subsys/bluetooth/controller/ll_sw/nordic/lll/lll_scan_aux.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ void lll_scan_aux_isr_aux_setup(void *param)
aux_start_us -= EVENT_JITTER_US;

start_us = radio_tmr_start_us(0, aux_start_us);
LL_ASSERT(start_us == (aux_start_us + 1U));
LL_ASSERT_MSG(start_us == (aux_start_us + 1U), "aux_offset %u us, start_us %u != %u",
aux_offset_us, start_us, (aux_start_us + 1U));

/* Setup header complete timeout */
hcto = start_us;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Execute ./bs_${BOARD_TS}_tests_bsim_bluetooth_host_adv_chain_prj_conf\
-v=${verbosity_level} -s=${simulation_id} -d=1 -testid=scan

Execute ./bs_2G4_phy_v1 -v=${verbosity_level} -s=${simulation_id} \
-D=2 -sim_length=10e6 $@
-D=2 -sim_length=11e6 $@

wait_for_background_jobs