BLE and SPI Flash Crash

kostyan5
Posts: 50
Joined: Mon Mar 06, 2017 3:16 pm

BLE and SPI Flash Crash

Postby kostyan5 » Thu Mar 16, 2017 5:28 pm

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?

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: BLE and SPI Flash Crash

Postby ESP_igrr » Fri Mar 17, 2017 12:12 am

Seems like pvPortMalloc ends up being placed into cached region, which should definitely not happen (it should be in IRAM). Will take a look.

kostyan5
Posts: 50
Joined: Mon Mar 06, 2017 3:16 pm

Re: BLE and SPI Flash Crash

Postby kostyan5 » Fri Mar 17, 2017 2:03 pm

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.

Who is online

Users browsing this forum: No registered users and 131 guests