-
Notifications
You must be signed in to change notification settings - Fork 716
(Waiting for Toolchain fix): BLE stack don't compile after the last me-no.dev commit #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Ouch!!! This is not good. Tracking as #82 for the implications across both Arduino and ESP-IDF. |
Hello again! I'm not sure about what is happening in my software, I think I'm mixing apples with oranges and this doesn't work After the #82, I try to compile with arduino-esp32 without BLE support to check other parts of my system and it works fine
|
Howdy, unfortunately we are just plain "broke" on Arduino at the moment. The story in detail can be found in #82 but in summary ...
|
Ok, Neil thanks for the support |
The great news is that the Arduino ESP32 project has been updated. Please re-build your base Arduino ESP32 environment. The even better news is that the owner of that project has decided to include the BLE C++ classes as part of the distribution. So it is now baked in. Please re-test and let us now see where we stand. |
Hello Neil, I try with my software and doesn't work again, the error is similar to the previous failure
|
The symptom you are seeing seems close to #110 ... in your script/sketch ... do you have WiFi enabled as well? Do the samples that come with the BLE C++ classes work? |
Next, I try your examples That wasn't a deep test but they compile and using rRF connect software I can see the esp32 device and interact with it. |
Hello Neil, yes my software uses wifi and BLE simultaneously, I'm going to disconect wifi while BLE is working Thanks for the help |
Ok wifi disconnected, but another issue raises. I think your last comment in #110 is the key, and stack size is creating troubles when the code is a bit more complicated than a simple test.
|
Aha ... that's actually good news. But let's be sure that we now realize that we have two stories here. One is the problem running BLE and WiFi together which appears to be stack size that is hard-coded in Arduino BLE. The second issue, the one that I am going to address here, is the last problem you posted. The good news is that we've been working this one as #121 and just this morning made a major breakthrough ... to the point where good users like yourself can use it. What I'd like to suggest is that we don't talk about this current problem in this issue any more but instead let me encourage you to piggyback on #121 which was the first to report that issue. Looking forward to hearing what you think after reading #121. |
Hello Neil, after following your comments in #121 I've got my BLE working fine 👍 Best regards
|
I'm at work just now ... but first opportunity I get I'll be re-testing here with the increased stack size. What I have been trying to avoid doing is learning how to build the Arduino-ESP32 libraries from source. Ideally, I just wanted to be a "user" of those libraries and the BLE code becomes just a layer on top of them. However I'm re-thinking that notion. Last I looked, I had convinced myself that the error we had was as described in #110 which is the primary tracker for WiFi/BLE memory issues. What I believe is that the amount of stack space associated with the main task is hard-coded by the Arduino-ESP32 libraries before distribution of the Arduino-ESP32 environment. I can't remember off the top of my head what the previous value was but even 8192 may be too low. Since I am ignorant on how to build the Arduino-ESP32 libraries for testing, I hadn't attempt to try any tests to see what values would work. What I believe I must do now is take the hit and learn (and document) how to build the Arduino-ESP32 libraries here/locally ... so that I can make changes to the build myself so that I can then be specific about what values may be needed. This may take some time. |
Hello Neil, the previous size was 4096 Thanks for your great work here. |
What we have is a game of parts. Espressif makes the physical ESP32 chip. Espressif also has a software team that owns the ESP-IDF. Within that team there are individuals for toolchain, individuals for FreeRTOS, individuals for BLE ... and the list goes on. It is also my understand that the Arduino-ESP32 is also built by Espressif but by a distinct individual/team there. What that means to you and me is that when we want to write "BLE and WiFi" apps, these are layered upon layers upon layers ... for example BLE and WiFi live on top of Arduino-ESP32 which lives on top of ESP-IDF which lives (loosely) on top of FreeRTOS ... and at the bottom there is the hardware. What that implies is that a "problem" could be introduced (or need resolution) somewhere other than the layer in which we are working. This means that we need to collaborate between the layers. I'm pretty sure that the Arduino-ESP32 layer team would be happy to change the stack size ... but they are asking "To What?". And that becomes a question for thee and me. The correct answer is for us to tell them what stack size we need. However, we don't have a science for saying "we need 8K/12K/16K/20K etc etc" ... or do we ...? Within an ESP-IDF/Arduino/FreeRTOS application we can ask the runtime "tell me about the high water mark of stack used". What this means is that if we set the stack to be ... oh ... lets say 50K ... we could run up WiFi and BLE together ... let them cook for a while ... and then ASK the runtime, how much stack are you using or maximally used? This would give us some evidence for what we need. And in there is the puzzle ... in order to get that information, we need to set the stack to be ... say 50K. In order to achieve that ... we need to have the skills to be able to "tweak" the lower level layer (in this case Arduino-ESP32) to change the stack size. This requires that we re-built the Arduino-ESP32 libraries with the new stack. And that is something Ive never done before. It may be very easy or it may be rocket science ... I haven't had time to go look yet. And that's the next piece of territory that needs explored. Once I have the size and shape of what it looks like to build the Arduino-ESP32 libraries from source and make tweaked changes ... I'll be able to run experiments to determine if stack size is what is needed ... and if not ... what else may be at fault. |
@nkolban just add a new project, import Arduino as component and call the WiFi and BLE API. Tweak the "magic" number and tell me the result (you can even use the sdkconfig bundled in arduino/tools/sdk in order to have the same config as what is used by Arduino). There is nothing else fancy :) Arduino is just a component in IDF and does not require any extra care ;) |
Following mr @me-no-dev instructions, I created a new ESP-IDF project called
I then entered the Arduino-esp32 project and performed a:
This created an environment I could use. I then copied the "sdkconfig" from the Arduino project to my own sdkconfig so we would be the same. I upped the stack size to 20K and built and ran. Unfortunately, it continued to crash. I enabled gdb debugging and got the following back trace:
At first I thought this is the same error we had been seeing ... but now that I look much closer ... even though we are still failing in
Now I'm going to hit the books to see if we can get more diagnostics from this error. |
Its the thing, ive got same or simmilar error on esp-idf stack (no arduino). |
Here is what I'm starting to find ... 3 permutations:
My digging seems to be showing that we are running out of memory when trying to create tasks. So I switched on verbose boot logging. This has shown me the following information:
Summarizing the interesting lines:
What I might now be sensing is that we might be needing to increase the stack size for both BLE and WiFi to run ... but the mere presence of BLE and WiFi together linked into the environment results in there being not enough RAM for them to be together. My gut is telling me that DRAM is where task stacks may be being allocated from. I'm also remembering (thought can't find it) a forum or chat post which talked about the latest ESP-IDF and toolchain requiring an extra 20K of RAM to support C++ exception processing. |
|
Have a look at this guys ... espressif/esp-idf#1072 ... this may be part of the story ... I'm not yet sure if the "patch/fix" mentioned in 1072 is available yet ... but it does sniff close. |
You can try, for debug purpose, to switch in menuconfig |
Now my test program crash at https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLETests/SampleClientWithWiFi.cpp#L110 Most likely its still low memory issue because trace log leads me to |
Guys, the problem is fixed. |
The problem is fixed for me too. Best regards |
Closing for now. Re-open as needed. |
Dang. I'm getting the bootloop again when ble/wifi enabled. I'm revisiting code I have from last year to see if the ble code size had reduced. I had downloaded an updated core in march. I noticed that #define CONFIG_MAIN_TASK_STACK_SIZE is now 4096. it used to be 8192 and that had fixed the issue. Do you know when was this changed back? Looked through the history. me-no-dev change it back on October 21st. from 8192 to 4096. Neil, there are so many threads on this issues. Any idea if the root cause was ever found? Are there other defines that fix this like the task stack size? I'm spinning up tasks in my code. Thanks for any input. |
Apparently the stack size was changed in the Arduino environment 6 months ago ... see here: https://github.com/espressif/arduino-esp32/pull/767/files |
Yes, I updated my post after looking at the history. Sorry about that. Still weird stuff going on. My buddy in the UK has same code base as me but he builds under IDF and gets past the bootloader loop I don’t. I’ve compared sdkconfigs and don’t see any real differences yet, still looking as he uses a different esp32 board so digging in there at the moment.
Read your post about it may be related to creating tasks I think you may be right. I have other code with wifi/ble both enabled and it runs fine but I don’t use any tasks. In my current code I use tasks. However, I commented out both calls to setup the tasks and it still fails at boot going into a loop even after a clean build. Weird.
From: Neil Kolban <[email protected]>
Sent: Monday, April 23, 2018 10:31 AM
To: nkolban/esp32-snippets <[email protected]>
Cc: ifrew <[email protected]>; Comment <[email protected]>
Subject: Re: [nkolban/esp32-snippets] (Waiting for Toolchain fix): BLE stack don't compile after the last me-no.dev commit (#81)
Apparently the stack size was changed in the Arduino environment 6 months ago ... see here:
https://github.com/espressif/arduino-esp32/pull/767/files<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fespressif%2Farduino-esp32%2Fpull%2F767%2Ffiles&data=02%7C01%7C%7Ca180d689d1c14b20982908d5a9400ad6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636601014875131413&sdata=hxKudTxMG%2BhTE9IPUExREaqJ4XXbPY5IrvQ63L%2FWovA%3D&reserved=0>
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnkolban%2Fesp32-snippets%2Fissues%2F81%23issuecomment-383657450&data=02%7C01%7C%7Ca180d689d1c14b20982908d5a9400ad6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636601014875131413&sdata=SCNS9RG3qOjb9uP12LILAzLVjNE5VuV64fCCoCl8BYE%3D&reserved=0>, or mute the thread<https://eur02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAL-x4C35tbrpj17VKGMiJ10-iPk8sVY4ks5trg_tgaJpZM4Phh0l&data=02%7C01%7C%7Ca180d689d1c14b20982908d5a9400ad6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636601014875131413&sdata=KhqXzN2dB%2FmvEtAnftr2%2BfupiErTOGEvW2pfirMiqFs%3D&reserved=0>.
|
Hello Neil, after the last commit of arduino-esp32 there are some troubles with your library
Best wishes and thanks for your great work
Editor: Moved to Pastebin: https://pastebin.com/GT41096V
The text was updated successfully, but these errors were encountered: