diff --git a/src/Arduino_Portenta_OTA.h b/src/Arduino_Portenta_OTA.h index e2e2bd1..82eb228 100644 --- a/src/Arduino_Portenta_OTA.h +++ b/src/Arduino_Portenta_OTA.h @@ -22,15 +22,20 @@ * INCLUDE ******************************************************************************/ +#include "Arduino_Portenta_OTA_Config.h" +#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT) + #include +#endif + +#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT) + #include +#endif + #include #include -#include - #include #include -#include - /****************************************************************************** * DEFINE ******************************************************************************/ @@ -117,7 +122,12 @@ class Arduino_Portenta_OTA * INCLUDE ******************************************************************************/ -#include "Arduino_Portenta_OTA_SD.h" -#include "Arduino_Portenta_OTA_QSPI.h" +#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT) + #include "Arduino_Portenta_OTA_SD.h" +#endif + +#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT) + #include "Arduino_Portenta_OTA_QSPI.h" +#endif #endif /* ARDUINO_PORTENTA_OTA_H_ */ \ No newline at end of file diff --git a/src/Arduino_Portenta_OTA_Config.h b/src/Arduino_Portenta_OTA_Config.h new file mode 100644 index 0000000..0397e71 --- /dev/null +++ b/src/Arduino_Portenta_OTA_Config.h @@ -0,0 +1,33 @@ +/* + This file is part of Arduino_Portenta_OTA. + + Copyright 2022 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_CONFIG_H_ +#define ARDUINO_PORTENTA_OTA_CONFIG_H_ + +/****************************************************************************** + * INCLUDE + ******************************************************************************/ + +#include + +#if defined(ARDUINO_PORTENTA_H7_M7) + #define ARDUINO_PORTENTA_OTA_MAGIC 0x2341025b + #define ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT + #define ARDUINO_PORTENTA_OTA_QSPI_SUPPORT +#endif + +#endif /* ARDUINO_PORTENTA_OTA_CONFIG_H_ */ diff --git a/src/Arduino_Portenta_OTA_QSPI.cpp b/src/Arduino_Portenta_OTA_QSPI.cpp index 3f129fb..b1fc43d 100644 --- a/src/Arduino_Portenta_OTA_QSPI.cpp +++ b/src/Arduino_Portenta_OTA_QSPI.cpp @@ -19,6 +19,9 @@ INCLUDE ******************************************************************************/ +#include "Arduino_Portenta_OTA_Config.h" +#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT) + #include "Arduino_Portenta_OTA_QSPI.h" #include @@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_QSPI::open() return false; } + +#endif /* ARDUINO_PORTENTA_OTA_QSPI_SUPPORT */ diff --git a/src/Arduino_Portenta_OTA_QSPI.h b/src/Arduino_Portenta_OTA_QSPI.h index a74b030..aa0b3bd 100644 --- a/src/Arduino_Portenta_OTA_QSPI.h +++ b/src/Arduino_Portenta_OTA_QSPI.h @@ -22,6 +22,9 @@ * INCLUDE ******************************************************************************/ +#include "Arduino_Portenta_OTA_Config.h" +#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT) + #include "Arduino_Portenta_OTA.h" /****************************************************************************** @@ -50,4 +53,5 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA mbed::FATFileSystem * _fs_qspi; }; +#endif /* ARDUINO_PORTENTA_OTA_QSPI_SUPPORT */ #endif /* ARDUINO_PORTENTA_OTA_QSPI_H_ */ diff --git a/src/Arduino_Portenta_OTA_SD.cpp b/src/Arduino_Portenta_OTA_SD.cpp index c1d1d29..685f1c0 100644 --- a/src/Arduino_Portenta_OTA_SD.cpp +++ b/src/Arduino_Portenta_OTA_SD.cpp @@ -19,6 +19,9 @@ INCLUDE ******************************************************************************/ +#include "Arduino_Portenta_OTA_Config.h" +#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT) + #include "Arduino_Portenta_OTA_SD.h" #include "BSP.h" @@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_SD::open() return false; } + +#endif /* ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT */ diff --git a/src/Arduino_Portenta_OTA_SD.h b/src/Arduino_Portenta_OTA_SD.h index d8e52e8..fecb893 100644 --- a/src/Arduino_Portenta_OTA_SD.h +++ b/src/Arduino_Portenta_OTA_SD.h @@ -22,6 +22,9 @@ * INCLUDE ******************************************************************************/ +#include "Arduino_Portenta_OTA_Config.h" +#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT) + #include "Arduino_Portenta_OTA.h" /****************************************************************************** @@ -50,4 +53,5 @@ class Arduino_Portenta_OTA_SD : public Arduino_Portenta_OTA }; +#endif /* ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT */ #endif /* ARDUINO_PORTENTA_OTA_SD_H_ */ diff --git a/src/decompress/utility.cpp b/src/decompress/utility.cpp index d10f80e..4bfecb4 100644 --- a/src/decompress/utility.cpp +++ b/src/decompress/utility.cpp @@ -179,7 +179,7 @@ int Arduino_Portenta_OTA::decompress() feedWatchdog(); - if (ota_header.header.magic_number != 0x2341025b) /* 0x2341:025b = VID/PID Portenta H7 */ + if (ota_header.header.magic_number != ARDUINO_PORTENTA_OTA_MAGIC) { fclose(update_file); remove(UPDATE_FILE_NAME_LZSS);