kopia lustrzana https://github.com/espressif/esp-idf
examples/ext_flash_fatfs: print out data partitions, add CI test
rodzic
ccde8c7d2f
commit
391d7ee4c7
|
@ -0,0 +1,27 @@
|
||||||
|
from __future__ import print_function
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
import IDF
|
||||||
|
except ImportError:
|
||||||
|
test_fw_path = os.getenv('TEST_FW_PATH')
|
||||||
|
if test_fw_path and test_fw_path not in sys.path:
|
||||||
|
sys.path.insert(0, test_fw_path)
|
||||||
|
import IDF
|
||||||
|
|
||||||
|
|
||||||
|
@IDF.idf_example_test(env_tag='Example_ExtFlash')
|
||||||
|
def test_examples_storage_ext_flash_fatfs(env, extra_data):
|
||||||
|
dut = env.get_dut('ext_flash_fatfs', 'examples/storage/ext_flash_fatfs')
|
||||||
|
dut.start_app()
|
||||||
|
|
||||||
|
dut.expect('Initialized external Flash')
|
||||||
|
dut.expect('partition \'nvs\'')
|
||||||
|
dut.expect('partition \'storage\'')
|
||||||
|
dut.expect('File written')
|
||||||
|
dut.expect('Read from file: \'Written using ESP-IDF')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
test_examples_storage_ext_flash_fatfs()
|
|
@ -30,6 +30,7 @@ const char *base_path = "/extflash";
|
||||||
|
|
||||||
static esp_flash_t* example_init_ext_flash(void);
|
static esp_flash_t* example_init_ext_flash(void);
|
||||||
static const esp_partition_t* example_add_partition(esp_flash_t* ext_flash, const char* partition_label);
|
static const esp_partition_t* example_add_partition(esp_flash_t* ext_flash, const char* partition_label);
|
||||||
|
static void example_list_data_partitions(void);
|
||||||
static bool example_mount_fatfs(const char* partition_label);
|
static bool example_mount_fatfs(const char* partition_label);
|
||||||
static void example_get_fatfs_usage(size_t* out_total_bytes, size_t* out_free_bytes);
|
static void example_get_fatfs_usage(size_t* out_total_bytes, size_t* out_free_bytes);
|
||||||
|
|
||||||
|
@ -45,6 +46,9 @@ void app_main(void)
|
||||||
const char *partition_label = "storage";
|
const char *partition_label = "storage";
|
||||||
example_add_partition(flash, partition_label);
|
example_add_partition(flash, partition_label);
|
||||||
|
|
||||||
|
// List the available partitions
|
||||||
|
example_list_data_partitions();
|
||||||
|
|
||||||
// Initialize FAT FS in the partition
|
// Initialize FAT FS in the partition
|
||||||
if (!example_mount_fatfs(partition_label)) {
|
if (!example_mount_fatfs(partition_label)) {
|
||||||
return;
|
return;
|
||||||
|
@ -139,6 +143,20 @@ static const esp_partition_t* example_add_partition(esp_flash_t* ext_flash, cons
|
||||||
return fat_partition;
|
return fat_partition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void example_list_data_partitions(void)
|
||||||
|
{
|
||||||
|
ESP_LOGI(TAG, "Listing data partitions:");
|
||||||
|
esp_partition_iterator_t it = esp_partition_find(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_ANY, NULL);
|
||||||
|
|
||||||
|
for (; it != NULL; it = esp_partition_next(it)) {
|
||||||
|
const esp_partition_t *part = esp_partition_get(it);
|
||||||
|
ESP_LOGI(TAG, "- partition '%s', subtype %d, offset 0x%x, size %d kB",
|
||||||
|
part->label, part->subtype, part->address, part->size / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_partition_iterator_release(it);
|
||||||
|
}
|
||||||
|
|
||||||
static bool example_mount_fatfs(const char* partition_label)
|
static bool example_mount_fatfs(const char* partition_label)
|
||||||
{
|
{
|
||||||
ESP_LOGI(TAG, "Mounting FAT filesystem");
|
ESP_LOGI(TAG, "Mounting FAT filesystem");
|
||||||
|
|
|
@ -215,6 +215,12 @@ example_test_009:
|
||||||
variables:
|
variables:
|
||||||
SETUP_TOOLS: "1"
|
SETUP_TOOLS: "1"
|
||||||
|
|
||||||
|
example_test_010:
|
||||||
|
extends: .example_test_template
|
||||||
|
tags:
|
||||||
|
- ESP32
|
||||||
|
- Example_ExtFlash
|
||||||
|
|
||||||
UT_001:
|
UT_001:
|
||||||
extends: .unit_test_template
|
extends: .unit_test_template
|
||||||
parallel: 50
|
parallel: 50
|
||||||
|
|
Ładowanie…
Reference in New Issue