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.
8 years, 5 months ago.
Write and read from internal Flash on mDot
Hi,
It might be a silly question but it is not obvious for a software dev like me :-). Is it possible to read/write from the internal flash memory (512 kB) on the Cortex M4 MCU that is on the mDot ?
I would like to store/read my own settings and I don't want to integrate an external flash or eeprom for that. I know you are already doing something like that with the actual mDot LoRa settings that we can persist using saveConfig().
Thanks, More questions to come :-) Jean
Question relating to:
1 Answer
8 years, 5 months ago.
Jean,
The mDot has an integrated 2MB flash part already. The mDot library runs a filesystem on that part and it is available for users via the mDot API. See the following functions...
bool saveUserFile(const char* file, void* data, uint32_t size);
bool appendUserFile(const char* file, void* data, uint32_t size);
bool readUserFile(const char* file, void* data, uint32_t size);
bool moveUserFile(const char* file, const char* new_name);
bool deleteUserFile(const char* file);
mDot::mdot_file openUserFile(const char* file, int mode);
bool seekUserFile(mDot::mdot_file& file, size_t offset, int whence);
int readUserFile(mDot::mdot_file& file, void* data, size_t length);
int writeUserFile(mDot::mdot_file& file, void* data, size_t length);
bool closeUserFile(mDot::mdot_file& file);
std::vector<mDot::mdot_file> listUserFiles();
Each of these functions is documented in mDot.h.
Cheers,
Mike
Great news Mike! I've looked at the mDot datasheet and could not find any mention of that external Flash! 2 Mb is more than enough!
Thanks
posted by 24 Nov 2015Hi Mike,
The documentation in mDot.h is fairly minimal. For example, with the functions that return bool, does "true" mean success or failure?
I'm trying to use seekUserFile() and writeUserFile() to overwrite parts of a file. Is this possible? Am I missing something?
Regards,
Geoff
posted by 19 Aug 2016
Hello, can someone share an example code of how to use these functions to store some variables in flash memory?
posted by John Caipa 22 Mar 2017