Skip to content

Commit 09503cf

Browse files
committed
use default instance of blockDevice for H7 boards
1 parent 407e30c commit 09503cf

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

examples/flashFormatter/flashFormatter.ino

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ void setup() {
1818

1919
if(!flashFormatter.checkandFormatPartition()){
2020
Serial.println("Failed to format partition");
21+
} else {
22+
Serial.println("Partition formatted successfully");
2123
}
2224
}
2325

src/flashFormatter/H7FlashFormatter.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@
1212
#include "certificates.h"
1313

1414
MBEDH7FlashFormatter::MBEDH7FlashFormatter():
15-
_root(QSPI_SO0, QSPI_SO1, QSPI_SO2, QSPI_SO3, QSPI_SCK, QSPI_CS, QSPIF_POLARITY_MODE_1, 40000000),
16-
_wifi_data(&_root, 1),
15+
_root(mbed::BlockDevice::get_default_instance()),
16+
_wifi_data(_root, 1),
1717
_wifi_data_fs("wlan"),
18-
_ota_data(&_root, 2),
18+
_ota_data(_root, 2),
1919
_ota_data_fs("fs"),
20-
_kvstore_data(&_root, 3)
20+
_kvstore_data(_root, 3)
2121
{
2222
}
2323

2424
bool MBEDH7FlashFormatter::checkPartition()
2525
{
26-
if (_root.init() != QSPIF_BD_ERROR_OK)
26+
if (_root->init() != mbed::BD_ERROR_OK)
2727
{
2828
return false;
2929
}
@@ -33,7 +33,7 @@ bool MBEDH7FlashFormatter::checkPartition()
3333
return false;
3434
}
3535

36-
if (_ota_data.init() != QSPIF_BD_ERROR_OK || _ota_data_fs.mount(&_ota_data) != 0)
36+
if (_ota_data.init() != mbed::BD_ERROR_OK || _ota_data_fs.mount(&_ota_data) != 0)
3737
{
3838
return false;
3939
}
@@ -45,22 +45,22 @@ bool MBEDH7FlashFormatter::checkPartition()
4545
_ota_data_fs.unmount();
4646
_ota_data.deinit();
4747

48-
if (_kvstore_data.init() != QSPIF_BD_ERROR_OK)
48+
if (_kvstore_data.init() != mbed::BD_ERROR_OK)
4949
{
5050
return false;
5151
}
5252

5353
_kvstore_data.deinit();
54-
_root.deinit();
54+
_root->deinit();
5555

5656
return true;
5757
}
5858

5959
bool MBEDH7FlashFormatter::formatPartition() {
60-
_root.erase(0x0, _root.get_erase_size());
61-
mbed::MBRBlockDevice::partition(&_root, 1, 0x0B, 0, 1024 * 1024);
62-
mbed::MBRBlockDevice::partition(&_root, 2, 0x0B, 1024 * 1024, 13 * 1024 * 1024);
63-
mbed::MBRBlockDevice::partition(&_root, 3, 0x0B, 13 * 1024 * 1024, 14 * 1024 * 1024);
60+
_root->erase(0x0, _root->get_erase_size());
61+
mbed::MBRBlockDevice::partition(_root, 1, 0x0B, 0, 1024 * 1024);
62+
mbed::MBRBlockDevice::partition(_root, 2, 0x0B, 1024 * 1024, 13 * 1024 * 1024);
63+
mbed::MBRBlockDevice::partition(_root, 3, 0x0B, 13 * 1024 * 1024, 14 * 1024 * 1024);
6464

6565
if(_ota_data_fs.mount(&_ota_data) != 0) {
6666
if(_ota_data_fs.reformat(&_ota_data) != 0) {
@@ -73,7 +73,7 @@ bool MBEDH7FlashFormatter::formatPartition() {
7373
if(!formatWifiPartition()) {
7474
return false;
7575
}
76-
_root.deinit();
76+
_root->deinit();
7777
return true;
7878
}
7979

@@ -139,7 +139,7 @@ bool MBEDH7FlashFormatter::formatWifiPartition() {
139139
while (byte_count < file_size) {
140140
if(byte_count + chunck_size > file_size)
141141
chunck_size = file_size - byte_count;
142-
int ret = _root.program(wifi_firmware_image_data, offset + byte_count, chunck_size);
142+
int ret = _root->program(wifi_firmware_image_data, offset + byte_count, chunck_size);
143143
if (ret != 0) {
144144
return false;
145145
}

src/flashFormatter/H7FlashFormatter.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
#pragma once
99
#include "FlashFormatterBase.h"
10-
#include "QSPIFBlockDevice.h"
10+
#include <BlockDevice.h>
1111
#include "MBRBlockDevice.h"
1212
#include "LittleFileSystem.h"
1313
#include "FATFileSystem.h"
@@ -20,7 +20,7 @@ class MBEDH7FlashFormatter : public FlashFormatterClass {
2020
bool checkPartition() override;
2121
bool formatPartition() override;
2222
private:
23-
QSPIFBlockDevice _root;
23+
mbed::BlockDevice* _root;
2424
mbed::MBRBlockDevice _wifi_data;
2525
mbed::FATFileSystem _wifi_data_fs;
2626
mbed::MBRBlockDevice _ota_data;

0 commit comments

Comments
 (0)