From dc5a32f3b8bbc7420926a1b44161fc5b63a243d0 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Mon, 20 Jun 2022 16:16:22 +0200 Subject: [PATCH] nimble/ll: Make LL task stack size configurable This commit makes LL stack size configurable. Depending on compiler and platform default value may not be enough. It was reported that on nRF52840 90 words is not enough even if Ext Adv is disabled. To keep things simple lets just increase default stack size to 120 word for all usecases (with exception of nRF51 where defults to 96 bytes). --- babblesim/hw/bsp/nrf52_bsim/syscfg.yml | 1 + nimble/controller/src/ble_ll.c | 15 ++------------- nimble/controller/syscfg.yml | 5 +++++ nimble/drivers/nrf51/pkg.yml | 3 +++ nimble/drivers/nrf51/syscfg.yml | 21 +++++++++++++++++++++ 5 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 nimble/drivers/nrf51/syscfg.yml diff --git a/babblesim/hw/bsp/nrf52_bsim/syscfg.yml b/babblesim/hw/bsp/nrf52_bsim/syscfg.yml index 5a45e9d08..c73106f32 100644 --- a/babblesim/hw/bsp/nrf52_bsim/syscfg.yml +++ b/babblesim/hw/bsp/nrf52_bsim/syscfg.yml @@ -72,3 +72,4 @@ syscfg.vals.BLE_CONTROLLER: OS_CPUTIME_FREQ: 32768 OS_CPUTIME_TIMER_NUM: 5 BLE_LL_RFMGMT_ENABLE_TIME: 1500 + BLE_LL_STACK_SIZE: 4000 diff --git a/nimble/controller/src/ble_ll.c b/nimble/controller/src/ble_ll.c index b4de889ed..cb6a6dc4f 100644 --- a/nimble/controller/src/ble_ll.c +++ b/nimble/controller/src/ble_ll.c @@ -358,21 +358,10 @@ static void ble_ll_event_dbuf_overflow(struct ble_npl_event *ev); #endif #if MYNEWT - -#if BABBLESIM -#define BLE_LL_STACK_SIZE (4000) -#else /* The BLE LL task data structure */ -#if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_EXT_ADV) -#define BLE_LL_STACK_SIZE (120) -#else -#define BLE_LL_STACK_SIZE (90) -#endif -#endif - struct os_task g_ble_ll_task; -OS_TASK_STACK_DEFINE(g_ble_ll_stack, BLE_LL_STACK_SIZE); +OS_TASK_STACK_DEFINE(g_ble_ll_stack, MYNEWT_VAL(BLE_LL_STACK_SIZE)); #endif /* MYNEWT */ @@ -1991,7 +1980,7 @@ ble_ll_init(void) /* Initialize the LL task */ os_task_init(&g_ble_ll_task, "ble_ll", ble_ll_task, NULL, MYNEWT_VAL(BLE_LL_PRIO), OS_WAIT_FOREVER, g_ble_ll_stack, - BLE_LL_STACK_SIZE); + MYNEWT_VAL(BLE_LL_STACK_SIZE)); #else /* diff --git a/nimble/controller/syscfg.yml b/nimble/controller/syscfg.yml index 841380f90..45fb461fe 100644 --- a/nimble/controller/syscfg.yml +++ b/nimble/controller/syscfg.yml @@ -493,6 +493,11 @@ syscfg.defs: range: 1..257 value: 32 + BLE_LL_STACK_SIZE: + description: > + This is the stack size for LL task. + value: 120 + syscfg.vals.BLE_LL_CFG_FEAT_LL_EXT_ADV: BLE_LL_CFG_FEAT_LE_CSA2: 1 BLE_HW_WHITELIST_ENABLE: 0 diff --git a/nimble/drivers/nrf51/pkg.yml b/nimble/drivers/nrf51/pkg.yml index 816a56355..9311093b9 100644 --- a/nimble/drivers/nrf51/pkg.yml +++ b/nimble/drivers/nrf51/pkg.yml @@ -29,3 +29,6 @@ pkg.apis: ble_driver pkg.deps: - nimble - nimble/controller + +# allows to override nimble/controller settings +pkg.subpriority: 1 diff --git a/nimble/drivers/nrf51/syscfg.yml b/nimble/drivers/nrf51/syscfg.yml new file mode 100644 index 000000000..451742a61 --- /dev/null +++ b/nimble/drivers/nrf51/syscfg.yml @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + + +syscfg.vals.!BLE_LL_CFG_FEAT_LL_EXT_ADV: + BLE_LL_STACK_SIZE: 96