Merge branch 'fix/incorrect_pma_config_esp32p4' into 'master'

fix(esp_hw_support): Fix incorrect PMA configuration for ESP32-P4

See merge request espressif/esp-idf!31400
This commit is contained in:
Aditya Patwardhan
2024-06-12 20:01:09 +08:00
5 changed files with 81 additions and 32 deletions
@@ -48,6 +48,10 @@ void test_drom_reg_write_violation(void);
void test_drom_reg_execute_violation(void);
void test_invalid_memory_region_write_violation(void);
void test_invalid_memory_region_execute_violation(void);
#ifdef __cplusplus
}
#endif
@@ -168,6 +168,10 @@ void app_main(void)
HANDLE_TEST(test_name, test_drom_reg_execute_violation);
#endif
#ifdef CONFIG_SOC_CPU_HAS_PMA
HANDLE_TEST(test_name, test_invalid_memory_region_write_violation);
HANDLE_TEST(test_name, test_invalid_memory_region_execute_violation);
#endif
#endif
die("Unknown test name");
@@ -246,3 +246,21 @@ void test_drom_reg_execute_violation(void)
func_ptr();
}
#endif
#ifdef CONFIG_SOC_CPU_HAS_PMA
void test_invalid_memory_region_write_violation(void)
{
uint32_t *test_addr = (uint32_t *)((uint32_t)(SOC_DRAM_HIGH + 0x40));
printf("Write operation | Address: %p\n", test_addr);
*test_addr = RND_VAL;
printf("%ld\n", *test_addr);
}
void test_invalid_memory_region_execute_violation(void)
{
void (*func_ptr)(void);
func_ptr = (void(*)(void))(SOC_DRAM_HIGH + 0x40);
printf("Execute operation | Address: %p\n", func_ptr);
func_ptr();
}
#endif
@@ -656,6 +656,12 @@ CONFIGS_MEMPROT_FLASH_IDROM = [
pytest.param('memprot_esp32p4', marks=[pytest.mark.esp32p4])
]
CONFIGS_MEMPROT_INVALID_REGION_PROTECTION_USING_PMA = [
pytest.param('memprot_esp32c6', marks=[pytest.mark.esp32c6]),
pytest.param('memprot_esp32h2', marks=[pytest.mark.esp32h2]),
pytest.param('memprot_esp32p4', marks=[pytest.mark.esp32p4])
]
@pytest.mark.parametrize('config', CONFIGS_MEMPROT_DCACHE, indirect=True)
@pytest.mark.generic
@@ -919,6 +925,24 @@ def test_drom_reg_execute_violation(dut: PanicTestDut, test_func_name: str) -> N
dut.expect_cpu_reset()
@pytest.mark.parametrize('config', CONFIGS_MEMPROT_INVALID_REGION_PROTECTION_USING_PMA, indirect=True)
@pytest.mark.generic
def test_invalid_memory_region_write_violation(dut: PanicTestDut, test_func_name: str) -> None:
dut.run_test_func(test_func_name)
dut.expect_gme('Store access fault')
dut.expect_reg_dump(0)
dut.expect_cpu_reset()
@pytest.mark.parametrize('config', CONFIGS_MEMPROT_INVALID_REGION_PROTECTION_USING_PMA, indirect=True)
@pytest.mark.generic
def test_invalid_memory_region_execute_violation(dut: PanicTestDut, test_func_name: str) -> None:
dut.run_test_func(test_func_name)
dut.expect_gme('Instruction access fault')
dut.expect_reg_dump(0)
dut.expect_cpu_reset()
@pytest.mark.esp32
@pytest.mark.generic
@pytest.mark.parametrize('config', ['gdbstub_coredump'], indirect=True)