Skip to content

Calculate SHA256 over firmware image uploaded via OTA #174

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 6 commits into from
Jul 20, 2020

Conversation

aentinger
Copy link
Contributor

@aentinger aentinger commented Jul 20, 2020

This PR calculate the SHA256 checksum over the firmware stored in the flash of the MCU. The checksum is then stored
as ASCII encoded hexadecimal number within a hidden character string property OTA_SHA256.

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).

FIY @eclipse1985

@aentinger aentinger added the type: enhancement Proposed improvement label Jul 20, 2020
@aentinger aentinger self-assigned this Jul 20, 2020
@codecov-commenter
Copy link

codecov-commenter commented Jul 20, 2020

Codecov Report

Merging #174 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #174   +/-   ##
=======================================
  Coverage   95.61%   95.61%           
=======================================
  Files          29       29           
  Lines        1004     1004           
=======================================
  Hits          960      960           
  Misses         44       44           
Impacted Files Coverage Δ
src/utility/ota/OTALogic.cpp 98.03% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 923931a...dea0e10. Read the comment docs.

@github-actions
Copy link

Memory usage change @ 63e85b2

Board flash RAM for global variables
arduino:samd:mkrgsm1400 ❔ -40 - +1176 🔺 +16 - +16
arduino:samd:mkrwan1300 0 - 0 0 - 0
arduino:samd:mkrwifi1010 ❔ -48 - +1200 🔺 +16 - +16
arduino:samd:nano_33_iot ❔ -48 - +1200 🔺 +16 - +16
Click for full report table
Board examples/ArduinoIoTCloud-Advanced
flash
examples/ArduinoIoTCloud-Advanced
RAM for global variables
examples/ArduinoIoTCloud-Basic
flash
examples/ArduinoIoTCloud-Basic
RAM for global variables
examples/utility/ArduinoIoTCloud_Travis_CI
flash
examples/utility/ArduinoIoTCloud_Travis_CI
RAM for global variables
examples/utility/Provisioning
flash
examples/utility/Provisioning
RAM for global variables
arduino:samd:mkrgsm1400 1176 16 1176 16 464 16 -40 16
arduino:samd:mkrwan1300 0 0 0 0 0 0
arduino:samd:mkrwifi1010 1200 16 1200 16 496 16 -48 16
arduino:samd:nano_33_iot 1200 16 1200 16 488 16 -48 16
Click for full report CSV
Board,examples/ArduinoIoTCloud-Advanced<br>flash,examples/ArduinoIoTCloud-Advanced<br>RAM for global variables,examples/ArduinoIoTCloud-Basic<br>flash,examples/ArduinoIoTCloud-Basic<br>RAM for global variables,examples/utility/ArduinoIoTCloud_Travis_CI<br>flash,examples/utility/ArduinoIoTCloud_Travis_CI<br>RAM for global variables,examples/utility/Provisioning<br>flash,examples/utility/Provisioning<br>RAM for global variables
arduino:samd:mkrgsm1400,1176,16,1176,16,464,16,-40,16
arduino:samd:mkrwan1300,0,0,0,0,0,0,,
arduino:samd:mkrwifi1010,1200,16,1200,16,496,16,-48,16
arduino:samd:nano_33_iot,1200,16,1200,16,488,16,-48,16

…f that line seems to be compiler version dependent
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Jul 20, 2020
@aentinger aentinger marked this pull request as ready for review July 20, 2020 12:57
@aentinger aentinger merged commit b6a1257 into master Jul 20, 2020
@aentinger aentinger deleted the sha256-firmware-image branch July 20, 2020 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants