forked from arduino-libraries/ArduinoIoTCloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
151 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,17 +15,18 @@ | |
a commercial license, send an email to [email protected]. | ||
*/ | ||
|
||
#ifdef ARDUINO_ARCH_SAMD | ||
|
||
/****************************************************************************** | ||
* INCLUDE | ||
******************************************************************************/ | ||
|
||
#include "OTA.h" | ||
#include <AIoTC_Config.h> | ||
|
||
#include <Arduino_DebugUtils.h> | ||
#if defined (ARDUINO_ARCH_SAMD) && OTA_ENABLED | ||
|
||
#include "OTA.h" | ||
#include <Arduino_DebugUtils.h> | ||
#include "../watchdog/Watchdog.h" | ||
#include "utility/ota/FlashSHA256.h" | ||
|
||
#if OTA_STORAGE_SNU | ||
# include <SNU.h> | ||
|
@@ -65,4 +66,19 @@ int samd_onOTARequest(char const * ota_url) | |
return static_cast<int>(OTAError::DownloadFailed); | ||
} | ||
|
||
String samd_getOTAImageSHA256() | ||
{ | ||
/* Calculate the SHA256 checksum over the firmware stored in the flash of the | ||
* MCU. Note: As we don't know the length per-se we read chunks of the flash | ||
* until we detect one containing only 0xFF (= flash erased). This only works | ||
* for firmware updated via OTA and second stage bootloaders (SxU family) | ||
* because only those erase the complete flash before performing an update. | ||
* Since the SHA256 firmware image is only required for the cloud servers to | ||
* perform a version check after the OTA update this is a acceptable trade off. | ||
* The bootloader is excluded from the calculation and occupies flash address | ||
* range 0 to 0x2000, total flash size of 0x40000 bytes (256 kByte). | ||
*/ | ||
return FlashSHA256::calc(0x2000, 0x40000 - 0x2000); | ||
} | ||
|
||
#endif /* ARDUINO_ARCH_SAMD */ |
Oops, something went wrong.