Hi,
I write a small c++ code, with spi read and write.
The code throw error - "InstrFetchProhibited occured".
I read http://esp-idf.readthedocs.io/en/latest ... flash.html page.
This page speak - "Concurrency Constraints".
I tried a lot, but unsuccessfully.
What do you suggest?
Thanks,
zs
SPI Flash - InstrFetchProhibited occured
-
- Posts: 9
- Joined: Mon Feb 29, 2016 8:09 am
Re: SPI Flash - InstrFetchProhibited occured
I would suggest posting a fragment of code showing the exact statement that was being executed when the exception was caught.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 9
- Joined: Mon Feb 29, 2016 8:09 am
Re: SPI Flash - InstrFetchProhibited occured
Sorry for small info!
Some helper function:
Config class:
Some helper function:
Code: Select all
#include <esp_spi_flash.h>
#include <rom/spi_flash.h>
#include "../cache_utils.h"
SpiFlashOpResult IRAM_ATTR guarded_spi_flash_read(size_t src_addr, void *dest, size_t size){
spi_flash_disable_interrupts_caches_and_other_cpu();
SpiFlashOpResult ret = SPIRead(src_addr,dest,size);
spi_flash_enable_interrupts_caches_and_other_cpu();
return ret;
}
SpiFlashOpResult IRAM_ATTR guarded_spi_flash_write(size_t src_addr, const uint32_t *dest, size_t size){
spi_flash_disable_interrupts_caches_and_other_cpu();
size_t alignedSize = size | 0x03;
SpiFlashOpResult ret = SPIEraseArea(src_addr,alignedSize);
ret = SPIWrite(src_addr,dest,size);
spi_flash_enable_interrupts_caches_and_other_cpu();
return ret;
}
Config class:
Code: Select all
#ifndef CONFIG_H
#define CONFIG_H
#include <stdio.h>
#include "configuration.h"
#include <rom/spi_flash.h>
extern "C" SpiFlashOpResult guarded_spi_flash_read(size_t src_addr, void *dest, size_t size);
extern "C" SpiFlashOpResult guarded_spi_flash_write(size_t src_addr, const uint32_t *dest, size_t size);
class Config {
public:
enum class NetworkType {
AP, CLIENT, AP_CLIENT
};
Config(){};
virtual ~Config(){};
char ssid[32+1];
char password[64+1];
NetworkType networkType;
virtual int sizeObject() {
return sizeof(class Config);
}
static int sizeClass() {
return sizeof(class Config);
}
virtual void getFromFlash() {
SpiFlashOpResult err = guarded_spi_flash_read((size_t)CONFIGURATION_CONFIG_START_ADDRESS,(void *)this,(size_t)sizeObject());
}
virtual void storeToFlash() {
SpiFlashOpResult err = guarded_spi_flash_write((size_t)CONFIGURATION_CONFIG_START_ADDRESS,(const uint32_t *)this,(size_t)sizeObject());
}
enum class ErrorType {
OK = SPI_FLASH_RESULT_OK, SPI_FLASH_RESULT_ERR = SPI_FLASH_RESULT_ERR,SPI_FLASH_RESULT_TIMEOUT = SPI_FLASH_RESULT_TIMEOUT
};
};
#endif /* CONFIG_H */
-
- Posts: 9
- Joined: Mon Feb 29, 2016 8:09 am
Re: SPI Flash - InstrFetchProhibited occured
Symptoms:
- If I call the at the beginning code(see next section), and after call any location( for exampe - modified gatt server sample) - not error!
- but, I not execute this section, and after call any location( for exampe - modified gatt server sample) - error occured:
- If I call the at the beginning code(see next section), and after call any location( for exampe - modified gatt server sample) - not error!
Code: Select all
extern "C" void app_main(void)
{
spi_flash_init();
nvs_flash_init();
/* critical section */
Config *testConfig = new Config;
sprintf(testConfig->ssid,"ABCD");
sprintf(testConfig->password,"XXXXXXXX");
testConfig->storeToFlash();
...
Code: Select all
Guru Meditation Error of type InstrFetchProhibited occurred on core 0. Exception was unhandled.
Register dump:
PC : 0x00633269 PS : 0x00060730 A0 : 0x800f624a A1 : 0x3ffd59e0
A2 : 0x3ffd1040 A3 : 0x00000004 A4 : 0x3ffd5cc0 A5 : 0x00633269
A6 : 0x3f404924 A7 : 0x3ffcbb6c A8 : 0x800f6055 A9 : 0x3ffd59d0
A10 : 0x3ffd1040 A11 : 0x3ffd59fc A12 : 0x000000ff A13 : 0x0000ff00
A14 : 0x00ff0000 A15 : 0xff000000 SAR : 0x00000004 EXCCAUSE: 0x00000014
EXCVADDR: 0x00633268 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffffc
-
- Posts: 9
- Joined: Mon Feb 29, 2016 8:09 am
-
- Posts: 9
- Joined: Mon Feb 29, 2016 8:09 am
Re: SPI Flash - InstrFetchProhibited occured
Good questions!WiFive wrote:Did you check https://github.com/espressif/esp-idf/bl ... ops.c#L187
You don't want to use nvs?
- I try spi_flash_write, read, erase combo. The result is the same. (InstrFetchProhibited)
- In my project want (must) use simple, own filesystem with big file. I also need to use these functions.
So, I must use spi_flash_read from any code!
Who is online
Users browsing this forum: No registered users and 62 guests