Skip to content

Firmware Over-The-Air (OTA) update capability #118

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 49 commits into from
Jun 3, 2020
Merged

Firmware Over-The-Air (OTA) update capability #118

merged 49 commits into from
Jun 3, 2020

Conversation

aentinger
Copy link
Contributor

@aentinger aentinger commented Apr 27, 2020

This PR intends to provide firmware OTA capability via Arduino IoT Cloud and MKR MEM shield connected to either MR 1000, MR WiFi 1010, MR NB 1500 or MR GSM 1400. The following modifications need to be made to the sketch:

/* ... */
#include <SFU.h>
#include <utility/ota/OTAStorage_MKRMEM.h>
/* ... */
static OTAStorage_MKRMEM ota_storage;
/* ... */
void setup()
{
  /* ... */
  ArduinoCloud.setOTAStorage(ota_storage);
}

Furthermore the desired OTA storage type needs to be configured in ArduinoIoTCloud_Config.h, e.g.

#ifndef OTA_STORAGE_MKRMEM
  #define OTA_STORAGE_MKRMEM      (1)
#endif

The firmware sets the hidden int property OTA_STORAGE_TYPE to one of the following values which allows the cloud to determine which OTA update storage medium is available:

  • OTA_STORAGE_TYPE = -1 -> No OTA storage medium connected, OTA not possible
  • OTA_STORAGE_TYPE = 0 -> MKR MEM Shield connected, OTA possible

If the OTA update file has been downloaded and its checksum verified successfully then a reset is performed and the new firmware is flashed onto the MCU by the second stage SFU bootloader. In case of an error during the update process no reset is performed and the source of the error is written to the hidden int property OTA_ERROR. The following error codes are available:

  • OTA_ERROR = 0 -> No Error
  • OTA_ERROR = 1 -> OTA storage initialisation failed
  • OTA_ERROR = 2 -> OTA storage open failed
  • OTA_ERROR = 3 -> OTA storage write failed
  • OTA_ERROR = 4 -> Checksum mismatch
  • OTA_ERROR = 5 -> Received data overrun (too much data received before it could be processed)

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@aentinger aentinger force-pushed the ota branch 4 times, most recently from ff01fa0 to 4c280bc Compare April 29, 2020 08:32
@github-actions

This comment has been minimized.

@aentinger aentinger force-pushed the ota branch 4 times, most recently from 3267bd4 to 3e9e7ea Compare April 29, 2020 13:31
@aentinger aentinger self-assigned this Apr 30, 2020
@aentinger aentinger added the type: enhancement Proposed improvement label Apr 30, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Apr 30, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot Apr 30, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 4, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 4, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 4, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 5, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 5, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 5, 2020
@aentinger aentinger force-pushed the ota branch 2 times, most recently from f926e46 to cfb5a09 Compare May 5, 2020 05:16
@aentinger aentinger marked this pull request as ready for review May 5, 2020 05:25
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 5, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 5, 2020
…son object containing the base64 encoded binary because otherwise the URL becomes to long for curl to process
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 14, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 14, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 28, 2020
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 28, 2020
…without being allocated on the heap with 'new'
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 28, 2020
…eds to be enabled by the user by configuring OTA_STORAGE_MKRMEM
@arduino-libraries arduino-libraries deleted a comment from github-actions bot May 28, 2020
@github-actions
Copy link

Memory usage change @50927c87408a280bbddc6108a3e1156d81142fbc

FQBN Flash Usage RAM For Global Variables
arduino:samd:mkr1000 🔺 +112 🔺 +8
arduino:samd:mkrgsm1400 🔺 +112 🔺 +16
arduino:samd:mkrnb1500 🔺 +112 🔺 +8
arduino:samd:mkrwan1300 0 0
arduino:samd:mkrwifi1010 🔺 +112 🔺 +8
arduino:samd:nano_33_iot 🔺 +112 🔺 +8
esp8266:esp8266:huzzah 🔺 +88 🔺 +8

@aentinger aentinger merged commit 6a54e17 into master Jun 3, 2020
@aentinger aentinger deleted the ota branch June 3, 2020 08:31
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.

3 participants