From 13a8bcb7cd10050a9fa42236a0471351fd5bea27 Mon Sep 17 00:00:00 2001 From: Rahul Tank Date: Thu, 12 May 2022 10:58:18 +0530 Subject: [PATCH] Nimble/host: Resolved crash of esp_timer on esp32h2 Per new architecture, event structure elements need to be initialized before assigning to callout. Modified the existing sequence to fix this. --- porting/npl/freertos/include/nimble/nimble_npl_os.h | 3 --- porting/npl/freertos/src/npl_os_freertos.c | 12 ++++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/porting/npl/freertos/include/nimble/nimble_npl_os.h b/porting/npl/freertos/include/nimble/nimble_npl_os.h index e4c985c28..52573cdd0 100644 --- a/porting/npl/freertos/include/nimble/nimble_npl_os.h +++ b/porting/npl/freertos/include/nimble/nimble_npl_os.h @@ -61,9 +61,6 @@ struct ble_npl_event; typedef void ble_npl_event_fn(struct ble_npl_event *ev); struct ble_npl_event { -#if CONFIG_BT_NIMBLE_USE_ESP_TIMER - ble_npl_event_fn *fn; -#endif void *event; }; diff --git a/porting/npl/freertos/src/npl_os_freertos.c b/porting/npl/freertos/src/npl_os_freertos.c index 4d130c778..6cd9f68a2 100644 --- a/porting/npl/freertos/src/npl_os_freertos.c +++ b/porting/npl/freertos/src/npl_os_freertos.c @@ -681,10 +681,9 @@ IRAM_ATTR npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_e BLE_LL_ASSERT(callout); memset(callout, 0, sizeof(*callout)); + ble_npl_event_init(&callout->ev, ev_cb, ev_arg); #if CONFIG_BT_NIMBLE_USE_ESP_TIMER - callout->ev.fn = ev_cb; - callout->ev.event = ev_arg; callout->evq = evq; esp_timer_create_args_t create_args = { @@ -703,6 +702,8 @@ IRAM_ATTR npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_e } else { callout = (struct ble_npl_callout_freertos *)co->co; BLE_LL_ASSERT(callout); + callout->evq = evq; + ble_npl_event_init(&callout->ev, ev_cb, ev_arg); } #else @@ -712,10 +713,9 @@ IRAM_ATTR npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_e BLE_LL_ASSERT(callout); memset(callout, 0, sizeof(*callout)); + ble_npl_event_init(&callout->ev, ev_cb, ev_arg); #if CONFIG_BT_NIMBLE_USE_ESP_TIMER - callout->ev.fn = ev_cb; - callout->ev.event = ev_arg; callout->evq = evq; esp_timer_create_args_t create_args = { @@ -734,11 +734,11 @@ IRAM_ATTR npl_freertos_callout_init(struct ble_npl_callout *co, struct ble_npl_e else { callout = (struct ble_npl_callout_freertos *)co->co; BLE_LL_ASSERT(callout); + callout->evq = evq; + ble_npl_event_init(&callout->ev, ev_cb, ev_arg); } #endif - callout->evq = evq; - ble_npl_event_init(&callout->ev, ev_cb, ev_arg); } void