diff --git a/examples/OTA_Internal_Flash/OTA_Internal_Flash.ino b/examples/OTA_Internal_Flash/OTA_Internal_Flash.ino deleted file mode 100644 index 6e1be15..0000000 --- a/examples/OTA_Internal_Flash/OTA_Internal_Flash.ino +++ /dev/null @@ -1,49 +0,0 @@ -/* - This example demonstrates how to use to update - the firmware of the Arduino Portenta H7 using - a firmware image stored in the internal flash of - the MCU. - - Before uploading this sketch: - Flash OTA_Usage_Portenta.ino.bin through dfu-util at address 0x08080000 - */ - -#include "Arduino_Portenta_OTA.h" - -void setup() -{ - Serial.begin(115200); - while (!Serial) {} - - Serial.println("*****OTA from Internal Flash*****"); - - Arduino_Portenta_OTA_InternalFlash ota(INTERNAL_FLASH_OFFSET, 0x80000); - Arduino_Portenta_OTA::Error ota_err = Arduino_Portenta_OTA::Error::None; - - Serial.println("Initializing OTA storage"); - if ((ota_err = ota.begin()) != Arduino_Portenta_OTA::Error::None) - { - Serial.print ("ota.begin() failed with error code "); - Serial.println((int)ota_err); - return; - } - - /* This function sets the precise length of update binary, in this case of OTA_Usage_Portenta.ino.PORTENTA_H7_M7.bin */ - ota.setUpdateLen(131728); - - Serial.println("Storing parameters for firmware update in bootloader accessible non-volatile memory"); - if ((ota_err = ota.update()) != Arduino_Portenta_OTA::Error::None) - { - Serial.print ("ota.update() failed with error code "); - Serial.println((int)ota_err); - return; - } - - Serial.println("Performing a reset after which the bootloader will update the firmware."); - ota.reset(); -} - -void loop() -{ - -} diff --git a/keywords.txt b/keywords.txt index 3e29772..b382d5e 100644 --- a/keywords.txt +++ b/keywords.txt @@ -9,7 +9,6 @@ Arduino_Portenta_OTA KEYWORD1 Arduino_Portenta_OTA_SD KEYWORD1 Arduino_Portenta_OTA_QSPI KEYWORD1 -Arduino_Portenta_OTA_InternalFlash KEYWORD1 Error KEYWORD1 ####################################### @@ -27,8 +26,6 @@ decompress KEYWORD2 # Constants (LITERAL1) ####################################### -INTERNAL_FLASH_FATFS LITERAL1 -INTERNAL_FLASH_LITTLEFS LITERAL1 QSPI_FLASH_FATFS LITERAL1 QSPI_FLASH_FATFS_MBR LITERAL1 SD_FATFS LITERAL1 diff --git a/src/Arduino_Portenta_OTA.h b/src/Arduino_Portenta_OTA.h index 94293b8..5e22260 100644 --- a/src/Arduino_Portenta_OTA.h +++ b/src/Arduino_Portenta_OTA.h @@ -35,7 +35,6 @@ * DEFINE ******************************************************************************/ -#define APOTA_INTERNAL_FLASH_FLAG (1 << 1) #define APOTA_QSPI_FLASH_FLAG (1 << 2) #define APOTA_SDCARD_FLAG (1 << 3) #define APOTA_RAW_FLAG (1 << 4) @@ -48,8 +47,6 @@ ******************************************************************************/ enum StorageTypePortenta { - INTERNAL_FLASH_FATFS = APOTA_INTERNAL_FLASH_FLAG | APOTA_FATFS_FLAG, - INTERNAL_FLASH_LITTLEFS = APOTA_INTERNAL_FLASH_FLAG | APOTA_LITTLEFS_FLAG, QSPI_FLASH_FATFS = APOTA_QSPI_FLASH_FLAG | APOTA_FATFS_FLAG, QSPI_FLASH_FATFS_MBR = APOTA_QSPI_FLASH_FLAG | APOTA_FATFS_FLAG | APOTA_MBR_FLAG, SD_FATFS = APOTA_SDCARD_FLAG | APOTA_FATFS_FLAG, @@ -115,6 +112,5 @@ class Arduino_Portenta_OTA #include "Arduino_Portenta_OTA_SD.h" #include "Arduino_Portenta_OTA_QSPI.h" -#include "Arduino_Portenta_OTA_InternalFlash.h" #endif /* ARDUINO_PORTENTA_OTA_H_ */ \ No newline at end of file diff --git a/src/Arduino_Portenta_OTA_InternalFlash.cpp b/src/Arduino_Portenta_OTA_InternalFlash.cpp deleted file mode 100644 index 8d862aa..0000000 --- a/src/Arduino_Portenta_OTA_InternalFlash.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - This file is part of Arduino_Portenta_OTA. - - Copyright 2020 ARDUINO SA (http://www.arduino.cc/) - - This software is released under the GNU General Public License version 3, - which covers the main part of arduino-cli. - The terms of this license can be found at: - https://www.gnu.org/licenses/gpl-3.0.en.html - - You can be released from the requirements of the above licenses by purchasing - a commercial license. Buying such a license is mandatory if you want to modify or - otherwise use the software for commercial activities involving the Arduino - software without disclosing the source code of your own applications. To purchase - a commercial license, send an email to license@arduino.cc. -*/ - -/****************************************************************************** - INCLUDE - ******************************************************************************/ - -#include "Arduino_Portenta_OTA_InternalFlash.h" - -#include - -using namespace arduino; - -/****************************************************************************** - CTOR/DTOR - ******************************************************************************/ - -Arduino_Portenta_OTA_InternalFlash::Arduino_Portenta_OTA_InternalFlash(StorageTypePortenta const storage_type, uint32_t const _data_offset) -: Arduino_Portenta_OTA(storage_type, _data_offset) -, _bd(0x8000000 + _data_offset, 2 * 1024 * 1024 - _data_offset) -, _fs_flash{NULL} -, _littlefs_fs_flash{NULL} -{ - assert(_storage_type == INTERNAL_FLASH_FATFS || _storage_type == INTERNAL_FLASH_LITTLEFS); -} - -/****************************************************************************** - PUBLIC MEMBER FUNCTIONS - ******************************************************************************/ - -bool Arduino_Portenta_OTA_InternalFlash::init() -{ - if (_storage_type == INTERNAL_FLASH_FATFS) - { - _fs_flash = new mbed::FATFileSystem("fs"); - int const err = _fs_flash->mount(&_bd); - if (err) - { - Serial1.print("Error while mounting flash filesystem: "); - Serial1.println(err); - return false; - } - return true; - } - - if (_storage_type == INTERNAL_FLASH_LITTLEFS) - { - _littlefs_fs_flash = new mbed::LittleFileSystem("little_fs"); - int const err = _littlefs_fs_flash->mount(&_bd); - if (err) - { - Serial1.print("Error while mounting littlefs filesystem: "); - Serial1.println(err); - return false; - } - return true; - } - - return false; -} - -bool Arduino_Portenta_OTA_InternalFlash::open() -{ - DIR * dir = NULL; - - if (_storage_type == INTERNAL_FLASH_FATFS) - { - if ((dir = opendir("/fs")) != NULL) - { - if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length)) - { - closedir(dir); - return true; - } - closedir(dir); - } - return false; - } - - if (_storage_type == INTERNAL_FLASH_LITTLEFS) - { - if ((dir = opendir("/little_fs")) != NULL) - { - if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length)) - { - closedir(dir); - return true; - } - closedir(dir); - } - return false; - } - - return false; -} diff --git a/src/Arduino_Portenta_OTA_InternalFlash.h b/src/Arduino_Portenta_OTA_InternalFlash.h deleted file mode 100644 index 74933ef..0000000 --- a/src/Arduino_Portenta_OTA_InternalFlash.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - This file is part of Arduino_Portenta_OTA. - - Copyright 2020 ARDUINO SA (http://www.arduino.cc/) - - This software is released under the GNU General Public License version 3, - which covers the main part of arduino-cli. - The terms of this license can be found at: - https://www.gnu.org/licenses/gpl-3.0.en.html - - You can be released from the requirements of the above licenses by purchasing - a commercial license. Buying such a license is mandatory if you want to modify or - otherwise use the software for commercial activities involving the Arduino - software without disclosing the source code of your own applications. To purchase - a commercial license, send an email to license@arduino.cc. -*/ - -#ifndef ARDUINO_PORTENTA_OTA_INTERNAL_FLASH_H_ -#define ARDUINO_PORTENTA_OTA_INTERNAL_FLASH_H_ - -/****************************************************************************** - * INCLUDE - ******************************************************************************/ - -#include "Arduino_Portenta_OTA.h" - -#include - -/****************************************************************************** - * CLASS DECLARATION - ******************************************************************************/ - -class Arduino_Portenta_OTA_InternalFlash : public Arduino_Portenta_OTA -{ -public: - - Arduino_Portenta_OTA_InternalFlash(StorageTypePortenta const storage_type, uint32_t const data_offset); - virtual ~Arduino_Portenta_OTA_InternalFlash() { } - - -protected: - - virtual bool init () override; - virtual bool open () override; - - -private: - - FlashIAPBlockDevice _bd; - mbed::FATFileSystem * _fs_flash; - mbed::LittleFileSystem * _littlefs_fs_flash; - -}; - -#endif /* ARDUINO_PORTENTA_OTA_INTERNAL_FLASH_H_ */