mirror of
https://github.com/espressif/esp-idf.git
synced 2024-09-20 00:36:01 -04:00
ci(mmu): add unicore test
This commit is contained in:
parent
52066307ed
commit
197c750067
@ -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 <inttypes.h>
|
||||
|
||||
#include "nvs_flash.h"
|
||||
#include "nvs.h"
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
import os
|
||||
import re
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
@ -11,31 +12,45 @@ from pytest_embedded import Dut
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.esp32p4
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['multicore'], indirect=True)
|
||||
def test_multicore_app_and_unicore_bootloader(dut: Dut) -> None:
|
||||
@pytest.mark.parametrize('config', ['multicore', 'multicore_psram'], indirect=True)
|
||||
def test_multicore_app_and_unicore_bootloader(dut: Dut, config) -> None: # type: ignore
|
||||
dut.expect('Multicore bootloader')
|
||||
dut.expect('Multicore app')
|
||||
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}')
|
||||
|
||||
dut.serial.bootloader_flash(path_to_unicore_build)
|
||||
dut.expect('Unicore bootloader')
|
||||
dut.expect('Multicore app')
|
||||
if 'psram' in config:
|
||||
dut.expect(re.compile(rb'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||
dut.expect('App is running')
|
||||
dut.expect('NVS test done\n')
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.esp32p4
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['unicore'], indirect=True)
|
||||
def test_unicore_app_and_multicore_bootloader(dut: Dut) -> None:
|
||||
@pytest.mark.parametrize('config', ['unicore', 'unicore_psram'], indirect=True)
|
||||
def test_unicore_app_and_multicore_bootloader(dut: Dut, config) -> None: # type: ignore
|
||||
dut.expect('Unicore bootloader')
|
||||
dut.expect('Unicore app')
|
||||
dut.expect('App is running')
|
||||
|
||||
path_to_unicore_build = os.path.join(dut.app.app_path, f'build_{dut.target}_multicore')
|
||||
dut.serial.bootloader_flash(path_to_unicore_build)
|
||||
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}')
|
||||
|
||||
dut.serial.bootloader_flash(path_to_multicore_build)
|
||||
dut.expect('Multicore bootloader')
|
||||
dut.expect('Unicore app')
|
||||
if 'psram' in config:
|
||||
dut.expect(re.compile(rb'Adding pool of \d+K of PSRAM memory to heap allocator'))
|
||||
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
|
Loading…
Reference in New Issue
Block a user