mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-21 10:15:42 +00:00
ci: run Example_GENERIC for C3
Add support for running example_GENERIC tests for C3 on label. Fix examples that fail.
This commit is contained in:

committed by
Angus Gratton

parent
c270a9f0b9
commit
8efb2bb1ed
@@ -2,22 +2,22 @@
|
||||
|
||||
(See the README.md file in the upper level 'examples' directory for more information about examples.)
|
||||
|
||||
This example demonstrates how to read and write a single integer value and a blob (binary large object) using NVS to preserve them between ESP32 module restarts.
|
||||
This example demonstrates how to read and write a single integer value and a blob (binary large object) using NVS to preserve them between ESP module restarts.
|
||||
|
||||
* value - tracks number of ESP32 module soft and hard restarts.
|
||||
* blob - contains a table with module run times. The table is read from NVS to dynamically allocated RAM. New run time is added to the table on each manually triggered soft restart and written back to NVS. Triggering is done by pulling down GPIO0.
|
||||
* value - tracks number of soft and hard restarts.
|
||||
* blob - contains a table with module run times. The table is read from NVS to dynamically allocated RAM. New run time is added to the table on each manually triggered soft restart and written back to NVS. Triggering is done by pulling down the boot mode pin (GPIO0 on ESP32 and ESP32-S2, GPIO9 on ESP32-C3).
|
||||
|
||||
Example also shows how to implement diagnostics if read / write operation was successful.
|
||||
Example also shows how to implement diagnostics if read / write operation was successful.
|
||||
|
||||
Detailed functional description of NVS and API is provided in [documentation](https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/storage/nvs_flash.html).
|
||||
|
||||
If not done already, consider checking simpler example *storage/nvs_rw_value*, that has been used as a starting point for preparing this one.
|
||||
If not done already, consider checking simpler example *storage/nvs_rw_value*, that has been used as a starting point for preparing this one.
|
||||
|
||||
## How to use example
|
||||
|
||||
### Hardware required
|
||||
|
||||
This example can be run on most common development boards which have an active button connected to GPIO0. On most boards, this button is labeled as "Boot". When pressed, the button connects GPIO0 to ground.
|
||||
This example can be run on most common development boards which have an active button connected to boot mode pin. On most boards, this button is labeled as "Boot". When pressed, the button connects boot mode pin to ground.
|
||||
|
||||
### Build and flash
|
||||
|
||||
|
@@ -19,6 +19,12 @@
|
||||
|
||||
#define STORAGE_NAMESPACE "storage"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32C3
|
||||
#define BOOT_MODE_PIN GPIO_NUM_9
|
||||
#else
|
||||
#define BOOT_MODE_PIN GPIO_NUM_0
|
||||
#endif //CONFIG_IDF_TARGET_ESP32C3
|
||||
|
||||
/* Save the number of module restarts in NVS
|
||||
by first reading and then incrementing
|
||||
the number that has been saved previously.
|
||||
@@ -167,16 +173,16 @@ void app_main(void)
|
||||
err = save_restart_counter();
|
||||
if (err != ESP_OK) printf("Error (%s) saving restart counter to NVS!\n", esp_err_to_name(err));
|
||||
|
||||
gpio_reset_pin(GPIO_NUM_0);
|
||||
gpio_set_direction(GPIO_NUM_0, GPIO_MODE_INPUT);
|
||||
gpio_reset_pin(BOOT_MODE_PIN);
|
||||
gpio_set_direction(BOOT_MODE_PIN, GPIO_MODE_INPUT);
|
||||
|
||||
/* Read the status of GPIO0. If GPIO0 is LOW for longer than 1000 ms,
|
||||
then save module's run time and restart it
|
||||
*/
|
||||
while (1) {
|
||||
if (gpio_get_level(GPIO_NUM_0) == 0) {
|
||||
if (gpio_get_level(BOOT_MODE_PIN) == 0) {
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
if(gpio_get_level(GPIO_NUM_0) == 0) {
|
||||
if(gpio_get_level(BOOT_MODE_PIN) == 0) {
|
||||
err = save_run_time();
|
||||
if (err != ESP_OK) printf("Error (%s) saving run time blob to NVS!\n", esp_err_to_name(err));
|
||||
printf("Restarting...\n");
|
||||
|
@@ -6,7 +6,7 @@ import ttfw_idf
|
||||
from tiny_test_fw import Utility
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_nvs_rw_blob(env, extra_data):
|
||||
|
||||
dut = env.get_dut('nvs_rw_blob', 'examples/storage/nvs_rw_blob')
|
||||
@@ -24,7 +24,7 @@ def test_examples_nvs_rw_blob(env, extra_data):
|
||||
for i in range(1, 10):
|
||||
time.sleep(random.uniform(0.1, 2)) # in order to randomize the runtimes stored in NVS
|
||||
try:
|
||||
# Pulling GPIO0 low using DTR
|
||||
# Pulling pin low using DTR
|
||||
dut.port_inst.setDTR(True)
|
||||
dut.expect('Restarting...', timeout=5) # the application waits for a second
|
||||
finally:
|
||||
|
@@ -8,7 +8,7 @@ except ImportError:
|
||||
from itertools import zip_longest
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_nvs_rw_value(env, extra_data):
|
||||
|
||||
dut = env.get_dut('nvs_rw_value', 'examples/storage/nvs_rw_value')
|
||||
|
@@ -8,7 +8,7 @@ except ImportError:
|
||||
from itertools import zip_longest
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_nvs_rw_value_cxx(env, extra_data):
|
||||
|
||||
dut = env.get_dut('nvs_rw_value_cxx', 'examples/storage/nvs_rw_value_cxx')
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_partition_find(env, extra_data):
|
||||
|
||||
dut = env.get_dut('partition_find', 'examples/storage/partition_api/partition_find')
|
||||
|
@@ -3,7 +3,7 @@ import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_partition_mmap(env, extra_data):
|
||||
|
||||
dut = env.get_dut('partition_mmap', 'examples/storage/partition_api/partition_mmap')
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_partition_ops(env, extra_data):
|
||||
|
||||
dut = env.get_dut('partition_ops', 'examples/storage/partition_api/partition_ops')
|
||||
|
@@ -7,9 +7,9 @@ import sys
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_parttool(env, extra_data):
|
||||
dut = env.get_dut('parttool', 'examples/storage/parttool', dut_class=ttfw_idf.ESP32DUT)
|
||||
dut = env.get_dut('parttool', 'examples/storage/parttool')
|
||||
dut.start_app(False)
|
||||
|
||||
# Verify factory firmware
|
||||
|
@@ -3,7 +3,7 @@ import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_spiffs(env, extra_data):
|
||||
|
||||
dut = env.get_dut('spiffs', 'examples/storage/spiffs')
|
||||
|
@@ -6,10 +6,10 @@ import os
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_spiffsgen(env, extra_data):
|
||||
# Test with default build configurations
|
||||
dut = env.get_dut('spiffsgen', 'examples/storage/spiffsgen', dut_class=ttfw_idf.ESP32DUT)
|
||||
dut = env.get_dut('spiffsgen', 'examples/storage/spiffsgen')
|
||||
dut.start_app()
|
||||
|
||||
base_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'spiffs_image')
|
||||
|
@@ -3,7 +3,7 @@ import re
|
||||
import ttfw_idf
|
||||
|
||||
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC')
|
||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32c3'])
|
||||
def test_examples_wear_levelling(env, extra_data):
|
||||
|
||||
dut = env.get_dut('wear_levelling', 'examples/storage/wear_levelling')
|
||||
|
Reference in New Issue
Block a user