Skip to content

Make library configurable using defines #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/Arduino_Portenta_OTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,20 @@
* INCLUDE
******************************************************************************/

#include "Arduino_Portenta_OTA_Config.h"
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)
#include <QSPIFBlockDevice.h>
#endif

#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)
#include <SDMMCBlockDevice.h>
#endif

#include <BlockDevice.h>
#include <MBRBlockDevice.h>
#include <SDMMCBlockDevice.h>

#include <FATFileSystem.h>
#include <LittleFileSystem.h>

#include <QSPIFBlockDevice.h>

/******************************************************************************
* DEFINE
******************************************************************************/
Expand Down Expand Up @@ -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_ */
33 changes: 33 additions & 0 deletions src/Arduino_Portenta_OTA_Config.h
Original file line number Diff line number Diff line change
@@ -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 [email protected].
*/

#ifndef ARDUINO_PORTENTA_OTA_CONFIG_H_
#define ARDUINO_PORTENTA_OTA_CONFIG_H_

/******************************************************************************
* INCLUDE
******************************************************************************/

#include <Arduino.h>

#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_ */
5 changes: 5 additions & 0 deletions src/Arduino_Portenta_OTA_QSPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>
Expand Down Expand Up @@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_QSPI::open()

return false;
}

#endif /* ARDUINO_PORTENTA_OTA_QSPI_SUPPORT */
4 changes: 4 additions & 0 deletions src/Arduino_Portenta_OTA_QSPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* INCLUDE
******************************************************************************/

#include "Arduino_Portenta_OTA_Config.h"
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)

#include "Arduino_Portenta_OTA.h"

/******************************************************************************
Expand Down Expand Up @@ -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_ */
5 changes: 5 additions & 0 deletions src/Arduino_Portenta_OTA_SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_SD::open()

return false;
}

#endif /* ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT */
4 changes: 4 additions & 0 deletions src/Arduino_Portenta_OTA_SD.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* INCLUDE
******************************************************************************/

#include "Arduino_Portenta_OTA_Config.h"
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)

#include "Arduino_Portenta_OTA.h"

/******************************************************************************
Expand Down Expand Up @@ -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_ */
2 changes: 1 addition & 1 deletion src/decompress/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there also a ARDUINO_PORTENTA_OTA_MAGIC for non H7 boards? This is confusing me 😉

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @aentinger my intention should be more clear now -> #23

{
fclose(update_file);
remove(UPDATE_FILE_NAME_LZSS);
Expand Down