From 3f807a8582c7d028189418ea38f87f51deed07f7 Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 20 Jul 2023 14:03:38 +0200 Subject: [PATCH 1/5] Nano ESP32: enable compile examples workflow --- .github/workflows/compile-examples.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 385ef69..5ffde03 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -37,6 +37,8 @@ jobs: board: - fqbn: "esp32:esp32:esp32" type: esp32 + - fqbn: "arduino:esp32:nano_nora" + type: arduino_esp32 include: - board: @@ -46,6 +48,12 @@ jobs: source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json libraries: | - name: Arduino_DebugUtils + - board: + type: arduino_esp32 + platforms: | + - name: arduino:esp32 + libraries: | + - name: Arduino_DebugUtils steps: - name: Checkout From 6ad4b2265916b36284da9ca74c9e8acd2028354a Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 20 Jul 2023 15:19:31 +0200 Subject: [PATCH 2/5] Add Blink Example for NANO ESP32 --- .../NANO_ESP32_Blink/NANO_ESP32_Blink.ino | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 examples/NANO_ESP32_Blink/NANO_ESP32_Blink.ino diff --git a/examples/NANO_ESP32_Blink/NANO_ESP32_Blink.ino b/examples/NANO_ESP32_Blink/NANO_ESP32_Blink.ino new file mode 100644 index 0000000..8f3bc2a --- /dev/null +++ b/examples/NANO_ESP32_Blink/NANO_ESP32_Blink.ino @@ -0,0 +1,56 @@ +/* + * Blink for Arduino NANO ESP32 board + * + * This sketch can be used to generate an example binary that can be uploaded to ESP32 via OTA. + * It needs to be used together with OTA.ino + * + * Steps to test OTA: + * 1) Upload this sketch or any other sketch (this one this one lights up the RGB LED with different colours). + * 2) In the IDE select: Sketch -> Export compiled Binary + * 3) Upload the exported binary to a server + * 4) Open the related OTA.ino sketch and eventually update the OTA_FILE_LOCATION + * 5) Upload the sketch OTA.ino to perform OTA + */ + +void setLed(int blue, int gree, int red) { + if (blue == 1) { + digitalWrite(LED_BLUE, LOW); + } + else { + digitalWrite(LED_BLUE, HIGH); + } + + if (gree == 1) { + digitalWrite(LED_GREEN, LOW); + } + else { + digitalWrite(LED_GREEN, HIGH); + } + + if (red == 1) { + digitalWrite(LED_RED, LOW); + } + else { + digitalWrite(LED_RED, HIGH); + } +} + + +void setup() +{ + pinMode(LED_BLUE, OUTPUT); + pinMode(LED_GREEN, OUTPUT); + pinMode(LED_RED, OUTPUT); +} + +void loop() +{ // Blue LED on + setLed(1, 0, 0); + delay(1000); + // Green LED on + setLed(0, 1, 0); + delay(1000); + // Red LED on + setLed(0, 0, 1); + delay(1000); +} From b7766b581acb83919110fc34afac7f881454e8ac Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 20 Jul 2023 15:20:54 +0200 Subject: [PATCH 3/5] CI: compile examples using board matrix --- .github/workflows/compile-examples.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 5ffde03..2029e8d 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -48,12 +48,18 @@ jobs: source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json libraries: | - name: Arduino_DebugUtils + sketch-paths: | + - examples/OTA + - examples/LOLIN_32_Blink - board: type: arduino_esp32 platforms: | - name: arduino:esp32 libraries: | - name: Arduino_DebugUtils + sketch-paths: | + - examples/OTA + - examples/NANO_ESP32_Blink steps: - name: Checkout @@ -74,7 +80,7 @@ jobs: - source-path: ./ ${{ matrix.libraries }} sketch-paths: | - - examples + ${{ matrix.sketch-paths }} enable-deltas-report: true sketches-report-path: ${{ env.SKETCHES_REPORTS_PATH }} From bf1398817242f1ce407a204f9c46d2091a3c7919 Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 20 Jul 2023 15:21:28 +0200 Subject: [PATCH 4/5] Add Arduino NANO ESP32 magic number --- src/Arduino_ESP32_OTA.cpp | 2 +- src/Arduino_ESP32_OTA.h | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Arduino_ESP32_OTA.cpp b/src/Arduino_ESP32_OTA.cpp index 6c5ce05..57aad7d 100644 --- a/src/Arduino_ESP32_OTA.cpp +++ b/src/Arduino_ESP32_OTA.cpp @@ -189,7 +189,7 @@ int Arduino_ESP32_OTA::download(const char * ota_url) return static_cast(Error::OtaHeaderLength); } - if (_ota_header.header.magic_number != 0x45535033) + if (_ota_header.header.magic_number != ARDUINO_ESP32_OTA_MAGIC) { return static_cast(Error::OtaHeaterMagicNumber); } diff --git a/src/Arduino_ESP32_OTA.h b/src/Arduino_ESP32_OTA.h index fe07108..fe26f11 100644 --- a/src/Arduino_ESP32_OTA.h +++ b/src/Arduino_ESP32_OTA.h @@ -26,6 +26,14 @@ #include #include "decompress/utility.h" +/****************************************************************************** + DEFINES + ******************************************************************************/ +#if defined (ARDUINO_NANO_ESP32) + #define ARDUINO_ESP32_OTA_MAGIC 0x23410070 +#else + #define ARDUINO_ESP32_OTA_MAGIC 0x45535033 +#endif /****************************************************************************** CONSTANTS ******************************************************************************/ From abe1e64e760003b0a0fb328ee5ca7d0e5b25f93c Mon Sep 17 00:00:00 2001 From: pennam Date: Thu, 20 Jul 2023 16:41:04 +0200 Subject: [PATCH 5/5] OTA Example: add Arduino NANO ESP32 support --- examples/OTA/OTA.ino | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/OTA/OTA.ino b/examples/OTA/OTA.ino index 0736666..d8edc07 100644 --- a/examples/OTA/OTA.ino +++ b/examples/OTA/OTA.ino @@ -36,7 +36,12 @@ static char const SSID[] = SECRET_SSID; /* your network SSID (name) */ static char const PASS[] = SECRET_PASS; /* your network password (use for WPA, or use as key for WEP) */ + +#if defined(ARDUINO_NANO_ESP32) +static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/NANO_ESP32_Blink.ino.ota"; +#else static char const OTA_FILE_LOCATION[] = "https://downloads.arduino.cc/ota/LOLIN_32_Blink.ino.ota"; +#endif /****************************************************************************** * SETUP/LOOP @@ -95,7 +100,11 @@ void setup() } Serial.println("Performing a reset after which the bootloader will start the new firmware."); +#if defined(ARDUINO_NANO_ESP32) + Serial.println("Hint: Arduino NANO ESP32 will blink Red Green and Blue."); +#else Serial.println("Hint: LOLIN32 will blink Blue."); +#endif delay(1000); /* Make sure the serial message gets out before the reset. */ ota.reset(); }