From 1c932fb7ed88b5edf424e25e4ecb15f9f42cb177 Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 15 Jul 2021 08:49:42 +0200 Subject: [PATCH] Since version 6.12 of mbed-os and 2.3.1 of mbed core COMPONENT_4343W_FS is used instead of COMPONENT_4343W and the QSPI BlockDevice is initialized in the core --- src/Arduino_Portenta_OTA_QSPI.cpp | 16 ++++++++++++---- src/Arduino_Portenta_OTA_QSPI.h | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Arduino_Portenta_OTA_QSPI.cpp b/src/Arduino_Portenta_OTA_QSPI.cpp index fe96a64..44adaed 100644 --- a/src/Arduino_Portenta_OTA_QSPI.cpp +++ b/src/Arduino_Portenta_OTA_QSPI.cpp @@ -25,6 +25,10 @@ using namespace arduino; +#if defined (COMPONENT_4343W_FS) +extern QSPIFBlockDevice *qspi_bd; +#endif + /****************************************************************************** CTOR/DTOR ******************************************************************************/ @@ -33,7 +37,6 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s : Arduino_Portenta_OTA(storage_type, data_offset) , _bd_qspi{NULL} , _fs_qspi{NULL} -, _block_device_qspi(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000) { assert(_storage_type == QSPI_FLASH_FATFS || _storage_type == QSPI_FLASH_FATFS_MBR); } @@ -44,13 +47,18 @@ Arduino_Portenta_OTA_QSPI::Arduino_Portenta_OTA_QSPI(StorageTypePortenta const s bool Arduino_Portenta_OTA_QSPI::init() { - if (_block_device_qspi.init() != QSPIF_BD_ERROR_OK) +#if !defined (COMPONENT_4343W_FS) + qspi_bd = new QSPIFBlockDevice(PD_11, PD_12, PF_7, PD_13, PF_10, PG_6, QSPIF_POLARITY_MODE_1, 40000000); + if (qspi_bd->init() != QSPIF_BD_ERROR_OK) { + Serial1.println("Error: QSPI init failure."); return false; + } +#endif if(_storage_type == QSPI_FLASH_FATFS) { _fs_qspi = new mbed::FATFileSystem("fs"); - int const err_mount = _fs_qspi->mount(&_block_device_qspi); + int const err_mount = _fs_qspi->mount(qspi_bd); if (err_mount) { Serial1.print("Error while mounting the filesystem. Err = "); @@ -62,7 +70,7 @@ bool Arduino_Portenta_OTA_QSPI::init() if (_storage_type == QSPI_FLASH_FATFS_MBR) { - _bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast(&_block_device_qspi), _data_offset); + _bd_qspi = new mbed::MBRBlockDevice(reinterpret_cast(qspi_bd), _data_offset); _fs_qspi = new mbed::FATFileSystem("fs"); int const err_mount = _fs_qspi->mount(_bd_qspi); if (err_mount) { diff --git a/src/Arduino_Portenta_OTA_QSPI.h b/src/Arduino_Portenta_OTA_QSPI.h index 9297b24..a16ce63 100644 --- a/src/Arduino_Portenta_OTA_QSPI.h +++ b/src/Arduino_Portenta_OTA_QSPI.h @@ -47,7 +47,9 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA mbed::BlockDevice * _bd_qspi; mbed::FATFileSystem * _fs_qspi; - QSPIFBlockDevice _block_device_qspi; +#if !defined (COMPONENT_4343W_FS) + QSPIFBlockDevice *qspi_bd; +#endif };