Page 1 of 1

Modify data of particular location of flash memory using spiffs.?

Posted: Fri Jun 09, 2017 1:26 pm
by rahul.b.patel
Hello,
I have requirement to load data into the flash at fix location and then modify that particular flash data with the use of spiffs library.
Can anyone suggest me how can it be possible.?
In other way, Is it possible to load data using flash download tool into spiffs partition area and then modify particular data with spiffs read write operations..?

Thanks.

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Fri Jun 09, 2017 2:12 pm
by loboris
It is possible, but it makes no sense. It is like using dd on Linux to modify the part of the mounted file system, the best way to make the file system unusable.
If you need to work with fixed flash memory locations, define separate flash partition and than access it directly using flash functions. That way you can also preload data using flash download tool.

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Fri Jun 09, 2017 5:14 pm
by Ritesh
loboris wrote:It is possible, but it makes no sense. It is like using dd on Linux to modify the part of the mounted file system, the best way to make the file system unusable.
If you need to work with fixed flash memory locations, define separate flash partition and than access it directly using flash functions. That way you can also preload data using flash download tool.
Hi Loboris,

I and Rahul are working together in one of ESP32 based project.

His concern is like there is one restriction like to delete 4 KBytes chunk to write 2 bytes of data into particular sector of SPI Flash Memory.

So that he first need to read that 4 Kbyte Sector data then modify data at offset whatever he wants to update from that particular section.

So, our requirement is like we have some couple of certificates file whose size is maximum of 1024 byte for individual certificate. So, First it will be loaded externally either like firmware binary into other location or can be loaded into SPIFFS into project.

I think you have did into your LCD based example to load different images into SPIFFS. Correct?

I have checked your updated LCD Repository but failed to execute make makefs command to generate SPIFFS image .img file.

Can you please help us on this?

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Tue Jun 13, 2017 5:00 pm
by Ritesh
Hi Loboris,

We have tested SPIFFS code which is provided in your TFT Library Repository and found one issue.

The issue is like we have added some files externally using mkspiffs binary. After that we have opened one file among them in "w" mode only at that time it seems like another same name file has been created or existing​ file is deleted and new same name file has been created.

So does it valid way to recreate same name file and delete older file if same name file has been opened with write mode?

Let me know if need any information from my side.

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Tue Jun 13, 2017 6:02 pm
by loboris
I'm not sure if I understand what is the problem.

Look at: https://www.tutorialspoint.com/c_standa ... _fopen.htm
"w" mode creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file.
You can also check https://github.com/loboris/ESP32_spiffs_example, there are more examples of file read/write...

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Wed Jun 14, 2017 12:49 am
by Ritesh
loboris wrote:I'm not sure if I understand what is the problem.

Look at: https://www.tutorialspoint.com/c_standa ... _fopen.htm
"w" mode creates an empty file for writing. If a file with the same name already exists, its content is erased and the file is considered as a new empty file.
You can also check https://github.com/loboris/ESP32_spiffs_example, there are more examples of file read/write...
Hi,

Sorry, I just need to confirm mode again that it's rw mode or only w mode and then will get back to you.

Re: Modify data of particular location of flash memory using spiffs.?

Posted: Wed Jun 14, 2017 4:09 am
by rahul.b.patel
Hello,
The issue was that I was using "w+" mode for modifying existing file instead of "r+"mode, so the existing file was getting truncated to zero. It is solved now.

Thanks.