1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-16 21:05:35 +03:00

Fix the RESET_FORCED case not being used and not being able to correctly

determine the reason for the reset when the reset is forced.

Before 31b06cd7d2 it was possible for
early init code to overwrite the reset reason, however this commit also
broke the code that allows the system, and developer, to determine the
reason for the reset when the reset was forced.
This commit is contained in:
Dominic Clifton 2021-05-27 12:51:08 +02:00
parent f25642cc56
commit e5a06beefc
2 changed files with 6 additions and 7 deletions

View file

@ -110,10 +110,8 @@ void systemReset(void)
NVIC_SystemReset();
}
void forcedSystemResetWithoutDisablingCaches(void)
void systemResetWithoutDisablingCaches(void)
{
// Don't overwrite the PERSISTENT_OBJECT_RESET_REASON; just make another attempt
__disable_irq();
NVIC_SystemReset();
}
@ -184,7 +182,8 @@ void systemCheckResetReason(void)
case RESET_BOOTLOADER_POST:
// Boot loader activity magically prevents SysTick from interrupting.
// Issue a soft reset to prevent the condition.
forcedSystemResetWithoutDisablingCaches(); // observed that disabling dcache after cold boot with BOOT pin high causes segfault.
persistentObjectWrite(PERSISTENT_OBJECT_RESET_REASON, RESET_FORCED);
systemResetWithoutDisablingCaches(); // observed that disabling dcache after cold boot with BOOT pin high causes segfault.
case RESET_MSC_REQUEST:
case RESET_NONE:

View file

@ -69,7 +69,7 @@
#include "build/debug.h"
void forcedSystemResetWithoutDisablingCaches(void);
void systemResetWithoutDisablingCaches(void);
#if !defined (HSE_VALUE)
#define HSE_VALUE ((uint32_t)25000000) /*!< Value of the External oscillator in Hz */
@ -179,7 +179,7 @@ void HandleStuckSysTick(void)
}
if (tickStart == tickEnd) {
forcedSystemResetWithoutDisablingCaches();
systemResetWithoutDisablingCaches();
}
}
@ -389,7 +389,7 @@ static void SystemClockHSE_Config(void)
#ifdef USE_H7_HSE_TIMEOUT_WORKAROUND
if (status == HAL_TIMEOUT) {
forcedSystemResetWithoutDisablingCaches(); // DC - sometimes HSERDY gets stuck, waiting longer doesn't help.
systemResetWithoutDisablingCaches(); // DC - sometimes HSERDY gets stuck, waiting longer doesn't help.
}
#endif