diff --git a/os/common/startup/ARMCMx/compilers/GCC/crt0_v6m.S b/os/common/startup/ARMCMx/compilers/GCC/crt0_v6m.S index 42bf683f32..eda38669d4 100644 --- a/os/common/startup/ARMCMx/compilers/GCC/crt0_v6m.S +++ b/os/common/startup/ARMCMx/compilers/GCC/crt0_v6m.S @@ -137,6 +137,13 @@ #define CRT0_CALL_DESTRUCTORS TRUE #endif +/** + * @brief Entry Hook Enabled. + */ +#if !defined(CRT0_ENTRY_HOOK) || defined(__DOXYGEN__) +#define CRT0_ENTRY_HOOK FALSE +#endif + /** * @brief Number of extra cores. */ @@ -163,6 +170,10 @@ .thumb_func .global _crt0_entry _crt0_entry: +#if CRT0_ENTRY_HOOK == TRUE + ldr R0, =__entry_hook + blx R0 +#endif /* Interrupts are globally masked initially.*/ cpsid i diff --git a/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S b/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S index 4abe00a999..c38f430cab 100644 --- a/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S +++ b/os/common/startup/ARMCMx/compilers/GCC/crt0_v7m.S @@ -177,6 +177,13 @@ #define CRT0_CPACR_INIT 0x00F00000 #endif +/** + * @brief Entry Hook Enabled. + */ +#if !defined(CRT0_ENTRY_HOOK) || defined(__DOXYGEN__) +#define CRT0_ENTRY_HOOK FALSE +#endif + /*===========================================================================*/ /* Code section. */ /*===========================================================================*/ @@ -201,6 +208,10 @@ .thumb_func .global _crt0_entry _crt0_entry: +#if CRT0_ENTRY_HOOK == TRUE + ldr R0, =__entry_hook + blx R0 +#endif /* Interrupts are globally masked initially.*/ cpsid i diff --git a/os/common/startup/ARMCMx/compilers/GCC/crt1.c b/os/common/startup/ARMCMx/compilers/GCC/crt1.c index ae15b3216e..4c9fc02315 100644 --- a/os/common/startup/ARMCMx/compilers/GCC/crt1.c +++ b/os/common/startup/ARMCMx/compilers/GCC/crt1.c @@ -146,6 +146,20 @@ void __cpu_init(void) { #endif } +/** + * @brief called immediately at Reset + * @details This hook is invoked immediately after the Reset Handler + * + * @note This function is a weak symbol. + */ +#if !defined(__DOXYGEN__) +__attribute__((weak)) +#endif +/*lint -save -e9075 [8.4] All symbols are invoked from asm context.*/ +#ifndef _ARDUPILOT_ +void __entry_hook(void) {} +#endif + /** * @brief Early initialization. * @details This hook is invoked immediately after the stack and core