From ac7879c683f226cd159560600fabcd6c166dbaea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Proch=C3=A1zka?= <90197375+P-R-O-C-H-Y@users.noreply.github.com> Date: Mon, 15 Aug 2022 14:47:07 +0200 Subject: [PATCH] Added NVS test sketch + test script (#6885) * Added NVS test sketch + test script * Added cfg.json with multiple fqbns * cfg.json missing commas fix * Changed OPI PSRAM to QSPI accordind to new HW setup. * disabled PSRAM for ESP32S3 * Reverting PSRAM changes * Remove Octal flash test Octal flash needs to be tested locally before each release. --- tests/nvs/cfg.json | 39 +++++++++++++++++++++++++++++++++++++++ tests/nvs/nvs.ino | 36 ++++++++++++++++++++++++++++++++++++ tests/nvs/test_nvs.py | 7 +++++++ 3 files changed, 82 insertions(+) create mode 100644 tests/nvs/cfg.json create mode 100644 tests/nvs/nvs.ino create mode 100644 tests/nvs/test_nvs.py diff --git a/tests/nvs/cfg.json b/tests/nvs/cfg.json new file mode 100644 index 000000000..c1b23d468 --- /dev/null +++ b/tests/nvs/cfg.json @@ -0,0 +1,39 @@ +{ + "targets": [ + { + "name": "esp32", + "fqbn":[ + "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40", + "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40" + ] + }, + { + "name": "esp32s2", + "fqbn": [ + "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40", + "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40" + ] + }, + { + "name": "esp32c3", + "fqbn": [ + "espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=dio", + "espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=dout,FlashFreq=40", + "espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32c3:PartitionScheme=huge_app,FlashMode=qout,FlashFreq=40" + ] + }, + { + "name": "esp32s3", + "fqbn": [ + "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio", + "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=qio120", + "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app,FlashMode=dio" + ] + } + ] +} \ No newline at end of file diff --git a/tests/nvs/nvs.ino b/tests/nvs/nvs.ino new file mode 100644 index 000000000..7bfe25ff0 --- /dev/null +++ b/tests/nvs/nvs.ino @@ -0,0 +1,36 @@ +#include + +Preferences preferences; + +void setup() { + Serial.begin(115200); + + while (!Serial) { + ; + } + + preferences.begin("my-app", false); + + // Get the counter value, if the key does not exist, return a default value of 0 + unsigned int counter = preferences.getUInt("counter", 0); + + // Print the counter to Serial Monitor + Serial.printf("Current counter value: %u\n", counter); + + // Increase counter by 1 + counter++; + + // Store the counter to the Preferences + preferences.putUInt("counter", counter); + + // Close the Preferences + preferences.end(); + + // Wait 1 second + delay(1000); + + // Restart ESP + ESP.restart(); +} + +void loop() {} diff --git a/tests/nvs/test_nvs.py b/tests/nvs/test_nvs.py new file mode 100644 index 000000000..656ab544e --- /dev/null +++ b/tests/nvs/test_nvs.py @@ -0,0 +1,7 @@ +def test_nvs(dut): + dut.expect('Current counter value: 0') + dut.expect('Current counter value: 1') + dut.expect('Current counter value: 2') + dut.expect('Current counter value: 3') + dut.expect('Current counter value: 4') + dut.expect('Current counter value: 5') \ No newline at end of file