Skip to content

Commit 0384d9b

Browse files
committed
Turn local variable FlashIAPBlockDevice bd into a private member instead (safer that way).
1 parent e52a319 commit 0384d9b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/Arduino_Portenta_OTA_InternalFlash.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323

2424
#include <stm32h7xx_hal_rtc_ex.h>
2525

26-
#include "FlashIAPBlockDevice.h"
27-
2826
#include <assert.h>
2927

3028
using namespace arduino;
@@ -41,6 +39,7 @@ extern RTC_HandleTypeDef RTCHandle;
4139

4240
Arduino_Portenta_OTA_InternalFlash::Arduino_Portenta_OTA_InternalFlash(StorageTypePortenta const storage_type, uint32_t const _data_offset)
4341
: Arduino_Portenta_OTA(storage_type, _data_offset)
42+
, _bd(0x8000000 + _data_offset, 2 * 1024 * 1024 - _data_offset)
4443
, _fs_flash("fs")
4544
, _littlefs_fs_flash("little_fs")
4645
, _update_size_internal_flash{0}
@@ -55,11 +54,9 @@ Arduino_Portenta_OTA_InternalFlash::Arduino_Portenta_OTA_InternalFlash(StorageTy
5554

5655
bool Arduino_Portenta_OTA_InternalFlash::init()
5756
{
58-
FlashIAPBlockDevice bd(0x8000000 + _data_offset, 2 * 1024 * 1024 - _data_offset);
59-
6057
if (_storage_type == INTERNAL_FLASH_FATFS)
6158
{
62-
int const err = _fs_flash.mount(&bd);
59+
int const err = _fs_flash.mount(&_bd);
6360
if (err)
6461
{
6562
Serial1.print("Error while mounting flash filesystem: ");
@@ -71,7 +68,7 @@ bool Arduino_Portenta_OTA_InternalFlash::init()
7168

7269
if (_storage_type == INTERNAL_FLASH_LITTLEFS)
7370
{
74-
int const err = _littlefs_fs_flash.mount(&bd);
71+
int const err = _littlefs_fs_flash.mount(&_bd);
7572
if (err)
7673
{
7774
Serial1.print("Error while mounting littlefs filesystem: ");

src/Arduino_Portenta_OTA_InternalFlash.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include "Arduino_Portenta_OTA.h"
2626

27+
#include <FlashIAPBlockDevice.h>
28+
2729
/******************************************************************************
2830
* CLASS DECLARATION
2931
******************************************************************************/
@@ -45,6 +47,7 @@ class Arduino_Portenta_OTA_InternalFlash : public Arduino_Portenta_OTA
4547

4648
private:
4749

50+
FlashIAPBlockDevice _bd;
4851
mbed::FATFileSystem _fs_flash;
4952
mbed::LittleFileSystem _littlefs_fs_flash;
5053
int _update_size_internal_flash;

0 commit comments

Comments
 (0)