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
Add a __reset_handler to startup code
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Add a __reset_handler to startup code
Hi,
This is already possible, Reset_Handler is a weak symbol, redefine it, do your initialization, then jump to _crt0_entry.
Giovanni
This is already possible, Reset_Handler is a weak symbol, redefine it, do your initialization, then jump to _crt0_entry.
Giovanni