diff --git a/src/main/drivers/system_stm32f7xx.c b/src/main/drivers/system_stm32f7xx.c index 3f042498ab..b978f9c682 100644 --- a/src/main/drivers/system_stm32f7xx.c +++ b/src/main/drivers/system_stm32f7xx.c @@ -162,6 +162,10 @@ void systemInit(void) { checkForBootLoaderRequest(); + // Mark ITCM-RAM as read-only + LL_MPU_ConfigRegion(LL_MPU_REGION_NUMBER0, 0, RAMITCM_BASE, LL_MPU_REGION_SIZE_16KB | LL_MPU_REGION_PRIV_RO_URO); + LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT); + //SystemClock_Config(); // Configure NVIC preempt/priority groups diff --git a/src/main/fc/fc_hardfaults.c b/src/main/fc/fc_hardfaults.c index 97a47effef..d0163d7e52 100644 --- a/src/main/fc/fc_hardfaults.c +++ b/src/main/fc/fc_hardfaults.c @@ -31,6 +31,31 @@ #include "flight/mixer.h" +#ifdef STM32F7 +void MemManage_Handler(void) +{ + LED2_ON; + +#ifdef USE_TRANSPONDER + // prevent IR LEDs from burning out. + uint8_t requiredStateForTransponder = SYSTEM_STATE_CONFIG_LOADED | SYSTEM_STATE_TRANSPONDER_ENABLED; + if ((systemState & requiredStateForTransponder) == requiredStateForTransponder) { + transponderIrDisable(); + } +#endif + + LED1_OFF; + LED0_OFF; + + while (1) { + delay(500); + LED2_TOGGLE; + delay(50); + LED2_TOGGLE; + } +} +#endif + #ifdef DEBUG_HARDFAULTS //from: https://mcuoneclipse.com/2012/11/24/debugging-hard-faults-on-arm-cortex-m/ /** @@ -116,10 +141,8 @@ void HardFault_Handler(void) LED0_OFF; while (1) { -#ifdef LED2 delay(50); LED2_TOGGLE; -#endif } } #endif diff --git a/src/main/platform.h b/src/main/platform.h index 000d0b9bcf..b7e89232e4 100644 --- a/src/main/platform.h +++ b/src/main/platform.h @@ -31,6 +31,7 @@ #include "stm32f7xx_hal.h" #include "system_stm32f7xx.h" +#include "stm32f7xx_ll_cortex.h" #include "stm32f7xx_ll_spi.h" #include "stm32f7xx_ll_gpio.h" #include "stm32f7xx_ll_dma.h"