From 47ac8ef3f05249405381397b312a3507477ec6da Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Wed, 7 Nov 2018 15:25:04 -0600 Subject: [PATCH] Fix MPU test when MemManage fault enabled Hook both the HardFault and the MemManage IRQs since it is up to the target to determine which fault is enabled. --- TESTS/mbed_hal/mpu/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/TESTS/mbed_hal/mpu/main.cpp b/TESTS/mbed_hal/mpu/main.cpp index eb7ee15bda..5e380db20b 100644 --- a/TESTS/mbed_hal/mpu/main.cpp +++ b/TESTS/mbed_hal/mpu/main.cpp @@ -31,12 +31,14 @@ using namespace utest::v1; #define HARDFAULT_IRQn ((IRQn_Type)-13) +#define MEMFAULT_IRQn ((IRQn_Type)-12) // Assembly return instruction: bx lr #define ASM_BX_LR 0x4770 volatile uint32_t fault_count; uint32_t real_hard_fault_handler; +uint32_t real_mem_fault_handler; static volatile uint16_t data_function = ASM_BX_LR; static volatile uint16_t bss_function; @@ -154,9 +156,11 @@ void mpu_fault_test_heap() utest::v1::status_t fault_override_setup(const Case *const source, const size_t index_of_case) { - // Save old hard fault handler and replace it with a new one + // Save old fault handlers and replace it with a new one real_hard_fault_handler = NVIC_GetVector(HARDFAULT_IRQn); + real_mem_fault_handler = NVIC_GetVector(MEMFAULT_IRQn); NVIC_SetVector(HARDFAULT_IRQn, (uint32_t)&hard_fault_handler_test); + NVIC_SetVector(MEMFAULT_IRQn, (uint32_t)&hard_fault_handler_test); return greentea_case_setup_handler(source, index_of_case); } @@ -164,8 +168,9 @@ utest::v1::status_t fault_override_setup(const Case *const source, const size_t utest::v1::status_t fault_override_teardown(const Case *const source, const size_t passed, const size_t failed, const failure_t reason) { - // Restore real hard fault handler + // Restore real fault handlers NVIC_SetVector(HARDFAULT_IRQn, real_hard_fault_handler); + NVIC_SetVector(MEMFAULT_IRQn, real_mem_fault_handler); return greentea_case_teardown_handler(source, passed, failed, reason); }