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:

Library for LoRa communication using MultiTech MDOT. Lora, mdot, multitech

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

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

Accepted Answer

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 Jean Bédard 24 Nov 2015

Hi 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 Geoff Field 19 Aug 2016

Geoff,

True means success.

What you are trying to do should be possible. You'll want to make sure you're opened the file for writing.

Cheers,

Mike

posted by Mike Fiore 19 Aug 2016