9 years, 1 month 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:

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

1 Answer

9 years, 1 month 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

Accepted Answer

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 Chunqiang Li 07 Mar 2015

Some 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 Richard Thompson 07 Mar 2015

There 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 Chunqiang Li 09 Mar 2015