Skip to content
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

OTA protocol v3 #2199

Merged
merged 61 commits into from
Nov 23, 2020
Merged

OTA protocol v3 #2199

merged 61 commits into from
Nov 23, 2020

Conversation

sergeuz
Copy link
Member

@sergeuz sergeuz commented Sep 14, 2020

Problem

This PR implements the OTA protocol v3 and adds support for resumable firmware updates. The protocol is heavily based on SCTP and thus some familiarity with RFC 4960 will be helpful to understand it better. The SDD for the protocol can be found here.

Both features (the protocol and resumable updates) can be enabled/disabled independently at compile time via the platform feature macros HAL_PLATFORM_OTA_PROTOCOL_V3 and HAL_PLATFORM_RESUMABLE_OTA, although, at present, resumable updates require the new protocol in order to work.

Other internal features and refactoring introduced in this PR:

  • The system code responsible for firmware updates is now isolated in the singleton class system::FirmwareUpdate. Legacy APIs (Spark_Prepare_For_Firmware_Update(), etc.) now use the new class internally.
  • Last error message API (see system_error.h). The intent is to provide meaningful error messages to the server in failed CoAP responses – for diagnostic purposes.
  • New classes for encoding/decoding CoAP messages: CoapMessageEncoder, CoapMessageDecoder.
  • The new SimpleFileStorage class allows saving/loading an arbitrary structure to/from a file in a way optimized for LittleFS.
  • New high-level classes that mock the filesystem and cloud protocol's message channel APIs to simplify unit testing.
  • CC310 backend for mbedTLS has been refactored to better support operations defined by the mbedTLS' message digest API (such as cloning contexts).
  • Helper classes for SHA-256 and HMAC-SHA-256 computation have been moved to services, so they're now can be used outside the context of BLE control requests.
  • Maximum OTA chunk size is now determined by MBEDTLS_SSL_MAX_CONTENT_LEN. Note that this PR still uses 512-byte chunks.

Steps to Test

  • Run unit tests.
  • Test OTA firmware updates on Gen 3 platforms using the staging server.
  • Test OTA firmware updates on Gen 2 platforms.
  • Test firmware updates via YModem and control requests.
  • Test device setup over BLE.

@sergeuz sergeuz added this to the 3.0.0 milestone Sep 14, 2020
@sergeuz sergeuz force-pushed the ota_v3/ch55392 branch 2 times, most recently from 5a44800 to a97a44a Compare September 21, 2020 15:19
services/inc/underlying_type.h Show resolved Hide resolved
communication/src/coap_message_decoder.cpp Show resolved Hide resolved
communication/src/coap_message_encoder.cpp Show resolved Hide resolved
communication/src/coap_message_encoder.cpp Show resolved Hide resolved
hal/src/nRF52840/mbedtls/sha256_alt.h Show resolved Hide resolved
services/inc/c_string.h Show resolved Hide resolved
user/makefile Outdated Show resolved Hide resolved
system/src/firmware_update.cpp Show resolved Hide resolved
system/src/firmware_update.cpp Outdated Show resolved Hide resolved
communication/src/firmware_update.cpp Show resolved Hide resolved
@sergeuz sergeuz force-pushed the ota_v3/ch55392 branch 3 times, most recently from c92e8ab to b338dcb Compare November 18, 2020 17:59
…tion and use the global disconnection settings instead
@sergeuz sergeuz merged commit 95d7fe9 into develop Nov 23, 2020
@sergeuz sergeuz deleted the ota_v3/ch55392 branch November 23, 2020 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants