mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-26 20:53:11 +00:00
refactor(tools/test_apps): Move HAL tests for MPU to the panic test-app
This commit is contained in:
@@ -19,6 +19,8 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "hal/mpu_hal.h"
|
||||
|
||||
/* Test utility function */
|
||||
|
||||
extern void esp_restart_noos(void) __attribute__ ((noreturn));
|
||||
@@ -202,3 +204,31 @@ void test_ub(void)
|
||||
uint8_t stuff[1] = {rand()};
|
||||
printf("%d\n", stuff[rand()]);
|
||||
}
|
||||
|
||||
/* NOTE: The following test verifies the behaviour for the
|
||||
* Xtensa-specific MPU instructions (Refer WDTLB, DSYNC, WDTIB, ISYNC)
|
||||
* used for memory protection.
|
||||
*
|
||||
* However, this test is not valid for S2 and S3, because they have PMS
|
||||
* enabled on top of this, giving unpredicatable results.
|
||||
*/
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
void test_illegal_access(void)
|
||||
{
|
||||
intptr_t addr = 0x80000000; // MPU region 4
|
||||
volatile int __attribute__((unused)) val = INT16_MAX;
|
||||
|
||||
// Marked as an illegal access region at startup in ESP32, ESP32S2.
|
||||
// Make accessible temporarily.
|
||||
mpu_hal_set_region_access(4, MPU_REGION_RW);
|
||||
|
||||
val = *((int*) addr);
|
||||
printf("[1] val: %d at %p\n", val, (void *)addr);
|
||||
|
||||
// Make access to region illegal again.
|
||||
mpu_hal_set_region_access(4, MPU_REGION_ILLEGAL);
|
||||
val = *((int*) addr);
|
||||
// Does not reach here as device resets due to illegal access
|
||||
printf("[2] val: %d at %p\n", val, (void *)addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user