esp_partition_read causes exception

Posts: 2
Joined: Sun Feb 05, 2017 6:57 pm

esp_partition_read causes exception

Postby isakua » Tue Feb 07, 2017 9:37 pm

I'm writing flash memory access code and having a problem with esp_partition_read API.
When I run the following code, I get an exception at esp_partition_read but not all the time. Sometime it works and sometimes it won't. Can someone advise me the reason and fix please?


Code: Select all

#include <Arduino.h>
#include "esp_spi_flash.h"
#include "esp_partition.H"

static esp_partition_t *epp;

void setup()
	int i, s;
	char buf[4096];


	Serial.println("FLASH FILE SYSTEM TEST");
	epp = (esp_partition_t *)esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, NULL);
	if (!epp) {
		Serial.println("Can't find spiffs partition");
		while (1);
	Serial.printf("DATA Subtype=%d add=%x size=%x lbl=%s enc=%d\n", epp->subtype, epp->address, epp->size, epp->label, epp->encrypted);

	Serial.println("Write one sector");
	for (i = 0; i < sizeof(buf); i++) {
		buf[i] = 0x55;
	if (esp_partition_write(epp, 0, buf, sizeof(buf))) {
		Serial.println("Write Error");
	else {
		Serial.println("Write OK");

	Serial.println("Reading from flash...");
	for (i = 0; i < 2; i++) {
		if (esp_partition_read(epp, i * 4096 , buf, sizeof(buf))) {
			Serial.println("flash read error");
		else {
			for (s = 0; s < 10; s++) {
				Serial.printf("%x ", buf[s]);

void loop()

Run the above code, and get the following error from time to time.

Code: Select all

DATA Subtype=130 add=110000 size=200000 lbl=spiffs enc=0
Write one sector
Write OK
Reading from flash...
Guru Meditation Error of type IllegalInstruction occurred on core  1. Exception was unhandled.
Register dump:
PC      : 0x400d96bb  PS      : 0x00060c30  A0      : 0x3ffc29b8  A1      : 0x3ffdb790  
A2      : 0x00000000  A3      : 0x400821f8  A4      : 0x00000000  A5      : 0x0000ff00  
A6      : 0x00ff0000  A7      : 0xff000000  A8      : 0x800d96b9  A9      : 0x3ffdb770  
A10     : 0x00000000  A11     : 0x00000000  A12     : 0x3ffc2868  A13     : 0x3ffc2870  
A14     : 0x00000000  A15     : 0x00000001  SAR     : 0x00000020  EXCCAUSE: 0x00000000  
EXCVADDR: 0x00000000  LBEG    : 0x400014fd  LEND    : 0x4000150d  LCOUNT  : 0xffffffff  

Backtrace: 0x400d96bb:0x3ffdb790 0x3ffc29b8:0x3ffdb7b0 0x40081f84:0x3ffdb7d0 0x400f7459:0x3ffdb820 0x400d0ce3:0x3ffdb850 0x400ff746:0x3ffdc880

CPU halted.
ets Jun  8 2016 00:22:57
I modified partition like this:

Code: Select all

APP Subtype=0 add=0x10000 size=0x100000 lbl=factory enc=0
DAT Subtype=130 add=0x110000 size=0x200000 lbl=spiffs enc=0
DAT Subtype=1 add=0xf000 size=0x1000 lbl=phy_init enc=0
DAT Subtype=2 add=0x9000 size=0x6000 lbl=nvs enc=0

Posts: 2246
Joined: Sun May 08, 2016 4:11 am

Re: esp_partition_read causes exception

Postby ESP_Angus » Tue Feb 07, 2017 11:14 pm

This feels a bit like a bug which was resolved in esp-idf recently. I see me-no-dev updated the Arduino support to use the latest IDF yesterday, what version do you have?

Posts: 2
Joined: Sun Feb 05, 2017 6:57 pm

Re: esp_partition_read causes exception

Postby isakua » Tue Feb 07, 2017 11:35 pm


Who is online

Users browsing this forum: Google [Bot] and 21 guests