Save data only on the Spresense main board

Asked 2 years ago, Updated 2 years ago, 42 views

I would like to save data to Flash only on the main board of the Presense.
The Arduino SDK has an EEPROM library, but it does not appear to be in the Presence SDK.
If possible, I would appreciate it if you could tell me how to do it with the Spresense SDK.

spresense

2022-09-29 22:39

2 Answers

I found the following code in camera_main.c

/*In SD card is available, use SD card.
 * Otherwise, use SPI flash.
 */

ret = stat("/mnt/sd0", & stat_buf);
if(ret<0)
  {
    save_dir="/mnt/spif";
  }
else
  {
    save_dir="/mnt/sd0";
  }

As a trial, I created the file below /mnt/spif, but it didn't disappear even when I turned it off/on, so I think it's probably okay.


2022-09-29 22:39

I am in charge of SPRESENSE support for Sony.
I would like to reply to your inquiry.

As you have already checked, /mnt/spif has been allocated Flash space.
For example, you can access the file "hoge.txt" with the pathname "/mnt/spif/hoge.txt".
You can use C-language standard functions such as fopen, fwrite, fread, and fclose.

Here are some simple examples of the program:

# include 

FILE*fp;

fp = fopen("/mnt/spif/hoge.txt", "w");
fwrite(buf,size,n,fp);// Write
fclose(fp);

fp = fopen("/mnt/spif/hoge.txt", "r");
fread(buf,size,n,fp); // Read
fclose(fp);

Thank you for your continued support for the Presense.


2022-09-29 22:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.