Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
Does mbed support persistent storage access operation ?
Are there any API about persistent storage access operation in mbed ? Such as Flash interface, Filesystem.
Maybe it is on the way?
Question relating to:

1 Answer
10 years ago.
If your chip has extra flash (like the LPC1768), then you can use the LocalFileSystem. If not (like the FRDM-K64F), then you can use an SD card.
http://developer.mbed.org/cookbook/SD-Card-File-System
Thank you very much. but why LocalFileSystem calls semihost function ? Does it work with Flash driver ? By the way, there is no SD card in my project.
posted by 07 Mar 2015Some of the mbed boards have user-writable flash in the 'magic' mbed interface chip that acts as the USB programmer and serial port.
If yours doesn't (or you're prototyping for a production device that won't have the mbed interface), then you'll need to either add an external flash chip (eg the M25P family) or use the platform-specific functions to write to an unused part of the program flash.
There are several libraries for external flash chips, not sure about on-chip program flash.
Which platform are you using?
posted by 07 Mar 2015There is Flash memory in my board(nRF51822). but when I imported mbed-src to my project, I found following codes in LocalFileSystem.cpp:
ssize_t LocalFileHandle::write(const void *buffer, size_t length) { ssize_t n = semihost_write(_fh, (const unsigned char*)buffer, length, 0); number of characters not written n = length - n; number of characters written pos += n; return n; }
ssize_t LocalFileHandle::read(void *buffer, size_t length) { ssize_t n = semihost_read(_fh, (unsigned char*)buffer, length, 0); number of characters not read n = length - n; number of characters read pos += n; return n; }
The APIs call semihost_*. Does semihost_* call the flash driver of nRF51822 finally ?
posted by 09 Mar 2015