Page 1 of 1

Add a __reset_handler to startup code

Posted: Thu Jan 08, 2026 11:01 am
by drizzi
Hello,
I often have the need (e.g.: bootloader) to execute some code before anything else, right after the reset.
I can do that overriding the default Reset_Handler (do my stuff, then b _crt0_entry), but I find that adding adding a (weak) __reset_handler hook (like __cpu_init or __early_init) and then doing a b __reset_handler in _crt0_entry is a much more cleaner approach. But this requires to patch all the crt1.c and crt0*.S files (I exclusively use ARMCMx/GCC).
Maybe I am the only one with this request, but - if not - maybe it's an idea worth considering (despite the need to modify all the startup code for all platforms/compilers).

Ciao,
Davide

Re: Add a __reset_handler to startup code

Posted: Tue Jan 27, 2026 9:24 am
by Giovanni
Hi,

This is already possible, Reset_Handler is a weak symbol, redefine it, do your initialization, then jump to _crt0_entry.

Giovanni