Skip to content

Commit 5341e18

Browse files
Copiloth2zero
authored andcommitted
[Bugfix] Arduino 3.3.11 build/crash with esp32 c5/c6 vairants.
1 parent 5a6a85d commit 5341e18

6 files changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ jobs:
185185
- "examples/NimBLE_Server"
186186
variant:
187187
- esp32
188+
- esp32c5
188189
- esp32c3
189190
- esp32s3
190191
- esp32c6

src/nimble/esp_port/esp-hci/src/na_hci_transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#ifdef ESP_PLATFORM
88
#include "syscfg/syscfg.h"
9-
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT && CONFIG_BT_BLUEDROID_ENABLED
9+
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
1010

1111
#include <stdio.h>
1212
#include <string.h>

src/nimble/esp_port/esp_ipc/src/hci_esp_ipc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66

77
#include <syscfg/syscfg.h>
88
#ifdef ESP_PLATFORM
9-
# if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && \
10-
!defined(CONFIG_IDF_TARGET_ESP32S3) && CONFIG_BT_BLUEDROID_ENABLED
9+
# if !defined(CONFIG_IDF_TARGET_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3)
1110

1211
#include <assert.h>
1312
#include <string.h>

src/nimble/porting/nimble/include/os/os_mempool.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@
3232
#include "nimble/porting/nimble/include/os/os.h"
3333
#include "nimble/porting/nimble/include/os/queue.h"
3434

35+
#if defined(ARDUINO_ARCH_ESP32) && __has_include("esp_arduino_version.h")
36+
#include "esp_arduino_version.h"
37+
#endif
38+
39+
#if defined(ESP_ARDUINO_VERSION)
40+
/* Arduino ESP32 core 3.3.11+ dropped the legacy r_ prefix for these mempool symbols. */
41+
#define NIMBLE_OS_MEMPOOL_USE_ROM_R_PREFIX (ESP_ARDUINO_VERSION < ESP_ARDUINO_VERSION_VAL(3, 3, 11))
42+
#else
43+
#define NIMBLE_OS_MEMPOOL_USE_ROM_R_PREFIX 1
44+
#endif
45+
3546
#ifdef __cplusplus
3647
extern "C" {
3748
#endif
@@ -170,7 +181,7 @@ typedef __uint128_t os_membuf_t;
170181
#define OS_MEMPOOL_BYTES(n,blksize) \
171182
(sizeof (os_membuf_t) * OS_MEMPOOL_SIZE((n), (blksize)))
172183

173-
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED
184+
#if SOC_ESP_NIMBLE_CONTROLLER && CONFIG_BT_CONTROLLER_ENABLED && NIMBLE_OS_MEMPOOL_USE_ROM_R_PREFIX
174185
/**
175186
* Initialize a memory pool.
176187
*
@@ -405,6 +416,9 @@ os_error_t os_memblock_put(struct os_mempool *mp, void *block_addr);
405416
}
406417
#endif
407418

419+
/* Keep this version gate local to this header. */
420+
#undef NIMBLE_OS_MEMPOOL_USE_ROM_R_PREFIX
421+
408422
#endif /* _OS_MEMPOOL_H_ */
409423

410424

src/nimble/porting/nimble/src/nimble_port.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ esp_err_t esp_nimble_init(void)
9595
os_mempool_module_init();
9696
os_msys_init();
9797

98-
#elif CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT && CONFIG_BT_BLUEDROID_ENABLED
98+
#elif CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
9999
hci_transport_deinit();
100100
na_hci_transport_init(HCI_TRANSPORT_VHCI);
101101
int na_npl_freertos_mempool_init(void);
@@ -137,8 +137,7 @@ esp_err_t esp_nimble_deinit(void)
137137

138138
ble_transport_ll_deinit();
139139

140-
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT && CONFIG_BT_BLUEDROID_ENABLED
141-
na_hci_transport_deinit();
140+
#if CONFIG_BT_LE_CONTROLLER_NPL_OS_PORTING_SUPPORT
142141
void na_npl_freertos_mempool_deinit(void);
143142
na_npl_freertos_mempool_deinit();
144143
ble_npl_eventq_deinit(&g_eventq_dflt);

src/nimble/porting/npl/freertos/src/npl_os_freertos.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,6 @@ static os_membuf_t *ble_freertos_mutex_buf = NULL;
661661

662662
static uint16_t ble_freertos_total_event_cnt = 0;
663663

664-
#if CONFIG_BT_BLUEDROID_ENABLED
665664
int na_npl_freertos_mempool_init(void)
666665
{
667666
int rc = -1;
@@ -818,5 +817,3 @@ na_npl_freertos_eventq_init(struct ble_npl_eventq *evq)
818817
}
819818
}
820819
#endif /* CONFIG_BT_BLUEDROID_ENABLED */
821-
822-
#endif

0 commit comments

Comments
 (0)