Spiff Not reading the file data

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

Spiff Not reading the file data

Postby Ritu21 » Tue Apr 23, 2019 1:56 pm

Hi,

I am storing some data on spiff which gets stored but when I try to read that file and it gives blank data. I am using fread function to read the file.

Below is the error received:

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4008e4d6 PS : 0x00060a30 A0 : 0x80082b64 A1 : 0x3fff4ab0
A2 : 0x15122500 A3 : 0xffffffff A4 : 0x3ffd9f40 A5 : 0x00000000
A6 : 0x00000000 A7 : 0xff000000 A8 : 0x8008dbf0 A9 : 0x3fff4aa0
A10 : 0x00000003 A11 : 0x00060a23 A12 : 0x00060a20 A13 : 0x3ffe1af0
A14 : 0x0000ffff A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0x15122504 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

ELF file SHA256: 0ce7ca74a0b7b7db3c943c0d0fa9ba8a965d0e87196337beb70a45be30887e5a

Backtrace: 0x4008e4d6:0x3fff4ab0 0x40082b61:0x3fff4ad0 0x40082c51:0x3fff4b00 0x4000be35:0x3fff4b20 0x4000202e:0x3fff4b40 0x400020b5:0x3fff4b60 0x400e7767:0x3fff4b80 0x400d49b4:0x3fff5040 0x4008dad1:0x3fff5060


Could you please help me understand why is this scenario happening???

Hope to see your reply soon.

Thanks
Ritu.

User avatar
fly135
Posts: 606
Joined: Wed Jan 03, 2018 8:33 pm
Location: Orlando, FL

Re: Spiff Not reading the file data

Postby fly135 » Tue Apr 23, 2019 3:33 pm

Where's your code. I'm using spiffs and it works.

John A

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Spiff Not reading the file data

Postby Ritesh » Tue Apr 23, 2019 5:17 pm

Ritu21 wrote:
Tue Apr 23, 2019 1:56 pm
Hi,

I am storing some data on spiff which gets stored but when I try to read that file and it gives blank data. I am using fread function to read the file.

Below is the error received:

Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4008e4d6 PS : 0x00060a30 A0 : 0x80082b64 A1 : 0x3fff4ab0
A2 : 0x15122500 A3 : 0xffffffff A4 : 0x3ffd9f40 A5 : 0x00000000
A6 : 0x00000000 A7 : 0xff000000 A8 : 0x8008dbf0 A9 : 0x3fff4aa0
A10 : 0x00000003 A11 : 0x00060a23 A12 : 0x00060a20 A13 : 0x3ffe1af0
A14 : 0x0000ffff A15 : 0x00000000 SAR : 0x0000001e EXCCAUSE: 0x0000001c
EXCVADDR: 0x15122504 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff

ELF file SHA256: 0ce7ca74a0b7b7db3c943c0d0fa9ba8a965d0e87196337beb70a45be30887e5a

Backtrace: 0x4008e4d6:0x3fff4ab0 0x40082b61:0x3fff4ad0 0x40082c51:0x3fff4b00 0x4000be35:0x3fff4b20 0x4000202e:0x3fff4b40 0x400020b5:0x3fff4b60 0x400e7767:0x3fff4b80 0x400d49b4:0x3fff5040 0x4008dad1:0x3fff5060


Could you please help me understand why is this scenario happening???

Hope to see your reply soon.

Thanks
Ritu.
Hi,

Would you please trace crash dump using addr2line toolchain in which you need to input -pfia -e option with your elf and crash dump?

So that you can extact trace with steps to detect where actual issue into your case.

Let me know if you don't know like how to execute it.
Regards,
Ritesh Prajapati

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

Re: Spiff Not reading the file data

Postby Ritu21 » Wed Apr 24, 2019 5:21 am

Hi John,

Please find the attached code and let me know the bug.

Hi Ritesh,

Thanks for your suggestion but I didn't understand the exact procedure. Could you please explain it more??

Thanks
Ritu.
Attachments
spiffs.c
(6.36 KiB) Downloaded 610 times

Ritesh
Posts: 1365
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Spiff Not reading the file data

Postby Ritesh » Wed Apr 24, 2019 8:18 am

Ritu21 wrote:
Wed Apr 24, 2019 5:21 am
Hi John,

Please find the attached code and let me know the bug.

Hi Ritesh,

Thanks for your suggestion but I didn't understand the exact procedure. Could you please explain it more??

Thanks
Ritu.
Hi,

Please execute below command to see crash dump analysis for your issue

xtensa-esp32-elf-addr2line -pfia -e PATH_OF_Your_ELF_File 0x4008e4d6:0x3fff4ab0 0x40082b61:0x3fff4ad0 0x40082c51:0x3fff4b00 0x4000be35:0x3fff4b20 0x4000202e:0x3fff4b40 0x400020b5:0x3fff4b60 0x400e7767:0x3fff4b80 0x400d49b4:0x3fff5040 0x4008dad1:0x3fff5060

so you will few traces after executing it. So, please send me those traces once you capture it.
Regards,
Ritesh Prajapati

Ritu21
Posts: 123
Joined: Sat Aug 04, 2018 9:58 am

Re: Spiff Not reading the file data

Postby Ritu21 » Thu May 23, 2019 7:06 am

Hi team,

As notified before, I am not able to read data from file I have stored using Spiffs.

Below is my code and the following log:

void spiff_RFIDDataStorage()
{
char rfid_dataInFlash[1024];
size_t total = 0, used = 0;
ret = esp_spiffs_info(NULL, &total, &used);
if (ret != ESP_OK) {
ESP_LOGE(SPIFFS_TAG, "Failed to get SPIFFS partition information (%s)", esp_err_to_name(ret));
} else {
ESP_LOGI(SPIFFS_TAG, "Partition size: total: %d, used: %d", total, used);
}
char time_buf[32];
strcpy((char *)flash[g_byRfidStoredInFlash_Counter].rfidData,(char *)g_byRfid_data_buff_copy);
printf("flash[%d] = %s\n", g_byRfidStoredInFlash_Counter,flash[g_byRfidStoredInFlash_Counter].rfidData);

time_t rawtime;
struct tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
strftime(time_buf, sizeof(time_buf), "%d/%m/%Y %H:%M:%S", timeinfo);
ESP_LOGI(SPIFFS_TAG, "The current date/time in India is: %s",time_buf);
strcpy((char *)flash[g_byRfidStoredInFlash_Counter].dateTime,time_buf);
// Use POSIX and C standard library functions to work with files.
// First create a file.
ESP_LOGI(SPIFFS_TAG, "Opening file");
printf("Appending file\n");
FILE* f = fopen("/spiffs/rfidData.txt", "a");
if (f == NULL) {
ESP_LOGE(SPIFFS_TAG, "Failed to open file for writing");
return;
}
/*long int res1 = ftell(f);
if (res1 != -1)
printf("Size of the file is %ld bytes \n", res1);*/

fwrite(&flash[g_byRfidStoredInFlash_Counter], sizeof(flash), 1, f);
//fprintf(f, (char *)flash[g_byRfidStoredInFlash_Counter]);
g_byRfidStoredInFlash_Counter++;
g_byRfidStoredInFlash_CounterCopy = g_byRfidStoredInFlash_Counter;
fclose(f);
FILE* fp = fopen("/spiffs/rfidData.txt", "r");
if (fp == NULL) {
ESP_LOGE(SPIFFS_TAG, "Failed to open file for reading");
return;
}
ESP_LOGI(SPIFFS_TAG, "File written");
while((fread(rfid_dataInFlash, 1025, 1, fp)) != NULL){
char* pos = strchr(rfid_dataInFlash, '\n');
if(pos) {
*pos = '\0';
}
}
ESP_LOGI(SPIFFS_TAG, "Read from file: '%s'", rfid_dataInFlash);
}

Log:

I (81096) SPIFFS: Partition size: total: 7781, used: 251
flash[1] = 650055FEC40A
I (81096) SPIFFS: The current date/time in India is: 23/05/2019 12:30:29
I (81096) SPIFFS: Opening file
Appending file
I (81106) SPIFFS: File written
I (81106) SPIFFS: Read from file: '▒'

As you can see , file writing was successfull but read gives some other result.

Please see to it and revert asap.

Thanks
Ritu.

Who is online

Users browsing this forum: joglz8 and 80 guests