Page 1 of 1

BLE and SPI Flash Crash

Posted: Thu Mar 16, 2017 5:28 pm
by kostyan5
It appears that if I enable BLE and then do some flash operations (SPIFFS file write or read) I get Illegal Instruction exception:

Guru Meditation Error of type IllegalInstruction occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x400d2eb2 PS : 0x00060b31 A0 : 0x8000beb2 A1 : 0x3ffc04e0
0x400d2eb2: pvPortMalloc at /Users/Kon/Armada/GitHub/armada-firmware/esp-idf/components/esp32/./heap_alloc_caps.c:305

esp-idf documentation says that accessing instructions from flash is disabled when spi flash operation is in progress. However, an ISR can potentially read from flash, which I suspect BLE stack is doing.

If I don't enable BLE, all flash operations work just fine. If I don't do flash, BLE works just fine. Thoughts?

Re: BLE and SPI Flash Crash

Posted: Fri Mar 17, 2017 12:12 am
by ESP_igrr
Seems like pvPortMalloc ends up being placed into cached region, which should definitely not happen (it should be in IRAM). Will take a look.

Re: BLE and SPI Flash Crash

Posted: Fri Mar 17, 2017 2:03 pm
by kostyan5
Adding IRAM_ATTR to pvPortMalloc() and pvPortMallocCaps() fixed the crash. Not sure if this is the proper way but I'm assuming espressif will put out a formal fix. Thanks.