Skip to content

Commit 65f238f

Browse files
committed
Using pointer allows to only create instances when a filesystem is actually selected.
1 parent c7cd207 commit 65f238f

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/Arduino_Portenta_OTA_InternalFlash.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ using namespace arduino;
3232
Arduino_Portenta_OTA_InternalFlash::Arduino_Portenta_OTA_InternalFlash(StorageTypePortenta const storage_type, uint32_t const _data_offset)
3333
: Arduino_Portenta_OTA(storage_type, _data_offset)
3434
, _bd(0x8000000 + _data_offset, 2 * 1024 * 1024 - _data_offset)
35-
, _fs_flash("fs")
36-
, _littlefs_fs_flash("little_fs")
35+
, _fs_flash{NULL}
36+
, _littlefs_fs_flash{NULL}
3737
{
3838
assert(_storage_type == INTERNAL_FLASH_FATFS ||
3939
_storage_type == INTERNAL_FLASH_LITTLEFS);
@@ -47,7 +47,8 @@ bool Arduino_Portenta_OTA_InternalFlash::init()
4747
{
4848
if (_storage_type == INTERNAL_FLASH_FATFS)
4949
{
50-
int const err = _fs_flash.mount(&_bd);
50+
_fs_flash = new mbed::FATFileSystem("fs");
51+
int const err = _fs_flash->mount(&_bd);
5152
if (err)
5253
{
5354
Serial1.print("Error while mounting flash filesystem: ");
@@ -59,7 +60,8 @@ bool Arduino_Portenta_OTA_InternalFlash::init()
5960

6061
if (_storage_type == INTERNAL_FLASH_LITTLEFS)
6162
{
62-
int const err = _littlefs_fs_flash.mount(&_bd);
63+
_littlefs_fs_flash = new mbed::LittleFileSystem("little_fs");
64+
int const err = _littlefs_fs_flash->mount(&_bd);
6365
if (err)
6466
{
6567
Serial1.print("Error while mounting littlefs filesystem: ");

src/Arduino_Portenta_OTA_InternalFlash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ class Arduino_Portenta_OTA_InternalFlash : public Arduino_Portenta_OTA
4747
private:
4848

4949
FlashIAPBlockDevice _bd;
50-
mbed::FATFileSystem _fs_flash;
51-
mbed::LittleFileSystem _littlefs_fs_flash;
50+
mbed::FATFileSystem * _fs_flash;
51+
mbed::LittleFileSystem * _littlefs_fs_flash;
5252

5353
};
5454

0 commit comments

Comments
 (0)