mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
ci(mmu): add unicore test
This commit is contained in:
@ -1 +1,2 @@
|
|||||||
idf_component_register(SRCS "main.c")
|
idf_component_register(SRCS "main.c"
|
||||||
|
PRIV_REQUIRES nvs_flash esp_psram)
|
||||||
|
@ -5,8 +5,70 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
#include "nvs_flash.h"
|
||||||
|
#include "nvs.h"
|
||||||
|
|
||||||
void app_main(void)
|
void app_main(void)
|
||||||
{
|
{
|
||||||
printf("App is running\n");
|
printf("App is running\n");
|
||||||
|
|
||||||
|
// One difference of multicore bootloader is whether it resets all the MMU. If not, it may cause the nvs fail to
|
||||||
|
// call mmap. Test code copied from examples/storage/nvs_rw_value.
|
||||||
|
|
||||||
|
// Initialize NVS
|
||||||
|
esp_err_t err = nvs_flash_init();
|
||||||
|
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||||
|
// NVS partition was truncated and needs to be erased
|
||||||
|
// Retry nvs_flash_init
|
||||||
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||||
|
err = nvs_flash_init();
|
||||||
|
}
|
||||||
|
ESP_ERROR_CHECK( err );
|
||||||
|
|
||||||
|
// Open
|
||||||
|
printf("Opening Non-Volatile Storage (NVS) handle... ");
|
||||||
|
nvs_handle_t my_handle;
|
||||||
|
err = nvs_open("storage", NVS_READWRITE, &my_handle);
|
||||||
|
if (err != ESP_OK) {
|
||||||
|
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
|
||||||
|
} else {
|
||||||
|
printf("Done\n");
|
||||||
|
|
||||||
|
// Read
|
||||||
|
printf("Reading restart counter from NVS ... ");
|
||||||
|
int32_t restart_counter = 0; // value will default to 0, if not set yet in NVS
|
||||||
|
err = nvs_get_i32(my_handle, "restart_counter", &restart_counter);
|
||||||
|
switch (err) {
|
||||||
|
case ESP_OK:
|
||||||
|
printf("Done\n");
|
||||||
|
printf("Restart counter = %" PRIu32 "\n", restart_counter);
|
||||||
|
break;
|
||||||
|
case ESP_ERR_NVS_NOT_FOUND:
|
||||||
|
printf("The value is not initialized yet!\n");
|
||||||
|
break;
|
||||||
|
default :
|
||||||
|
printf("Error (%s) reading!\n", esp_err_to_name(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Write
|
||||||
|
printf("Updating restart counter in NVS ... ");
|
||||||
|
restart_counter++;
|
||||||
|
err = nvs_set_i32(my_handle, "restart_counter", restart_counter);
|
||||||
|
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
|
||||||
|
|
||||||
|
// Commit written value.
|
||||||
|
// After setting any values, nvs_commit() must be called to ensure changes are written
|
||||||
|
// to flash storage. Implementations may write to storage at other times,
|
||||||
|
// but this is not guaranteed.
|
||||||
|
printf("Committing updates in NVS ... ");
|
||||||
|
err = nvs_commit(my_handle);
|
||||||
|
printf((err != ESP_OK) ? "Failed!\n" : "Done\n");
|
||||||
|
|
||||||
|
// Close
|
||||||
|
nvs_close(my_handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("NVS test done\n");
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
# SPDX-License-Identifier: CC0-1.0
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from artifacts_handler import ArtifactType
|
from artifacts_handler import ArtifactType
|
||||||
@ -12,13 +13,16 @@ from pytest_embedded import Dut
|
|||||||
@pytest.mark.esp32s3
|
@pytest.mark.esp32s3
|
||||||
@pytest.mark.esp32p4
|
@pytest.mark.esp32p4
|
||||||
@pytest.mark.generic
|
@pytest.mark.generic
|
||||||
@pytest.mark.parametrize('config', ['multicore'], indirect=True)
|
@pytest.mark.parametrize('config', ['multicore', 'multicore_psram'], indirect=True)
|
||||||
def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader) -> None: # type: ignore
|
def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader, config) -> None: # type: ignore
|
||||||
dut.expect('Multicore bootloader')
|
dut.expect('Multicore bootloader')
|
||||||
dut.expect('Multicore app')
|
dut.expect('Multicore app')
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
|
|
||||||
path_to_unicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_unicore')
|
assert 'multicore' in config
|
||||||
|
app_config = config.replace('multicore', 'unicore')
|
||||||
|
|
||||||
|
path_to_unicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_{app_config}')
|
||||||
if app_downloader:
|
if app_downloader:
|
||||||
app_downloader.download_app(
|
app_downloader.download_app(
|
||||||
os.path.relpath(path_to_unicore_build, IDF_PATH), ArtifactType.BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES
|
os.path.relpath(path_to_unicore_build, IDF_PATH), ArtifactType.BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES
|
||||||
@ -27,20 +31,26 @@ def test_multicore_app_and_unicore_bootloader(dut: Dut, app_downloader) -> None:
|
|||||||
dut.serial.bootloader_flash(path_to_unicore_build)
|
dut.serial.bootloader_flash(path_to_unicore_build)
|
||||||
dut.expect('Unicore bootloader')
|
dut.expect('Unicore bootloader')
|
||||||
dut.expect('Multicore app')
|
dut.expect('Multicore app')
|
||||||
|
if 'psram' in config:
|
||||||
|
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
|
dut.expect('NVS test done\n')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.esp32
|
@pytest.mark.esp32
|
||||||
@pytest.mark.esp32s3
|
@pytest.mark.esp32s3
|
||||||
@pytest.mark.esp32p4
|
@pytest.mark.esp32p4
|
||||||
@pytest.mark.generic
|
@pytest.mark.generic
|
||||||
@pytest.mark.parametrize('config', ['unicore'], indirect=True)
|
@pytest.mark.parametrize('config', ['unicore', 'unicore_psram'], indirect=True)
|
||||||
def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader) -> None: # type: ignore
|
def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader, config) -> None: # type: ignore
|
||||||
dut.expect('Unicore bootloader')
|
dut.expect('Unicore bootloader')
|
||||||
dut.expect('Unicore app')
|
dut.expect('Unicore app')
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
|
|
||||||
path_to_multicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_multicore')
|
assert 'unicore' in config
|
||||||
|
app_config = config.replace('unicore', 'multicore')
|
||||||
|
|
||||||
|
path_to_multicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_{app_config}')
|
||||||
if app_downloader:
|
if app_downloader:
|
||||||
app_downloader.download_app(
|
app_downloader.download_app(
|
||||||
os.path.relpath(path_to_multicore_build, IDF_PATH), ArtifactType.BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES
|
os.path.relpath(path_to_multicore_build, IDF_PATH), ArtifactType.BUILD_DIR_WITHOUT_MAP_AND_ELF_FILES
|
||||||
@ -49,4 +59,7 @@ def test_unicore_app_and_multicore_bootloader(dut: Dut, app_downloader) -> None:
|
|||||||
dut.serial.bootloader_flash(path_to_multicore_build)
|
dut.serial.bootloader_flash(path_to_multicore_build)
|
||||||
dut.expect('Multicore bootloader')
|
dut.expect('Multicore bootloader')
|
||||||
dut.expect('Unicore app')
|
dut.expect('Unicore app')
|
||||||
|
if 'psram' in config:
|
||||||
|
dut.expect(re.compile(r'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||||
dut.expect('App is running')
|
dut.expect('App is running')
|
||||||
|
dut.expect('NVS test done\n')
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
CONFIG_SPIRAM=y
|
@ -0,0 +1,2 @@
|
|||||||
|
CONFIG_FREERTOS_UNICORE=y
|
||||||
|
CONFIG_SPIRAM=y
|
Reference in New Issue
Block a user