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

rahul.b.patel
Posts: 62
Joined: Wed Apr 19, 2017 6:35 am

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

Postby rahul.b.patel » Fri Jun 09, 2017 1:26 pm

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.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Fri Jun 09, 2017 2:12 pm

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.

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

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

Postby Ritesh » Fri Jun 09, 2017 5:14 pm

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?
Regards,
Ritesh Prajapati

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

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

Postby Ritesh » Tue Jun 13, 2017 5:00 pm

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.
Regards,
Ritesh Prajapati

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Tue Jun 13, 2017 6:02 pm

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...

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

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

Postby Ritesh » Wed Jun 14, 2017 12:49 am

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.
Regards,
Ritesh Prajapati

rahul.b.patel
Posts: 62
Joined: Wed Apr 19, 2017 6:35 am

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

Postby rahul.b.patel » Wed Jun 14, 2017 4:09 am

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.

Who is online

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