mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
test(parlio,rmt,lcd): add virtual flash encryption test
This commit is contained in:
committed by
Chen Ji Chang
parent
a483acbf8f
commit
0ac402217c
@@ -0,0 +1,35 @@
|
||||
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import pytest
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from _pytest.monkeypatch import MonkeyPatch
|
||||
from pytest_embedded_idf.serial import IdfSerial
|
||||
|
||||
|
||||
# This is a custom IdfSerial class to support custom functionality
|
||||
# which is required only for this test
|
||||
class EfuseFlashEncSerial(IdfSerial):
|
||||
@IdfSerial.use_esptool()
|
||||
def write_flash_no_enc(self) -> None:
|
||||
self.app.flash_settings['encrypt'] = False
|
||||
flash_files = []
|
||||
for file in self.app.flash_files:
|
||||
# Set encrypted flag to false for each file.
|
||||
flash_files.append(file._replace(encrypted=False))
|
||||
# Replace the original tuple with modified tuple with all the files marked as unencrypted.
|
||||
self.app.flash_files = tuple(flash_files)
|
||||
# Now flash the files
|
||||
self.flash()
|
||||
|
||||
|
||||
@pytest.fixture(scope='module')
|
||||
def monkeypatch_module(request: FixtureRequest) -> MonkeyPatch:
|
||||
mp = MonkeyPatch()
|
||||
request.addfinalizer(mp.undo)
|
||||
return mp
|
||||
|
||||
|
||||
@pytest.fixture(scope='module', autouse=True)
|
||||
def replace_dut_class(monkeypatch_module: MonkeyPatch) -> None:
|
||||
monkeypatch_module.setattr('pytest_embedded_idf.IdfSerial', EfuseFlashEncSerial)
|
||||
@@ -95,7 +95,7 @@ static void test_parlio_bitscrambler(void)
|
||||
.idle_value = 0x00,
|
||||
.bitscrambler_program = bitscrambler_program_test_tx_LSB_to_MSB,
|
||||
};
|
||||
uint8_t tx_payload[TEST_PAYLOAD_SIZE] = {0};
|
||||
__attribute__((aligned(TEST_PAYLOAD_SIZE))) uint8_t tx_payload[TEST_PAYLOAD_SIZE] = {0};
|
||||
for (int i = 0; i < TEST_PAYLOAD_SIZE; i++) {
|
||||
tx_payload[i] = i;
|
||||
}
|
||||
|
||||
@@ -541,7 +541,7 @@ TEST_CASE("parallel_rx_unit_receive_external_memory_test", "[parlio_rx]")
|
||||
{
|
||||
parlio_rx_unit_handle_t rx_unit = NULL;
|
||||
parlio_rx_delimiter_handle_t deli = NULL;
|
||||
size_t payload_size = 1000;
|
||||
size_t payload_size = 1024;
|
||||
|
||||
parlio_rx_unit_config_t config = TEST_DEFAULT_UNIT_CONFIG(PARLIO_CLK_SRC_DEFAULT, 1000000);
|
||||
config.flags.free_clk = 1;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
bootloader, bootloader, primary, N/A, N/A,
|
||||
partition_table, partition_table, primary, N/A, N/A,
|
||||
nvs, data, nvs, , 0x4000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
emul_efuse, data, efuse, , 0x2000,
|
||||
factory, app, factory, , 1M,
|
||||
|
@@ -19,6 +19,28 @@ def test_parlio(dut: Dut) -> None:
|
||||
dut.run_all_single_board_cases()
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config, skip_autoflash',
|
||||
[
|
||||
('virt_flash_enc', 'y'),
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
@idf_parametrize('target', ['esp32c6', 'esp32h2', 'esp32p4', 'esp32c5'], indirect=['target'])
|
||||
def test_parlio_with_virt_flash_enc(dut: Dut) -> None:
|
||||
print(' - Erase flash')
|
||||
dut.serial.erase_flash()
|
||||
|
||||
print(' - Start app (flash partition_table and app)')
|
||||
dut.serial.write_flash_no_enc()
|
||||
dut.expect('Loading virtual efuse blocks from real efuses')
|
||||
dut.expect('Checking flash encryption...')
|
||||
dut.expect('Generating new flash encryption key...')
|
||||
|
||||
dut.run_all_single_board_cases()
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize(
|
||||
'config',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# FLASH_ENCRYPTION with EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0xC000
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_efuse_emul.csv"
|
||||
|
||||
CONFIG_SECURE_FLASH_ENC_ENABLED=y
|
||||
|
||||
# Virtual eFuse mode is enough for driver behaviour test.
|
||||
# Real encryption tests are guaranteed by DMA tests
|
||||
CONFIG_EFUSE_VIRTUAL=y
|
||||
CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH=y
|
||||
Reference in New Issue
Block a user