18.2.12 The “On Bootstrap” Routine
Some hardware configurations require special initialization once most of the C/C++
runtime environment has been initialized, while StatusBEV
is still set
and before the main()
function has been called. For instance, special
hardware initialization and/or initialization of the environment might be required by an
RTOS. To achieve this, there is an On Bootstrap hook provided, so that you do not need
to customize the entire startup code sequence.
An empty weak implementation of the On Bootstrap routine (_on_bootstrap
)
is provided with the start-up code. It is called by the runtime startup code after most
of the C/C++ language context initialization has been performed.
void _on_bootstrap(void)
{
// Add code to be executed just before main() here
}
This
routine can be placed into any source file in your project and you do not need to adjust
any compiler options to have it executed.This routine can be written assuming that the runtime environment has been mostly
established. The StatusBEV
is cleared immediately after this routine
returns. See 18.2 Runtime Start-Up Code for
the order in which the environment is set up.