Skip to content

Commit 4fede42

Browse files
authored
Merge pull request #22 from bcmi-labs/core_config
Make library configurable using defines
2 parents a524332 + ad3d370 commit 4fede42

7 files changed

+68
-7
lines changed

src/Arduino_Portenta_OTA.h

+16-6
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@
2222
* INCLUDE
2323
******************************************************************************/
2424

25+
#include "Arduino_Portenta_OTA_Config.h"
26+
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)
27+
#include <QSPIFBlockDevice.h>
28+
#endif
29+
30+
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)
31+
#include <SDMMCBlockDevice.h>
32+
#endif
33+
2534
#include <BlockDevice.h>
2635
#include <MBRBlockDevice.h>
27-
#include <SDMMCBlockDevice.h>
28-
2936
#include <FATFileSystem.h>
3037
#include <LittleFileSystem.h>
3138

32-
#include <QSPIFBlockDevice.h>
33-
3439
/******************************************************************************
3540
* DEFINE
3641
******************************************************************************/
@@ -117,7 +122,12 @@ class Arduino_Portenta_OTA
117122
* INCLUDE
118123
******************************************************************************/
119124

120-
#include "Arduino_Portenta_OTA_SD.h"
121-
#include "Arduino_Portenta_OTA_QSPI.h"
125+
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)
126+
#include "Arduino_Portenta_OTA_SD.h"
127+
#endif
128+
129+
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)
130+
#include "Arduino_Portenta_OTA_QSPI.h"
131+
#endif
122132

123133
#endif /* ARDUINO_PORTENTA_OTA_H_ */

src/Arduino_Portenta_OTA_Config.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
This file is part of Arduino_Portenta_OTA.
3+
4+
Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
5+
6+
This software is released under the GNU General Public License version 3,
7+
which covers the main part of arduino-cli.
8+
The terms of this license can be found at:
9+
https://www.gnu.org/licenses/gpl-3.0.en.html
10+
11+
You can be released from the requirements of the above licenses by purchasing
12+
a commercial license. Buying such a license is mandatory if you want to modify or
13+
otherwise use the software for commercial activities involving the Arduino
14+
software without disclosing the source code of your own applications. To purchase
15+
a commercial license, send an email to [email protected].
16+
*/
17+
18+
#ifndef ARDUINO_PORTENTA_OTA_CONFIG_H_
19+
#define ARDUINO_PORTENTA_OTA_CONFIG_H_
20+
21+
/******************************************************************************
22+
* INCLUDE
23+
******************************************************************************/
24+
25+
#include <Arduino.h>
26+
27+
#if defined(ARDUINO_PORTENTA_H7_M7)
28+
#define ARDUINO_PORTENTA_OTA_MAGIC 0x2341025b
29+
#define ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT
30+
#define ARDUINO_PORTENTA_OTA_QSPI_SUPPORT
31+
#endif
32+
33+
#endif /* ARDUINO_PORTENTA_OTA_CONFIG_H_ */

src/Arduino_Portenta_OTA_QSPI.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
INCLUDE
2020
******************************************************************************/
2121

22+
#include "Arduino_Portenta_OTA_Config.h"
23+
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)
24+
2225
#include "Arduino_Portenta_OTA_QSPI.h"
2326

2427
#include <assert.h>
@@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_QSPI::open()
97100

98101
return false;
99102
}
103+
104+
#endif /* ARDUINO_PORTENTA_OTA_QSPI_SUPPORT */

src/Arduino_Portenta_OTA_QSPI.h

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
* INCLUDE
2323
******************************************************************************/
2424

25+
#include "Arduino_Portenta_OTA_Config.h"
26+
#if defined(ARDUINO_PORTENTA_OTA_QSPI_SUPPORT)
27+
2528
#include "Arduino_Portenta_OTA.h"
2629

2730
/******************************************************************************
@@ -50,4 +53,5 @@ class Arduino_Portenta_OTA_QSPI : public Arduino_Portenta_OTA
5053
mbed::FATFileSystem * _fs_qspi;
5154
};
5255

56+
#endif /* ARDUINO_PORTENTA_OTA_QSPI_SUPPORT */
5357
#endif /* ARDUINO_PORTENTA_OTA_QSPI_H_ */

src/Arduino_Portenta_OTA_SD.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
INCLUDE
2020
******************************************************************************/
2121

22+
#include "Arduino_Portenta_OTA_Config.h"
23+
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)
24+
2225
#include "Arduino_Portenta_OTA_SD.h"
2326

2427
#include "BSP.h"
@@ -97,3 +100,5 @@ bool Arduino_Portenta_OTA_SD::open()
97100

98101
return false;
99102
}
103+
104+
#endif /* ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT */

src/Arduino_Portenta_OTA_SD.h

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
* INCLUDE
2323
******************************************************************************/
2424

25+
#include "Arduino_Portenta_OTA_Config.h"
26+
#if defined(ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT)
27+
2528
#include "Arduino_Portenta_OTA.h"
2629

2730
/******************************************************************************
@@ -50,4 +53,5 @@ class Arduino_Portenta_OTA_SD : public Arduino_Portenta_OTA
5053

5154
};
5255

56+
#endif /* ARDUINO_PORTENTA_OTA_SDMMC_SUPPORT */
5357
#endif /* ARDUINO_PORTENTA_OTA_SD_H_ */

src/decompress/utility.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ int Arduino_Portenta_OTA::decompress()
179179

180180
feedWatchdog();
181181

182-
if (ota_header.header.magic_number != 0x2341025b) /* 0x2341:025b = VID/PID Portenta H7 */
182+
if (ota_header.header.magic_number != ARDUINO_PORTENTA_OTA_MAGIC)
183183
{
184184
fclose(update_file);
185185
remove(UPDATE_FILE_NAME_LZSS);

0 commit comments

Comments
 (0)