Closed Laxilef closed 2 weeks ago
Hello @Laxilef, thanks for opening this issue. Yes, the new arduino core has broken this library for now and I will fix this in the future. It will still work but it requires modifying your application to do the BLE related calls from a task running on the same core as the main NimBLE stack task like so:
void BLETask(void* param) {
for(;;) {
..BLE STUFF GOES HERE..
delay(1); // always delay in the loop to allow other tasks to run
}
vTaskDelete(NULL); // should never get here
}
void setup() {
...YOUR INIT CODE...
xTaskCreatePinnedToCore(
BLETask, /* Function to implement the task */
"BLETask", /* Name of the task */
4096, /* Stack size in bytes */
NULL, /* Task input parameter */
2, /* Priority of the task (set higher than loop) */
nullptr, /* Task handle. */
CONFIG_BT_NIMBLE_PINNED_TO_CORE); /* Core where main nimble task runs */
}
void loop() {
delay(1);
}
Yeah, it works! Thanks @h2zero :)
p.s. did you find any other bugs with 3.x.x?
Unrelated, however, ESP-NOW had some breaking changes made. Espressif has noted them, but the Arduino wrapper team missed it.
@Laxilef Im not aware of anything else, I just knew the build broke due to IPC changes.
I've pinned this for everyone to comment on their experience and to make the workaround visible.
I will wait for the fix and go back to esp32 Version 2.
Please test #681 and let me know if it resolves this for you all.
Please test #681 and let me know if it resolves this for you all.
The change resolves the issue, I am now able to scan without getting the Core 0 panic'ed
error đź‘Ť
On a ESP32-Zero. with esp32 3.0.1
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x403778d1
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x508
load:0x403c9700,len:0x4
load:0x403c9704,len:0xad0
load:0x403cc700,len:0x29e4
entry 0x403c9880
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (ipc0)
Core 0 register dump:
PC : 0x4038344e PS : 0x00060036 A0 : 0x80381940 A1 : 0x3fcf0d00
A2 : 0x3fc98a5c A3 : 0xffffffff A4 : 0x00060023 A5 : 0x00060023
A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x803835e1 A9 : 0x3fc9b240
A10 : 0x00060023 A11 : 0x00000001 A12 : 0x00060021 A13 : 0x00000001
A14 : 0x03c98958 A15 : 0x3fc98958 SAR : 0x00000004 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff
Backtrace: 0x4038344b:0x3fcf0d00 0x4038193d:0x3fcf0d30 0x403837d8:0x3fcf0d60 0x403837ce:0xa5a5a5a5 |<-CORRUPTED
ELF file SHA256: 0c670f66a2a5e575
Same on ESP32-S3WROOM-1 Dev board
Using the last library with the Arduino Nano ESP32 board that still uses esp32 2.0.13 gave these errors during compiling
C:\\Users\\ednie\\AppData\\Local\\Temp\\arduino\\sketches\\8800A92742734354C2C4BFDC9F9ADF6B/ESP32Arduino_WordClockV029.ino.elf"
c:/users/ednie/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\ednie\AppData\Local\Temp\arduino\sketches\8800A92742734354C2C4BFDC9F9ADF6B\sketch\objs.a(ESP32Arduino_WordClockV029.ino.cpp.o):(.literal._Z15StartBLEServicev+0x20): undefined reference to `NimBLEAdvertising::start(unsigned int, void (*)(NimBLEAdvertising*), NimBLEAddress*)'
c:/users/ednie/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\ednie\AppData\Local\Temp\arduino\sketches\8800A92742734354C2C4BFDC9F9ADF6B\sketch\objs.a(ESP32Arduino_WordClockV029.ino.cpp.o): in function `StartBLEService()':
C:\Users\ednie\Documents\Files\Arduino\Arduino_Nano-ESP32-WordClock\ESP32Arduino_WordClockV029/ESP32Arduino_WordClockV029.ino:2591: undefined reference to `NimBLEAdvertising::start(unsigned int, void (*)(NimBLEAdvertising*), NimBLEAddress*)'
collect2.exe: error: ld returned 1 exit status
@ednieuw Have you tested with the PR mentioned above ? #679
Probably not at first but now I downloaded NimBLE-Arduino-nimble-1.5.0.zip With the ESP32-S3-Zero the program start and initializes the serial port, Preferences storage and Neopixels
I use BLE-UART from your examples I as remember well will try the Arduino Nano ESP32 now workinf with esp32 2.0.13
Rebooting... ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x2b (SPI_FAST_FLASH_BOOT) Saved PC:0x403778d9 SPIWP:0xee mode:DIO, clock div:1 load:0x3fce3818,len:0x508 load:0x403c9700,len:0x4 load:0x403c9704,len:0xad0 load:0x403cc700,len:0x29e4 entry 0x403c9880 Serial started Mem.Checksum = 25065 Setting loaded E (794) BLE_INIT: hci inits failed
E (794) BLE_INIT: controller disable failed
E (795) BLE_INIT: controller deinit failed
E (795) BLE_INIT: nimble host init failed
assert failed: xQueueReceive queue.c:1475 (( pxQueue ))
Backtrace: 0x403772c6:0x3fcedb10 0x4037d4d9:0x3fcedb30 0x403832a1:0x3fcedb50 0x4037dbcb:0x3fcedc80 0x420169d1:0x3fcedcc0 0x4037542f:0x3fcedcf0 0x42005e72:0x3fcedd10
You BLE-uart example also gives the same error as above and the Arduino Nano ESP32 does not initializes the BLE serial and simply stops without rebooting
BTW The Nano was also rebooting FYI I used this piece of code (from the Espressif migration 2.x -> 3.x document) to make a library compatible for both esp32 versions
#ifdef ESP_ARDUINO_VERSION_MAJOR
#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0)
// Code for version 3.x
#else
// Code for version 2.x
#ifdef ESP32
#else
#endif
#endif
#endif
Sorry I mentioned the wrong PR... the fix should be in #681
Now I have NimBLE-Arduino-release-1.4.zip
I tested that this morning but I will test it again to be sure because there is also NimBLE-Arduino-master.zip in my download folder
From: h2zero @.> Sent: Tuesday, 11 June 2024 15:43 To: h2zero/NimBLE-Arduino @.> Cc: Ed Nieuwenhuys @.>; Mention @.> Subject: Re: [h2zero/NimBLE-Arduino] ESP32-S3 crash with arduino-esp32 core 3.x.x (Issue #676)
Sorry I mentioned the wrong PR... the fix should be in #681 https://github.com/h2zero/NimBLE-Arduino/pull/681
— Reply to this email directly, view it on GitHub https://github.com/h2zero/NimBLE-Arduino/issues/676#issuecomment-2160802565 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC42NIAR3IXQGBQFSJSXDQDZG35GHAVCNFSM6AAAAABI4XUVLCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRQHAYDENJWGU . You are receiving this because you were mentioned. https://github.com/notifications/beacon/AC42NIDUOS5GT76H64R6J5LZG35GHA5CNFSM6AAAAABI4XUVLCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUAZM5QK.gif Message ID: @. @.> >
No. still rebooting checked esp_nible_hci.c to be sure I had the right library version Saw all the Github changes. For example at line 75
/* Added; Called from the core NimBLE is running on, not used for unicore */
#ifndef CONFIG_FREERTOS_UNICORE
void ble_hci_trans_hs_cmd_tx_on_core(void *arg)
{
// Ugly but necessary as the arduino core does not provide enough IPC stack for variables.
esp_vhci_host_send_packet((uint8_t*)arg, *((uint8_t*)arg + 3) + 1 + BLE_HCI_CMD_HDR_LEN);
}
#endif
Rebooting...
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4037790d
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3818,len:0x508
load:0x403c9700,len:0x4
load:0x403c9704,len:0xad0
load:0x403cc700,len:0x29e4
entry 0x403c9880
Serial started
Mem.Checksum = 25065
Setting loaded
Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (ipc0)
Core 0 register dump:
PC : 0x403835aa PS : 0x00060036 A0 : 0x80381a9c A1 : 0x3fcf0d00
A2 : 0x3fc986ac A3 : 0xffffffff A4 : 0x00060023 A5 : 0x00060023
A6 : 0xb33fffff A7 : 0xb33fffff A8 : 0x8038373d A9 : 0x3fc9ae00
A10 : 0x00060023 A11 : 0x00000001 A12 : 0x00060021 A13 : 0x00000001
A14 : 0x03c985a8 A15 : 0x3fc985a8 SAR : 0x00000004 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40056f5c LEND : 0x40056f72 LCOUNT : 0xffffffff
Backtrace: 0x403835a7:0x3fcf0d00 0x40381a99:0x3fcf0d30 0x40383934:0x3fcf0d60 0x4038392a:0xa5a5a5a5 |<-CORRUPTED
ELF file SHA256: 10f61709dc4a6b25
`
If you still have this:
/* Added; Called from the core NimBLE is running on, not used for unicore */
#ifndef CONFIG_FREERTOS_UNICORE
void ble_hci_trans_hs_cmd_tx_on_core(void *arg)
{
// Ugly but necessary as the arduino core does not provide enough IPC stack for variables.
esp_vhci_host_send_packet((uint8_t*)arg, *((uint8_t*)arg + 3) + 1 + BLE_HCI_CMD_HDR_LEN);
}
#endif
in esp_nible_hci.c then you do not have the PR branch as that is what gets removed there.
Can you send the library bij mail to me or direct me how to download it?
Please test #681 and let me know if it resolves this for you all.
Tested on esp32 s3, core 3.0.1, esp-idf v5.1.4, works great
@ednieuw https://github.com/h2zero/NimBLE-Arduino/archive/refs/heads/remove-ipc.zip
Thanks for the link Laxilef! I still can not find it in Github but with your link I got success The code works on ESP32 S3 with core 3.0.1
But now an error with esp32 core 2.0.13 compiling for Arduino Nano ESP32 Would be nice if it work on both versions.
c:/users/ednie/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\ednie\AppData\Local\Temp\arduino\sketches\8800A92742734354C2C4BFDC9F9ADF6B\sketch\objs.a(ESP32Arduino_WordClockV029.ino.cpp.o):(.literal._Z15StartBLEServicev+0x20): undefined reference to `NimBLEAdvertising::start(unsigned int, void (*)(NimBLEAdvertising*), NimBLEAddress*)'
c:/users/ednie/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32s3-elf-gcc/esp-2021r2-patch5-8.4.0/bin/../lib/gcc/xtensa-esp32s3-elf/8.4.0/../../../../xtensa-esp32s3-elf/bin/ld.exe: C:\Users\ednie\AppData\Local\Temp\arduino\sketches\8800A92742734354C2C4BFDC9F9ADF6B\sketch\objs.a(ESP32Arduino_WordClockV029.ino.cpp.o): in function `StartBLEService()':
C:\Users\ednie\Documents\Files\Arduino\Arduino_Nano-ESP32-WordClock\ESP32Arduino_WordClockV029/ESP32Arduino_WordClockV029.ino:2587: undefined reference to `NimBLEAdvertising::start(unsigned int, void (*)(NimBLEAdvertising*), NimBLEAddress*)'
collect2.exe: error: ld returned 1 exit status
@ednieuw have you set CONFIG_BT_NIMBLE_ROLE_BROADCASTER_DISABLED
to 1 somewhere?
Please try one of the server examples with default config and let me know if you have this error.
No. Did not changed anything. Used this library version https://github.com/h2zero/NimBLE-Arduino/archive/refs/heads/remove-ipc.zip If there is another version to test give me the link.
if you like it I can change esp_nible_hci.c with the #if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) compile options mentioned before and test it with the different esp32 core versions and mcu’s It is patch work but seems a safe change. If it works (-:
@ednieuw I'm not able to reproduce this issue, there must be something in your environment causing this.
It could be a cache problem. I suspect the arduino IDE2 is not clearing it completely when switching boards I combined the two versions and separated them with the #ifdefs. That did not work. I had to leave home but will try tomorrow to clear the cache when switching between the two core versions. I will update you about the result
That sounds likely, please let me know. I recommend switching to PlatformIO in vscode as it makes this sort of thing much easier to manage.
Succes. Both ESP32 version V2.0 and v3.0 work now. I tried the ESP32-S3 with V3.0.1 and the Arduino Nano ESP32 with the Arduino version V2.0 13. I will give platformIO a new try. I was not very happy with it a few years ago. Thanks for your support
Great! thanks for the update! I will close this now.
Hi I'm using NimBLE-Arduino 1.4.1 with arduino-esp32 core 2.x.x and it works great, but now I'm trying to upgrade to arduino-esp32 core 3.x.x and when I call the
NimBLEClient::connect()
method I get a crash. The error always looks like this:I tried increasing the task stack to 50k, it doesn't help. Platformio.ini config:
This is very similar to #649. Does this mean that the library is currently not compatible with arduino-esp32 core 3.x.x?