From abf57318ccd5b4b18f913d27ff99166daf8668ec Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 7 Jul 2020 07:03:20 +0200 Subject: [PATCH 1/4] Automatically include SSU and set-up everything for OTA upload when building for a MKR GSM board --- src/ArduinoIoTCloudTCP.cpp | 11 ++++++++--- src/ArduinoIoTCloud_Config.h | 8 +++----- src/utility/ota/OTAStorage_MKRGSM.h | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 705f5d36b..0555424ff 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -29,6 +29,7 @@ #include "tls/utility/CryptoUtil.h" #endif +#include "utility/ota/OTAStorage_MKRGSM.h" #include "utility/ota/OTAStorage_MKRMEM.h" #include "cbor/CBOREncoder.h" @@ -39,9 +40,11 @@ TimeService time_service; -#if OTA_STORAGE_MKRMEM +#if OTA_STORAGE_MKRGSM + static OTAStorage_MKRGSM ota_storage_ssu; +#elif OTA_STORAGE_MKRMEM static OTAStorage_MKRMEM ota_storage_sfu; -#endif /* OTA_STORAGE_MKRMEM */ +#endif /****************************************************************************** GLOBAL CONSTANTS @@ -141,7 +144,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort) printConnectionStatus(_iot_status); -#if OTA_STORAGE_MKRMEM +#if OTA_STORAGE_MKRGSM + setOTAStorage(ota_storage_ssu); +#elif OTA_STORAGE_MKRMEM setOTAStorage(ota_storage_sfu); #endif /* OTA_STORAGE_MKRMEM */ diff --git a/src/ArduinoIoTCloud_Config.h b/src/ArduinoIoTCloud_Config.h index 2d05b8d9e..b63ab3df1 100644 --- a/src/ArduinoIoTCloud_Config.h +++ b/src/ArduinoIoTCloud_Config.h @@ -26,7 +26,9 @@ #define OTA_STORAGE_MKRMEM (0) #endif -#ifndef OTA_STORAGE_MKRGSM +#ifdef ARDUINO_SAMD_MKRGSM1400 + #define OTA_STORAGE_MKRGSM (1) +#else #define OTA_STORAGE_MKRGSM (0) #endif @@ -34,10 +36,6 @@ * AUTOMATIC CONFIGURED DEFINES ******************************************************************************/ -#if !defined(ARDUINO_SAMD_MKR1000) && !defined(ARDUINO_SAMD_MKRWIFI1010) && !defined(ARDUINO_SAMD_MKRGSM1400) && !defined(ARDUINO_SAMD_MKRNB1500) - #define OTA_STORAGE_MKRMEM (0) -#endif - #if OTA_STORAGE_MKRMEM || OTA_STORAGE_MKRGSM #define OTA_ENABLED (1) #else diff --git a/src/utility/ota/OTAStorage_MKRGSM.h b/src/utility/ota/OTAStorage_MKRGSM.h index d775b94df..7f6f11479 100644 --- a/src/utility/ota/OTAStorage_MKRGSM.h +++ b/src/utility/ota/OTAStorage_MKRGSM.h @@ -25,6 +25,8 @@ #include #if OTA_STORAGE_MKRGSM +#include + #include "OTAStorage.h" #include From 8f05a0d46060cf69ebe24576e5e5d45ac013583d Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 7 Jul 2020 07:13:34 +0200 Subject: [PATCH 2/4] Use the latest ArduinoCore-samd from master, not the latest released version --- .github/workflows/compile-examples.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 2b22feb01..46b055241 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -71,6 +71,8 @@ jobs: - name: Compile examples uses: arduino/actions/libraries/compile-examples@master with: + platforms | + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip fqbn: ${{ matrix.board.fqbn }} libraries: "${{ env.UNIVERSAL_LIBRARIES }} ${{ matrix.libraries }}" sketch-paths: "${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.sketch-paths }}" From a3c8b3f9b302523498ffd5716ddc4f05d510e602 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 7 Jul 2020 07:38:02 +0200 Subject: [PATCH 3/4] Renaming MKRGSM to SSU in order to better reflect that the ota storage is used in combi with the SSU bootloader --- src/ArduinoIoTCloudTCP.cpp | 8 ++++---- src/ArduinoIoTCloud_Config.h | 6 +++--- ...AStorage_MKRGSM.cpp => OTAStorage_SSU.cpp} | 20 +++++++++---------- .../{OTAStorage_MKRGSM.h => OTAStorage_SSU.h} | 14 ++++++------- 4 files changed, 24 insertions(+), 24 deletions(-) rename src/utility/ota/{OTAStorage_MKRGSM.cpp => OTAStorage_SSU.cpp} (82%) rename src/utility/ota/{OTAStorage_MKRGSM.h => OTAStorage_SSU.h} (86%) diff --git a/src/ArduinoIoTCloudTCP.cpp b/src/ArduinoIoTCloudTCP.cpp index 0555424ff..732b39b17 100644 --- a/src/ArduinoIoTCloudTCP.cpp +++ b/src/ArduinoIoTCloudTCP.cpp @@ -29,7 +29,7 @@ #include "tls/utility/CryptoUtil.h" #endif -#include "utility/ota/OTAStorage_MKRGSM.h" +#include "utility/ota/OTAStorage_SSU.h" #include "utility/ota/OTAStorage_MKRMEM.h" #include "cbor/CBOREncoder.h" @@ -40,8 +40,8 @@ TimeService time_service; -#if OTA_STORAGE_MKRGSM - static OTAStorage_MKRGSM ota_storage_ssu; +#if OTA_STORAGE_SSU + static OTAStorage_SSU ota_storage_ssu; #elif OTA_STORAGE_MKRMEM static OTAStorage_MKRMEM ota_storage_sfu; #endif @@ -144,7 +144,7 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort) printConnectionStatus(_iot_status); -#if OTA_STORAGE_MKRGSM +#if OTA_STORAGE_SSU setOTAStorage(ota_storage_ssu); #elif OTA_STORAGE_MKRMEM setOTAStorage(ota_storage_sfu); diff --git a/src/ArduinoIoTCloud_Config.h b/src/ArduinoIoTCloud_Config.h index b63ab3df1..821755b4c 100644 --- a/src/ArduinoIoTCloud_Config.h +++ b/src/ArduinoIoTCloud_Config.h @@ -27,16 +27,16 @@ #endif #ifdef ARDUINO_SAMD_MKRGSM1400 - #define OTA_STORAGE_MKRGSM (1) + #define OTA_STORAGE_SSU (1) #else - #define OTA_STORAGE_MKRGSM (0) + #define OTA_STORAGE_SSU (0) #endif /****************************************************************************** * AUTOMATIC CONFIGURED DEFINES ******************************************************************************/ -#if OTA_STORAGE_MKRMEM || OTA_STORAGE_MKRGSM +#if OTA_STORAGE_MKRMEM || OTA_STORAGE_SSU #define OTA_ENABLED (1) #else #define OTA_ENABLED (0) diff --git a/src/utility/ota/OTAStorage_MKRGSM.cpp b/src/utility/ota/OTAStorage_SSU.cpp similarity index 82% rename from src/utility/ota/OTAStorage_MKRGSM.cpp rename to src/utility/ota/OTAStorage_SSU.cpp index 07731bacb..e060f92ba 100644 --- a/src/utility/ota/OTAStorage_MKRGSM.cpp +++ b/src/utility/ota/OTAStorage_SSU.cpp @@ -20,9 +20,9 @@ ******************************************************************************/ #include -#if OTA_STORAGE_MKRGSM +#if OTA_STORAGE_SSU -#include "OTAStorage_MKRGSM.h" +#include "OTAStorage_SSU.h" /****************************************************************************** CONSTANTS @@ -35,7 +35,7 @@ static char const SSU_CHECK_FILE_NAME[] = "UPDATE.OK"; PUBLIC MEMBER FUNCTIONS ******************************************************************************/ -bool OTAStorage_MKRGSM::init() +bool OTAStorage_SSU::init() { if (!_fileUtils.begin()) return false; @@ -49,28 +49,28 @@ bool OTAStorage_MKRGSM::init() return false; } -bool OTAStorage_MKRGSM::open(char const * /* file_name */) +bool OTAStorage_SSU::open(char const * /* file_name */) { return true; } -size_t OTAStorage_MKRGSM::write(uint8_t const* const buf, size_t const num_bytes) +size_t OTAStorage_SSU::write(uint8_t const* const buf, size_t const num_bytes) { _fileUtils.appendFile(SSU_UPDATE_FILENAME, (const char*)buf, num_bytes); return num_bytes; } -void OTAStorage_MKRGSM::close() +void OTAStorage_SSU::close() { /* Nothing to do */ } -void OTAStorage_MKRGSM::remove(char const * /* file_name */) +void OTAStorage_SSU::remove(char const * /* file_name */) { _fileUtils.deleteFile(SSU_UPDATE_FILENAME); } -bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /* new_file_name */) +bool OTAStorage_SSU::rename(char const * /* old_file_name */, char const * /* new_file_name */) { /* Create a file 'UPDATE.OK' which is used by the SSU * 2nd stage bootloader to recognise that the update @@ -82,9 +82,9 @@ bool OTAStorage_MKRGSM::rename(char const * /* old_file_name */, char const * /* return (_fileUtils.appendFile(SSU_CHECK_FILE_NAME, &c, sizeof(c)) == sizeof(c)); } -void OTAStorage_MKRGSM::deinit() +void OTAStorage_SSU::deinit() { /* Nothing to do */ } -#endif /* OTA_STORAGE_MKRGSM */ +#endif /* OTA_STORAGE_SSU */ diff --git a/src/utility/ota/OTAStorage_MKRGSM.h b/src/utility/ota/OTAStorage_SSU.h similarity index 86% rename from src/utility/ota/OTAStorage_MKRGSM.h rename to src/utility/ota/OTAStorage_SSU.h index 7f6f11479..9ab681a5f 100644 --- a/src/utility/ota/OTAStorage_MKRGSM.h +++ b/src/utility/ota/OTAStorage_SSU.h @@ -15,15 +15,15 @@ a commercial license, send an email to license@arduino.cc. */ -#ifndef ARDUINO_OTA_STORAGE_MKRGSM_H_ -#define ARDUINO_OTA_STORAGE_MKRGSM_H_ +#ifndef ARDUINO_OTA_STORAGE_SSU_H_ +#define ARDUINO_OTA_STORAGE_SSU_H_ /****************************************************************************** * INCLUDE ******************************************************************************/ #include -#if OTA_STORAGE_MKRGSM +#if OTA_STORAGE_SSU #include @@ -35,11 +35,11 @@ * CLASS DECLARATION ******************************************************************************/ -class OTAStorage_MKRGSM : public OTAStorage +class OTAStorage_SSU : public OTAStorage { public: - virtual ~OTAStorage_MKRGSM() { } + virtual ~OTAStorage_SSU() { } virtual bool init () override; @@ -56,6 +56,6 @@ class OTAStorage_MKRGSM : public OTAStorage }; -#endif /* OTA_STORAGE_MKRGSM */ +#endif /* OTA_STORAGE_SSU */ -#endif /* ARDUINO_OTA_STORAGE_MKRGSM_H_ */ +#endif /* ARDUINO_OTA_STORAGE_SSU_H_ */ From 85e7ef7e1d020a4834aa1853e79698f2b3fcd188 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Tue, 7 Jul 2020 07:53:17 +0200 Subject: [PATCH 4/4] Fixing github workflow --- .github/workflows/compile-examples.yml | 64 ++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 46b055241..5ca9b3962 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -18,7 +18,13 @@ jobs: env: # libraries to install for all boards - UNIVERSAL_LIBRARIES: '"Arduino_ConnectionHandler" "Arduino_DebugUtils" "ArduinoMqttClient"' + UNIVERSAL_LIBRARIES: | + # Install the ArduinoIoTCloud library from the repository + - source-path: ./ + - source-url: https://github.com/arduino-libraries/Arduino_ConnectionHandler.git + version: latest + - name: Arduino_DebugUtils + - name: ArduinoMqttClient # sketch paths to compile (recursive) for all boards UNIVERSAL_SKETCH_PATHS: '"examples/ArduinoIoTCloud-Advanced" "examples/ArduinoIoTCloud-Basic" "examples/utility/ArduinoIoTCloud_Travis_CI"' @@ -33,7 +39,7 @@ jobs: {"fqbn": "arduino:samd:mkrwan1300", "type": "wan"}, {"fqbn": "arduino:samd:mkrgsm1400", "type": "gsm"}, {"fqbn": "arduino:samd:mkrnb1500", "type": "nb"}, - {"fqbn": '"esp8266:esp8266:huzzah" "https://arduino.esp8266.com/stable/package_esp8266com_index.json"', "type": "esp8266"} + {"fqbn": "esp8266:esp8266:huzzah", "type": "esp8266"} ] # make board type-specific customizations to the matrix jobs @@ -41,26 +47,65 @@ jobs: # WiFi boards - board: type: "wifi" - libraries: '"ArduinoECCX08" "RTCZero" "WiFi101" "WiFiNINA" "Arduino_MKRMEM"' + platforms: | + # Install Arduino SAMD Boards via Boards Manager for the toolchain + - name: arduino:samd + # Overwrite the Arduino SAMD Boards release version with version from the tip of the master branch + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: WiFi101 + - name: WiFiNINA + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/WiFi_Cloud_Blink"' # LoRaWAN boards - board: type: "wan" - libraries: '"ArduinoECCX08" "RTCZero" "MKRWAN"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: MKRWAN sketch-paths: # GSM boards - board: type: "gsm" - libraries: '"ArduinoECCX08" "RTCZero" "MKRGSM" "Arduino_MKRMEM"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + # Use the version of MKRGSM from the tip of its repository's default branch + - source-url: https://github.com/arduino-libraries/MKRGSM.git + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/GSM_Cloud_Blink"' # NB boards - board: type: "nb" - libraries: '"ArduinoECCX08" "RTCZero" "MKRNB" "Arduino_MKRMEM"' + platforms: | + - name: arduino:samd + - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + name: arduino:samd + libraries: | + - name: ArduinoECCX08 + - name: RTCZero + - name: MKRNB + - name: Arduino_MKRMEM sketch-paths: '"examples/utility/Provisioning" "examples/utility/NB_Cloud_Blink"' # ESP8266 boards - board: type: "esp8266" + platforms: | + # Install ESP8266 platform via Boards Manager + - name: esp8266:esp8266 + source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json libraries: sketch-paths: '"examples/utility/WiFi_Cloud_Blink_with_security_credentials"' @@ -71,10 +116,11 @@ jobs: - name: Compile examples uses: arduino/actions/libraries/compile-examples@master with: - platforms | - - source-url: https://github.com/arduino/ArduinoCore-samd/archive/master.zip + platforms: ${{ matrix.platforms }} fqbn: ${{ matrix.board.fqbn }} - libraries: "${{ env.UNIVERSAL_LIBRARIES }} ${{ matrix.libraries }}" + libraries: | + ${{ env.UNIVERSAL_LIBRARIES }} + ${{ matrix.libraries }} sketch-paths: "${{ env.UNIVERSAL_SKETCH_PATHS }} ${{ matrix.sketch-paths }}" size-report-sketch: 'ArduinoIoTCloud_Travis_CI' enable-size-deltas-report: 'true'