-
Notifications
You must be signed in to change notification settings - Fork 7.6k
External PSRAM not supported? #5751
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
I think the root cause is that behavior of some IDF drivers depends on I think the solution for this problem is to enable |
@SuGlider PTAL on this related issue. |
Unfortunatelly 2.0.0 is not availble to PlaformIO at this moment. But it can be used with Arduino IDE. I created a repository with a new Arduino Core 2.0.0 that can be tested. https://github.com/espressif/arduino-esp32/tree/mem-optimized In order to install it as a separated board for testing, please follow the instructions from
In case it works fine for a number of users, we will commit it for the next ESP32 Arduino release. |
Actually, I figured out how to get arduino version 2.0.0 for the esp-idf by modifying my ini file: platform = https://github.com/platformio/platform-espressif32.git#feature/arduino-upstream
platform_packages =
framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.0
board = esp-wrover-kit
framework = arduino So far it works with a couple tweaks to the existing code..... |
Hi! I've tried your solution and heap haven't increased compared to pre-2.0.0 version :( |
You still have to call The default is to make all malloc calls use internal heap. The argument is the smallest allocation that would still be allocated on internal heap. Also I am not sure what the |
@jgamble-simple For more information: |
It looks like
and it fails when |
WiFiClientSecure is using the hardware accelerated encryption functions. AFAIK, there is no way to use the PSRAM to feed/collect the hardware accelerator. There is a way to use DMA with the HW AES, so it might be possible to keep this off the heap, but that would be beyond my skills, and would likely need some changes in IDF. |
Note that mbedTLS memory allocation policy can be configured, currently it is fixed to "internal RAM": https://github.com/espressif/esp32-arduino-lib-builder/blob/51a3ba2bcd1eaad61ff9d67de5cc93b5baeeb9f8/sdkconfig.esp32#L1152-L1155 |
Very interesting. I may have to play around with that at some point. |
I've just checked it (
and
Gives the same heap size... |
@mrdc Could you please clarify where have you specified |
Sure, here you go:
Not yet, have to check first how to do it :) |
on commit deacf43 sdkconfig modifications to build libraries with compile optimization to size (-Os) keep all the bootloaders with -Os and no boot messages changes max number of sockets from 10 to 16 disables LWIP "Experimental PPP and SLIP" because it adds about 60K to the binary size and it's not used in Arduino on commit a133257 sets WIFI LWIP to try first to allocate from SPIRAM on esp32 (this is esp32s2 default configuration) defines SPIRAM_MALLOC_ALWAYSINTERNAL to 4096 bytes on esp32 (same as default for esp32s2) disables SPIRAM_MALLOC_RESERVE_INTERNAL on both esp32 and esp32s2 to release more RAM to heap Related PRs in Arduino-ESP32: espressif/arduino-esp32#5789 espressif/arduino-esp32#5791 Related issue: espressif/arduino-esp32#5699 espressif/arduino-esp32#5474 espressif/arduino-esp32#5630 espressif/arduino-esp32#5751
@mrdc Please check the latest Arduino release v2.0.1RC1 that makes more heap sapce available, reduces the binary size and keeps https://github.com/espressif/arduino-esp32/releases/ |
Any update on this? |
I am seeing what I think is the same issue on Arduino Core 2.0.1 AND 2.0.3-rc1. Is anyone else? How sure are we that this is resolved?
|
I am 100% sure that it works on 2.0.0.... But I am not sure that it works on later versions, because I am still on 2.0.0 for my project @raphael-bmec-co |
@jgamble-simple thanks for this. I will role back to 2.0.0 and see if I am still seeing the crash. Appreciate the prompt feedback. |
Okay I have done days and days of testing on this and I am afraid it is 100% not working as detailed below. This seems like a huge stability issue to me. Using BLE+WiFi+PSRAM is a base use case for secure IoT applications. Hopefully this is something that is resolvable. The fact that it was working on 1.0.6 is promising. Can we reopen this issue or should I copy this across to a new issue? Issue detailsBoard: ESP32 Dev Module Device: Chip is ESP32-D0WD-V3 (revision 3); Auto-detected Flash size: 16MB Hardware Configuration: None Version: 1.0.6; 2.0.0; 2.0.1; 2.0.2; 2.0.3-RC1 IDE Name: Arduino IDE AND CLion with PIO OS: Windows 10 Flash frequency: 80 MHz PSRAM enabled: Yes Upload speed: 921600 Description 1.0.6: NO CRASH 2.0.0: Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed). Stack trace and decode
2.0.1: Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed). Stack trace and decode
2.0.2: Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed). Stack trace and decodeCore 0 register dump:
2.0.3-RC1: Guru Meditation Error: Core 0 panic'ed (Cache disabled but cached memory region accessed). Stack trace and decodeCore 0 register dump:
Sketch #include <WiFi.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
// Set to 1 to accelerate the crash. Set to zero to see a typical use case.
#define ACCELERATED_CRASH 1
// BLE defines.
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
void setup() {
// Comment this line and the crash does not happen.
heap_caps_malloc_extmem_enable(0);
// Serial.
Serial.begin(115200);
Serial.println("Starting BLE...");
// Minimum BLE simplified from example.
BLEDevice::init("Long name works now");
BLEServer *pServer = BLEDevice::createServer();
BLEService *pService = pServer->createService(SERVICE_UUID);
BLECharacteristic *pCharacteristic = pService->createCharacteristic(
CHARACTERISTIC_UUID,
BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
);
pCharacteristic->setValue("Hello World says Neil");
pService->start();
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
BLEDevice::startAdvertising();
Serial.println("Started BLE");
// Minimum WiFi.
Serial.println("Starting WiFi connection attempt...");
WiFi.begin("missing network", "password");
Serial.print("Available heap:");
Serial.println(ESP.getFreeHeap());
}
void loop() {
// This causes a crash to happen faster and may be useful for debugging.
// However the crash will happen even without this block.
if(ACCELERATED_CRASH){
while(!WiFi.isConnected()){
log_i("Attempting connection...");
WiFi.begin("missing network", "password");
delay(100);
}
}
delay(1000);
Serial.println("Loop");
}
Potentially related issues: |
@VojtechBartoska it seems like this may have it's root cause in the IDF according to these comments: espressif/esp-idf#7249 (comment) It seems like it may also be causing other issues with other components in the Arduino core. Are you able to give me some picture of if patches to the IDF are propagated into the Arduino cores and how long this might take? Thanks! |
Hello, rough realistic timeline is 1st week of May fixed in IDF and sync to Arduino. |
@VojtechBartoska thank you. We will follow-up early may to check on progress. Much appreciated. |
No, it is Arduino only used. Have you a example code which is failing? |
May you try flashmode |
Okay I have testing on two different devices now one with 8MB flash and one with 16MB. Not working as detailed below. Not sure where to go to from here. This is the trimmed down PIO file showing with partition files work and which don't:
This is the very simple sketch that I am testing with: #include "Arduino.h"
void setup() {
log_e("setup");
}
void loop() {
log_e("loop");
vTaskDelay(1000);
} |
reverting to:
They all work again. I think something is up with the Arduino Core build and/or the IDF? |
Thats your problem
Board partition size and partition scheme have to fit together. You can NOT define |
Tried your test sketch with a M5 stack core2. No problem.
M5 stack core2 has no PSRAM bug, so fixes not needed.
|
@SuGlider There is no issue |
agreed that should match and I will remove it if not needed however even if it matches the boot loop still happens. Taking a close look at the screenshot you send I noticed the sdk wasn't a 100% match. I took a closer look at the Changing the Changing the Does this make sense to you? Is this a valid setup to test IDF changes? Also I am using |
The difference is just minor. 826 is from yesterday and 828 from today. I tested both. Both work. |
And the |
It is only a minor update of how Platformio is catching the packages. Not related to the build process |
@Jason2866 my testing is showing: Not sure what the issue is there. I'll leave that one to you. Thanks for assisting with the PIO packages. Much appreciated. @VojtechBartoska the sad news is the IDF fix has not resolved the core issue. The test code I provided is still crashing with:
Where to from here? |
Yep, this is crashing! |
@VojtechBartoska just a ping on this. |
I got a bit lost in the exchange of messages. What is the final word? Is there an issue or not? |
@SuGlider I actually also missed that @Jason2866 had done a test on the actual issue. However, the test code @Jason2866 posted is not at all the test code I provided. Firstly, the issue occurs more quickly when a connection cannot be established and secondly it doesn't seem to happen if BLE is not enabled. Please test with the test code I provided. The issue is very much still there and has completely blocked our development for a few weeks now. Any assistance would be really really appreciated. Thanks. |
yes, orig. sketch is not working. @raphael-bmec-co In future please do not mix different issues in one issue report. Thx! |
I have compiled and tested the sketch from #5751 (comment) using Arduino IDE with a Partition Scheme = Huge APP (3MB No OTA/1MB SPIFFS). Issue confirmed. It seems to be some Memory Leak forced by @raphael-bmec-co - do you mind opeing a new issue for it. Please just copy paste #5751 (comment) - you can ssign me to the issue. The issue you describe is not related to this one. So, please let's close it and we start fresh in a new issue. |
@SuGlider and @Jason2866 100% agree. We went way off topic here trying to get the platform IO packages working. Sorry about that. I will open a new issue now. Thanks. |
Already working on the investigation of the issue. I'll report the findings there. |
Any news on this? I need to |
I can't see it solved. I also set heap_caps_malloc_extmem_enable() to 0 and i have no problem. No crash at all at anywhere. I just have no internal ram and i have my full ps ram doing nothing. I want the mbedtls and other things from psram. |
Arduino Core is pre-compiled with predefined settings that can be verified in the sdkconfig file. If other settings are necessary, the Core must be rebuilt or the project should move to an Arduino as an IDF Component model. |
Hardware:
Board: Custom board based on ESP32-WROVER-E
Core Installation version: 1.0.6
IDE name: Platform.io
PSRAM enabled: yes
Upload Speed: 230400
Computer OS: Windows 10 (Using wsl for uploading/platform.io)
Description:
Calling
heap_caps_malloc_extmem_enable(0)
causes a crash about 20% of the time when trying to connect to wifi, I have trimmed back my application to the bare min required to crash it. If I remove theheap_caps_malloc_extmem_enable
call then it works properly........Is this supposed to work? Or this crash expected?
Compiler Flags defined in platformio.ini:
Sketch:
Debug Messages:
The text was updated successfully, but these errors were encountered: