From 80c550f5ec4e3de20fe808819b5fe4e093d95873 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Sat, 5 Mar 2022 23:32:33 -0500 Subject: [PATCH] v1.8.1 to add `waitingForDRD()` function ### Releases v1.8.1 1. Add waitingForDRD() function to signal in DRD wating period. Check [DRD is waiting for a double reset? #14](https://github.com/khoih-prog/ESP_DoubleResetDetector/discussions/14) 2. Add example [checkWaitingDRD](https://github.com/khoih-prog/DoubleResetDetector_Generic/tree/master/examples/checkWaitingDRD) to demo how to use the new feature. 3. Add support to `Sparkfun Pro nRF52840 Mini` 4. Update `Packages' Patches` --- CONTRIBUTING.md | 7 +- README.md | 127 ++++++++---------------- changelog.md | 8 ++ library.json | 2 +- library.properties | 2 +- src/DoubleResetDetector_Generic.h | 152 +++++++++++++++++++++-------- src/mbed_portenta/FlashIAPLimits.h | 3 +- 7 files changed, 173 insertions(+), 128 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3f0d872..604df33 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: * Arduino IDE version (e.g. 1.8.19) or Platform.io version -* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.12, Adafruit SAMD core v1.7.7, Seeed Studio SAMD v1.8.2) +* `SAMD` Core Version (e.g. Arduino SAMD core v1.8.13, Adafruit SAMD core v1.7.9, Seeed Studio SAMD v1.8.2) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -27,9 +27,9 @@ Please ensure to specify the following: ``` Arduino IDE version: 1.8.19 -Arduino SAMD Core Version 1.8.12 +Arduino SAMD Core Version 1.8.13 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux +Linux kh-Inspiron-3593 5.4.0-100-generic #113-Ubuntu SMP Thu Feb 3 18:43:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux Context: I encountered an endless loop while trying to connect to Local WiFi. @@ -50,3 +50,4 @@ There are usually some outstanding feature requests in the [existing issues list ### Sending Pull Requests Pull Requests with changes and fixes are also welcome! + diff --git a/README.md b/README.md index 1e9b613..203b67e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](#Contributing) [![GitHub issues](https://img.shields.io/github/issues/khoih-prog/DoubleResetDetector_Generic.svg)](http://github.com/khoih-prog/DoubleResetDetector_Generic/issues) -Buy Me A Coffee +Donate to my libraries using BuyMeACoffee + --- --- @@ -43,6 +44,7 @@ * [How It Works](#how-it-works) * [Examples](#examples) * [ 1. minimal](examples/minimal) + * [ 2. checkWaitingDRD](examples/checkWaitingDRD) **New** * [Many other libraries are depending on this library's DRD feature](#many-other-libraries-are-depending-on-this-librarys-drd-feature) * [ 1. BlynkEthernet_WM](https://github.com/khoih-prog/BlynkEthernet_WM) * [ 2. Blynk_Esp8266AT_WM](https://github.com/khoih-prog/Blynk_Esp8266AT_WM) @@ -54,7 +56,7 @@ * [ 8. Ethernet_Manager](https://github.com/khoih-prog/Ethernet_Manager) * [ 9. Ethernet_Manager_STM32](https://github.com/khoih-prog/Ethernet_Manager_STM32) * [10. WiFiManager_Generic_Lite](https://github.com/khoih-prog/WiFiManager_Generic_Lite) -* [Example minimal](#example-minimal) +* [Example checkWaitingDRD](#example-checkWaitingDRD) * [Debug Terminal Output Samples](#debug-terminal-output-samples) * [1. SAMD_WiFiNINA on SAMD NANO_33_IOT using FlashStorage_SAMD](#1-samd_wifinina-on-samd-nano_33_iot-using-flashstorage_samd) * [1.1 DRD Not Detected](#11-drd-not-detected) @@ -133,7 +135,9 @@ This library can be used to detect a double reset within a predetermined time to This [**DoubleResetDetector_Generic** library](https://github.com/khoih-prog/DoubleResetDetector_Generic) currently supports these following boards: - 1. **nRF52 boards**, such as **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.** + 1. **nRF52 boards**, such as + - **AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc.** + - - **Sparkfun Pro nRF52840 Mini** 2. **SAM DUE** @@ -188,14 +192,14 @@ This [**DoubleResetDetector_Generic** library](https://github.com/khoih-prog/Dou 2. [`Arduino Core for STM32 v2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest) 3. [`Teensy core 1.56+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0, LC) boards 4. [`Arduino SAM DUE core 1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards - 5. [`Arduino SAMD core 1.8.12+`](https://www.arduino.cc/en/Guide/ArduinoM0) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) - 6. [`Adafruit SAMD core 1.7.8+`](https://www.adafruit.com/) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) + 5. [`Arduino SAMD core 1.8.13+`](https://www.arduino.cc/en/Guide/ArduinoM0) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) + 6. [`Adafruit SAMD core 1.7.9+`](https://www.adafruit.com/) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) 7. [`Seeeduino SAMD core 1.8.2+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) 8. [`Adafruit nRF52 v1.3.0+`](https://www.adafruit.com) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) - 9. [`Earle Philhower's arduino-pico core v1.10.0+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) -10. [`Arduino mbed_rp2040 core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) -11. [`Arduino mbed_nano core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) MBED nRF52840-based boards such as **Nano_33_BLE, Nano_33_BLE_Sense**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) -12. [`ArduinoCore-mbed mbed_portenta core 2.6.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino **Portenta_H7**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) + 9. [`Earle Philhower's arduino-pico core v1.12.0+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) +10. [`Arduino mbed_rp2040 core 2.7.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) +11. [`Arduino mbed_nano core 2.7.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) MBED nRF52840-based boards such as **Nano_33_BLE, Nano_33_BLE_Sense**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) +12. [`ArduinoCore-mbed mbed_portenta core 2.7.2+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino **Portenta_H7**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) 13. [`Arduino AmebaD core 3.1.2+`](https://github.com/ambiot/ambd_arduino) for Realtek RTL8720DN, RTL8722DM and RTL8722CSM, etc. boards. [![GitHub release](https://img.shields.io/github/release/ambiot/ambd_arduino.svg)](https://github.com/ambiot/ambd_arduino/releases/latest) 14. [`FlashStorage_SAMD library v1.3.2+`](https://github.com/khoih-prog/FlashStorage_SAMD) for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.). [![GitHub release](https://img.shields.io/github/release/khoih-prog/FlashStorage_SAMD.svg)](https://github.com/khoih-prog/FlashStorage_SAMD/releases/latest) @@ -227,7 +231,7 @@ Another way to install is to: 1. Install [VS Code](https://code.visualstudio.com/) 2. Install [PlatformIO](https://platformio.org/platformio-ide) -3. Install [**DoubleResetDetector_Generic** library](https://platformio.org/lib/show/7240/DoubleResetDetector_Generic) by using [Library Manager](https://platformio.org/lib/show/7240/DoubleResetDetector_Generic/installation). Search for **DoubleResetDetector_Generic** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) +3. Install [**DoubleResetDetector_Generic** library](https://registry.platformio.org/libraries/khoih-prog/DoubleResetDetector_Generic) by using [Library Manager](https://registry.platformio.org/libraries/khoih-prog/DoubleResetDetector_Generic/installation). Search for **DoubleResetDetector_Generic** in [Platform.io Author's Libraries](https://platformio.org/lib/search?query=author:%22Khoi%20Hoang%22) 4. Use included [platformio.ini](platformio/platformio.ini) file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at [Project Configuration File](https://docs.platformio.org/page/projectconf.html) --- @@ -299,13 +303,13 @@ This file must be copied into the directory: #### 4. For Arduino SAMD boards - ***To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD Packages_Patches](Packages_Patches/arduino/hardware/samd/1.8.12) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.12). + ***To be able to compile, run and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards***, you have to copy the whole [Arduino SAMD Packages_Patches](Packages_Patches/arduino/hardware/samd/1.8.13) directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.13). #### For core version v1.8.10+ -Supposing the Arduino SAMD version is 1.8.12. Now only one file must be copied into the directory: +Supposing the Arduino SAMD version is 1.8.13. Now only one file must be copied into the directory: -- `~/.arduino15/packages/arduino/hardware/samd/1.8.12/platform.txt` +- `~/.arduino15/packages/arduino/hardware/samd/1.8.13/platform.txt` Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz @@ -338,13 +342,13 @@ Whenever the above-mentioned compiler error issue is fixed with the new Arduino #### 5. For Adafruit SAMD boards - ***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.7) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.7). + ***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.9) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.9). -Supposing the Adafruit SAMD core version is 1.7.7. This file must be copied into the directory: +Supposing the Adafruit SAMD core version is 1.7.9. This file must be copied into the directory: -- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/platform.txt` -- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/cores/arduino/Print.h` -- `~/.arduino15/packages/adafruit/hardware/samd/1.7.7/cores/arduino/Print.cpp` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp` Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory: @@ -446,12 +450,12 @@ With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add #### 9. For Portenta_H7 boards using Arduino IDE in Linux - **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh). + **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh). Then run the following command using `sudo` ``` -$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1 +$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/2.7.2 $ chmod 755 portenta_post_install.sh $ sudo ./portenta_post_install.sh ``` @@ -464,9 +468,9 @@ This will create the file `/etc/udev/rules.d/49-portenta_h7.rules` as follows: SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666" ``` -Supposing the ArduinoCore-mbed core version is 2.6.1. Now only one file must be copied into the directory: +Supposing the ArduinoCore-mbed core version is 2.7.2. Now only one file must be copied into the directory: -- `~/.arduino15/packages/arduino/hardware/mbed_portenta/2.6.1/portenta_post_install.sh` +- `~/.arduino15/packages/arduino/hardware/mbed_portenta/2.7.2/portenta_post_install.sh` Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz @@ -492,6 +496,7 @@ Detects a double reset so that an alternative start-up mode can be used. One exa ### Examples: 1. [minimal](examples/minimal) + 2. [checkWaitingDRD](examples/checkWaitingDRD) **New** #### Many other libraries are depending on this library's DRD feature @@ -513,57 +518,10 @@ Detects a double reset so that an alternative start-up mode can be used. One exa --- --- -#### Example [minimal](examples/minimal) +#### Example [checkWaitingDRD](examples/checkWaitingDRD) -```cpp -#define DRD_GENERIC_DEBUG true //false - -#include - -// Number of seconds after reset during which a -// subseqent reset will be considered a double reset. -#define DRD_TIMEOUT 10 - -// RTC Memory Address for the DoubleResetDetector to use -#define DRD_ADDRESS 0 - -DoubleResetDetector_Generic* drd; - -#ifndef LED_BUILTIN -#define LED_BUILTIN 13 -#endif - -void setup() -{ - pinMode(LED_BUILTIN, OUTPUT); +https://github.com/khoih-prog/DoubleResetDetector_Generic/blob/5216729d2ebfb6d350dc39ebf8c4b8f3cab4ac39/examples/checkWaitingDRD/checkWaitingDRD.ino#L57-L164 - Serial.begin(115200); - while (!Serial); - - Serial.println(); - Serial.println("DoubleResetDetector Example Program"); - Serial.println("-----------------------------------"); - - drd = new DoubleResetDetector_Generic(DRD_TIMEOUT, DRD_ADDRESS); - - if (drd->detectDoubleReset()) { - Serial.println("Double Reset Detected"); - digitalWrite(LED_BUILTIN, LOW); - } else { - Serial.println("No Double Reset Detected"); - digitalWrite(LED_BUILTIN, HIGH); - } -} - -void loop() -{ - // Call the double reset detector loop method every so often, - // so that it can recognise when the timeout expires. - // You can also call drd.stop() when you wish to no longer - // consider the next reset as a double reset. - drd->loop(); -} -``` --- --- @@ -628,7 +586,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on RASPBERRY_PI_PICO -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS Flag read = 0xd0d04321 Flag read = 0xd0d04321 @@ -650,7 +608,7 @@ ClearFlag write = 0xd0d04321 ``` DoubleResetDetector minimal Example Program on RASPBERRY_PI_PICO -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS Flag read = 0xd0d01234 Flag read = 0xd0d01234 @@ -672,7 +630,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on RaspberryPi Pico -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -696,7 +654,7 @@ ClearFlag write = 0xd0d04321 ``` DoubleResetDetector minimal Example Program on RaspberryPi Pico -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -720,7 +678,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on Nano RP2040 Connect -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -744,7 +702,7 @@ ClearFlag write = 0xd0d04321 ``` DoubleResetDetector minimal Example Program on Nano RP2040 Connect -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -769,7 +727,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on Rtlduino RTL8720DN -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- Flag read = 0xbeefdeed No doubleResetDetected @@ -783,7 +741,7 @@ No Double Reset Detected ``` DoubleResetDetector minimal Example Program on Rtlduino RTL8720DN -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- Flag read = 0xd0d01234 doubleResetDetected @@ -802,7 +760,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on Nano 33 BLE -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -826,7 +784,7 @@ ClearFlag write = 0xd0d04321 ``` DoubleResetDetector minimal Example Program on Nano 33 BLE -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- LittleFS size (KB) = 64 LittleFS Mount OK @@ -850,7 +808,7 @@ This is the terminal output when running [minimal](examples/minimal) example on ``` DoubleResetDetector minimal Example Program on PORTENTA_H7_M7 -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x8080000 @@ -871,7 +829,7 @@ No Double Reset Detected ``` DoubleResetDetector minimal Example Program on PORTENTA_H7_M7 -DoubleResetDetector_Generic v1.8.0 +DoubleResetDetector_Generic v1.8.1 ----------------------------------- Flash Size: (KB) = 2048.00 FlashIAP Start Address: = 0x8080000 @@ -974,7 +932,8 @@ Submit issues to: [DoubleResetDetector_Generic issues](https://github.com/khoih- 19. Update to be compatible with new `FlashStorage_SAMD`, `FlashStorage_STM32` and `FlashStorage_STM32F1` libraries. 20. Use more efficient `FlashStorage_STM32` and `FlashStorage_STM32F1` libraries for STM32 21. Add support to more `SAMD` and `STM32` boards - +22. Add support to `Sparkfun Pro nRF52840 Mini` +23. Add waitingForDRD() function to signal in DRD wating period --- --- diff --git a/changelog.md b/changelog.md index bd298e8..c2cb4f0 100644 --- a/changelog.md +++ b/changelog.md @@ -12,6 +12,7 @@ ## Table of Contents * [Changelog](#changelog) + * [Releases v1.8.1](#releases-v181) * [Releases v1.8.0](#releases-v180) * [Releases v1.7.3](#releases-v173) * [Releases v1.7.2](#releases-v172) @@ -33,6 +34,13 @@ ## Changelog +### Releases v1.8.1 + +1. Add waitingForDRD() function to signal in DRD wating period. Check [DRD is waiting for a double reset? #14](https://github.com/khoih-prog/ESP_DoubleResetDetector/discussions/14) +2. Add example [checkWaitingDRD](https://github.com/khoih-prog/DoubleResetDetector_Generic/tree/master/examples/checkWaitingDRD) to demo how to use the new feature. +3. Add support to `Sparkfun Pro nRF52840 Mini` +4. Update `Packages' Patches` + ### Releases v1.8.0 1. Update to be compatible with new `FlashStorage_SAMD`, `FlashStorage_STM32` and `FlashStorage_STM32F1` libraries. diff --git a/library.json b/library.json index f25ba4d..98d83ad 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "DoubleResetDetector_Generic", - "version": "1.8.0", + "version": "1.8.1", "keywords": "device, control, eeprom, flashstorage-samd, flashstorage-stm32, nano-rp2040-connect, nano-33-ble, teensy, sam-due, samd, stm32, nRF52, double-reset, flashstorage, mbed-portenta, portenta-h7, portentah7, dueflashstorage, littlefs, spiffs, flashstorage-rtl8720, mbed, rpi-pico, rp2040, raspberry-pico, multi-reset, reset, detector, data", "description": "Library to detect a double reset, using EEPROM, DueFlashStorage, FlashStorage_SAMD, FlashStorage_RTL8720, FlashStorage_STM32 or LittleFS/InternalFS. For AVR, Teensy, SAM DUE, SAMD, STM32F/L/H/G/WB/MP1, nRF52, RP2040-based Nano_RP2040_Connect, RASPBERRY_PI_PICO, RTL8720DN, MBED nRF52840-based Nano_33_BLE, Portenta_H7, etc. boards. Now using efficient FlashStorage_STM32 library and supporting new RP2040-based Nano_RP2040_Connect, Portenta_H7, RASPBERRY_PI_PICO and STM32 core v2.0.0", "authors": diff --git a/library.properties b/library.properties index 45c379a..be7024b 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DoubleResetDetector_Generic -version=1.8.0 +version=1.8.1 author=Khoi Hoang maintainer=Khoi Hoang license=MIT diff --git a/src/DoubleResetDetector_Generic.h b/src/DoubleResetDetector_Generic.h index 4f7effc..81b542b 100644 --- a/src/DoubleResetDetector_Generic.h +++ b/src/DoubleResetDetector_Generic.h @@ -11,7 +11,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/DoubleResetDetector_Generic Licensed under MIT license - Version: 1.8.0 + Version: 1.8.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -30,6 +30,7 @@ 1.7.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug 1.7.3 K Hoang 10/10/2021 Update `platform.ini` and `library.json` 1.8.0 K Hoang 26/01/2022 Update to be compatible with new FlashStorage libraries. Add support to more SAMD/STM32 boards + 1.8.1 K Hoang 05/03/2022 Add waitingForDRD() function to signal in DRD wating period **********************************************************************************************************************************/ #pragma once @@ -37,14 +38,18 @@ #ifndef DoubleResetDetector_Generic_H #define DoubleResetDetector_Generic_H +#ifndef DRD_GENERIC_DEBUG + #define DRD_GENERIC_DEBUG false +#endif + #ifndef DOUBLERESETDETECTOR_GENERIC_VERSION - #define DOUBLERESETDETECTOR_GENERIC_VERSION "DoubleResetDetector_Generic v1.8.0" + #define DOUBLERESETDETECTOR_GENERIC_VERSION "DoubleResetDetector_Generic v1.8.1" #define DOUBLERESETDETECTOR_GENERIC_VERSION_MAJOR 1 #define DOUBLERESETDETECTOR_GENERIC_VERSION_MINOR 8 - #define DOUBLERESETDETECTOR_GENERIC_VERSION_PATCH 0 + #define DOUBLERESETDETECTOR_GENERIC_VERSION_PATCH 1 -#define DOUBLERESETDETECTOR_GENERIC_VERSION_INT 1008000 +#define DOUBLERESETDETECTOR_GENERIC_VERSION_INT 1008001 #endif @@ -90,7 +95,10 @@ #undef DRD_GENERIC_USE_EEPROM #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use SAM-DUE and DueFlashStorage + + #if (DRD_GENERIC_DEBUG) + #warning Use SAM-DUE and DueFlashStorage + #endif ///////////////////////////// #elif ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ @@ -109,7 +117,10 @@ #undef DRD_GENERIC_USE_EEPROM #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use SAMD and FlashStorage + + #if (DRD_GENERIC_DEBUG) + #warning Use SAMD and FlashStorage + #endif ///////////////////////////// #elif ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ @@ -125,8 +136,11 @@ #undef DRD_GENERIC_USE_EEPROM #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use NRF52 and LittleFS / InternalFS - + + #if (DRD_GENERIC_DEBUG) + #warning Use NRF52 and LittleFS / InternalFS + #endif + ///////////////////////////// #elif ( defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED) ) @@ -140,8 +154,10 @@ #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use RP2040 (such as RASPBERRY_PI_PICO) and LittleFS - + #if (DRD_GENERIC_DEBUG) + #warning Use RP2040 (such as RASPBERRY_PI_PICO) and LittleFS + #endif + ///////////////////////////// #elif ( defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_ARCH_MBED) ) @@ -149,7 +165,11 @@ // To check and determine if we need to init LittleFS here #if MBED_RP2040_INITIALIZED #define DRD_MBED_LITTLEFS_NEED_INIT false - #warning MBED_RP2040_INITIALIZED in another place + + #if (DRD_GENERIC_DEBUG) + #warning MBED_RP2040_INITIALIZED in another place + #endif + #else // Better to delay until init done #if defined(MBED_RP2040_INITIALIZED) @@ -170,8 +190,10 @@ #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use MBED RP2040 (such as NANO_RP2040_CONNECT, RASPBERRY_PI_PICO) and LittleFS - + #if (DRD_GENERIC_DEBUG) + #warning Use MBED RP2040 (such as NANO_RP2040_CONNECT, RASPBERRY_PI_PICO) and LittleFS + #endif + ///////////////////////////// #elif ( ( defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) ) && defined(ARDUINO_ARCH_MBED) ) @@ -180,10 +202,16 @@ #endif #if defined(CORE_CM7) - #warning Using Portenta H7 M7 core + #if (DRD_GENERIC_DEBUG) + #warning Using Portenta H7 M7 core + #endif + #define BOARD_NAME "PORTENTA_H7_M7" #else - #warning Using Portenta H7 M4 core + #if (DRD_GENERIC_DEBUG) + #warning Using Portenta H7 M4 core + #endif + #define BOARD_NAME "PORTENTA_H7_M4" #endif @@ -191,7 +219,11 @@ // To check and determine if we need to init LittleFS here #if MBED_PORTENTA_H7_INITIALIZED #define DRD_MBED_LITTLEFS_NEED_INIT false - #warning MBED_PORTENTA_H7_INITIALIZED in another place + + #if (DRD_GENERIC_DEBUG) + #warning MBED_PORTENTA_H7_INITIALIZED in another place + #endif + #else // Better to delay until init done #if defined(MBED_PORTENTA_H7_INITIALIZED) @@ -212,7 +244,9 @@ #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use MBED PORTENTA_H7 and LittleFS + #if (DRD_GENERIC_DEBUG) + #warning Use MBED PORTENTA_H7 and LittleFS + #endif ///////////////////////////// #elif ( defined(ARDUINO_ARCH_NRF52840) && defined(ARDUINO_ARCH_MBED) && defined(ARDUINO_ARDUINO_NANO33BLE) ) @@ -221,7 +255,11 @@ // To check and determine if we need to init LittleFS here #if NANO33BLE_INITIALIZED #define DRD_NANO33BLE_NEED_INIT false - #warning NANO33BLE_INITIALIZED in another place + + #if (DRD_GENERIC_DEBUG) + #warning NANO33BLE_INITIALIZED in another place + #endif + #else // Better to delay until init done #if defined(NANO33BLE_INITIALIZED) @@ -242,7 +280,9 @@ #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use MBED nRF52840 (such as Nano_33_BLE, Nano_33_BLE_Sense) and LittleFS + #if (DRD_GENERIC_DEBUG) + #warning Use MBED nRF52840 (such as Nano_33_BLE, Nano_33_BLE_Sense) and LittleFS + #endif ///////////////////////////// #elif defined(CONFIG_PLATFORM_8721D) @@ -255,7 +295,10 @@ #undef DRD_GENERIC_USE_EEPROM #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use RTL8720 and FlashStorage_RTL8720 + + #if (DRD_GENERIC_DEBUG) + #warning Use RTL8720 and FlashStorage_RTL8720 + #endif #elif ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \ defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \ @@ -270,20 +313,35 @@ #undef DRD_GENERIC_USE_EEPROM #endif #define DRD_GENERIC_USE_EEPROM false - #warning Use STM32 and FlashStorage_STM32 + + #if (DRD_GENERIC_DEBUG) + #warning Use STM32 and FlashStorage_STM32 + #endif + ///////////////////////////// #else #if defined(CORE_TEENSY) - #warning Use TEENSY and EEPROM + #if (DRD_GENERIC_DEBUG) + #warning Use TEENSY and EEPROM + #endif + #elif ( defined(ARDUINO_AVR_ADK) || defined(ARDUINO_AVR_BT) || defined(ARDUINO_AVR_DUEMILANOVE) || defined(ARDUINO_AVR_ESPLORA) \ || defined(ARDUINO_AVR_ETHERNET) || defined(ARDUINO_AVR_FIO) || defined(ARDUINO_AVR_GEMMA) || defined(ARDUINO_AVR_LEONARDO) \ || defined(ARDUINO_AVR_LILYPAD) || defined(ARDUINO_AVR_LILYPAD_USB) || defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) \ || defined(ARDUINO_AVR_MICRO) || defined(ARDUINO_AVR_MINI) || defined(ARDUINO_AVR_NANO) || defined(ARDUINO_AVR_NG) \ || defined(ARDUINO_AVR_PRO) || defined(ARDUINO_AVR_ROBOT_CONTROL) || defined(ARDUINO_AVR_ROBOT_MOTOR) || defined(ARDUINO_AVR_UNO) \ - || defined(ARDUINO_AVR_YUN) ) - #warning Use AVR and EEPROM + || defined(ARDUINO_AVR_YUN) ) + + #if (DRD_GENERIC_DEBUG) + #warning Use AVR and EEPROM + #endif + #else - #warning Use Unknown board and EEPROM + + #if (DRD_GENERIC_DEBUG) + #warning Use Unknown board and EEPROM + #endif + #endif #endif ///////////////////////////// @@ -376,8 +434,10 @@ #endif #define DRD_FILENAME "/fs/drd.dat" - #warning DRD_MBED_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic - + #if (DRD_GENERIC_DEBUG) + #warning DRD_MBED_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic + #endif + ///////////////////////////// #elif (DRD_GENERIC_USE_MBED_PORTENTA && DRD_PORTENTA_LITTLEFS_NEED_INIT) @@ -411,8 +471,10 @@ #endif #define DRD_FILENAME "/littlefs/drd.dat" - #warning DRD_PORTENTA_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic - + #if (DRD_GENERIC_DEBUG) + #warning DRD_PORTENTA_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic + #endif + ///////////////////////////// #elif (DRD_GENERIC_USE_NANO33BLE && DRD_NANO33BLE_NEED_INIT) @@ -466,8 +528,9 @@ #endif #define DRD_FILENAME "/littlefs/drd.dat" - #warning DRD_NANO33BLE_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic - + #if (DRD_GENERIC_DEBUG) + #warning DRD_NANO33BLE_LITTLEFS INITIALIZED locally in DoubleResetDetector_Generic + #endif ///////////////////////////// #elif DRD_GENERIC_USE_STM32 @@ -477,7 +540,11 @@ #if defined(DATA_EEPROM_BASE) // For STM32 devices having integrated EEPROM. #include - #warning STM32 devices have integrated EEPROM. Not using buffered API. + + #if (DRD_GENERIC_DEBUG) + #warning STM32 devices have integrated EEPROM. Not using buffered API. + #endif + #else /** Most STM32 devices don't have an integrated EEPROM. To emulate a EEPROM, the STM32 Arduino core emulated @@ -489,10 +556,18 @@ */ #if ( defined(STM32F1xx) || defined(STM32F3xx) ) #include // https://github.com/khoih-prog/FlashStorage_STM32 - #warning STM32F1/F3 devices have no integrated EEPROM. Using buffered API with FlashStorage_STM32F1 library + + #if (DRD_GENERIC_DEBUG) + #warning STM32F1/F3 devices have no integrated EEPROM. Using buffered API with FlashStorage_STM32F1 library + #endif + #else #include // https://github.com/khoih-prog/FlashStorage_STM32 - #warning STM32 devices have no integrated EEPROM. Using buffered API with FlashStorage_STM32 library + + #if (DRD_GENERIC_DEBUG) + #warning STM32 devices have no integrated EEPROM. Using buffered API with FlashStorage_STM32 library + #endif + #endif #endif // #if defined(DATA_EEPROM_BASE) @@ -508,10 +583,6 @@ ///////////////////////////////////////////// -#ifndef DRD_GENERIC_DEBUG - #define DRD_GENERIC_DEBUG false -#endif - #define DOUBLERESETDETECTOR_GENERIC_FLAG_SET 0xD0D01234 #define DOUBLERESETDETECTOR_GENERIC_FLAG_CLEAR 0xD0D04321 @@ -740,6 +811,11 @@ class DoubleResetDetector_Generic }; + bool waitingForDRD() + { + return waitingForDoubleReset; + } + ///////////////////////////////////////////// void loop() diff --git a/src/mbed_portenta/FlashIAPLimits.h b/src/mbed_portenta/FlashIAPLimits.h index 0d72d18..bfa2646 100644 --- a/src/mbed_portenta/FlashIAPLimits.h +++ b/src/mbed_portenta/FlashIAPLimits.h @@ -12,7 +12,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/DoubleResetDetector_Generic Licensed under MIT license - Version: 1.8.0 + Version: 1.8.1 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -31,6 +31,7 @@ 1.7.2 K Hoang 14/09/2021 Back to using auto LittleFS to fix bug 1.7.3 K Hoang 10/10/2021 Update `platform.ini` and `library.json` 1.8.0 K Hoang 26/01/2022 Update to be compatible with new FlashStorage libraries. Add support to more SAMD/STM32 boards + 1.8.1 K Hoang 05/03/2022 Add waitingForDRD() function to signal in DRD wating period **********************************************************************************************************************************/ #pragma once