|
ChibiOS/RT
2.6.0 |
|
ChibiOS/RT provides its own generic startup file for the ARM Cortex-Mx port. Of course it is not mandatory to use it but care should be taken about the startup phase details.
The startup process, as implemented, is the following:
__early_init() is invoked, if the symbol is not defined then an empty default routine is executed (weak symbol).main() function is invoked with no parameters._default_exit(). The default code is an endless empty loop.The startup code starts at the symbol ResetHandler and expects the following symbols to be defined in the linker script:
__ram_end__, end of RAM.__main_stack_base__, main stack lower boundary.__main_stack_end__, main stack initial position.__process_stack_base__, process stack lower boundary.__process_stack_end__, process stack initial position._textdata, address of the data segment source read only data._data, start of the data segment._edata, end of the data segment end location._bss_start, start of the BSS._bss_end, end of the BSS segment.__init_array_start, start of the constructors array.__init_array_end, end of the constructors array.__fini_array_start, start of the destructors array.__fini_array_end, end of the destructors array.Additionally the kernel expects the following symbols:
__main_thread_stack_base__, this symbol is required when the stack checking is enabled (CH_DBG_ENABLE_STACK_CHECK==TRUE), it is an alias of __process_stack_base__ in this port.__heap_base__ and __heap_end__, those symbols are required if the memory core manager is enabled (CH_USE_MEMCORE==TRUE) with a default core size set to zero (CH_MEMCORE_SIZE==0).Functions | |
| void | main (void) |
Application main() function. | |
| void | __early_init (void) |
| Early initialization. | |
| void | __late_init (void) |
| Late initialization. | |
| void | _default_exit (void) |
Default main() function exit handler. | |
| void | ResetHandler (void) |
| Reset vector. | |
Startup settings | |
| #define | CRT0_CONTROL_INIT 0x00000002 |
| Control special register initialization value. | |
| #define | CRT0_STACKS_FILL_PATTERN 0x55555555 |
| Stack segments initialization switch. | |
| #define | CRT0_INIT_STACKS TRUE |
| Stack segments initialization switch. | |
| #define | CRT0_INIT_DATA TRUE |
| DATA segment initialization switch. | |
| #define | CRT0_INIT_BSS TRUE |
| BSS segment initialization switch. | |
| #define | CRT0_CALL_CONSTRUCTORS TRUE |
| Constructors invocation switch. | |
| #define | CRT0_CALL_DESTRUCTORS TRUE |
| Destructors invocation switch. | |
Symbols from the scatter file | |
| uint32_t | __main_stack_base__ |
| Main stack lower boundary. | |
| uint32_t | __main_stack_end__ |
| Main stack initial position. | |
| uint32_t | __process_stack_base__ |
| Process stack lower boundary. | |
| uint32_t | __process_stack_end__ |
| Process stack initial position. | |
| uint32_t | _textdata |
| ROM image of the data segment start. | |
| uint32_t | _data |
| Data segment start. | |
| uint32_t | _edata |
| Data segment end. | |
| uint32_t | _bss_start |
| BSS segment start. | |
| uint32_t | _bss_end |
| BSS segment end. | |
| funcp_t | __init_array_start |
| Constructors table start. | |
| funcp_t | __init_array_end |
| Constructors table end. | |
| funcp_t | __fini_array_start |
| Destructors table start. | |
| funcp_t | __fini_array_end |
| Destructors table end. | |
| void main | ( | void | ) |
Application main() function.
Referenced by ResetHandler().
| void __early_init | ( | void | ) |
Early initialization.
This hook is invoked immediately after the stack initialization and before the DATA and BSS segments initialization. The default behavior is to do nothing.
Definition at line 234 of file crt0.c.
Referenced by ResetHandler().
| void __late_init | ( | void | ) |
Late initialization.
This hook is invoked after the DATA and BSS segments initialization and before any static constructor. The default behavior is to do nothing.
Definition at line 246 of file crt0.c.
Referenced by ResetHandler().
| void _default_exit | ( | void | ) |
Default main() function exit handler.
This handler is invoked or the main() function exit. The default behavior is to enter an infinite loop.
Definition at line 257 of file crt0.c.
Referenced by ResetHandler().
| void ResetHandler | ( | void | ) |
Reset vector.
Definition at line 268 of file crt0.c.
References __early_init(), __fini_array_end, __fini_array_start, __init_array_end, __init_array_start, __late_init(), __main_stack_base__, __main_stack_end__, __process_stack_base__, __process_stack_end__, _bss_end, _bss_start, _data, _default_exit(), _edata, _textdata, CRT0_CONTROL_INIT, CRT0_STACKS_FILL_PATTERN, and main().

| uint32_t __main_stack_base__ |
Main stack lower boundary.
This symbol must be exported by the linker script and represents the main stack lower boundary.
Referenced by ResetHandler().
| uint32_t __main_stack_end__ |
Main stack initial position.
This symbol must be exported by the linker script and represents the main stack initial position.
Referenced by ResetHandler().
| uint32_t __process_stack_base__ |
Process stack lower boundary.
This symbol must be exported by the linker script and represents the process stack lower boundary.
Referenced by ResetHandler().
| uint32_t __process_stack_end__ |
Process stack initial position.
This symbol must be exported by the linker script and represents the process stack initial position.
Referenced by ResetHandler().
| uint32_t _textdata |
ROM image of the data segment start.
Referenced by ResetHandler().
| uint32_t _data |
Data segment start.
Referenced by ResetHandler().
| uint32_t _edata |
Data segment end.
Referenced by ResetHandler().
| uint32_t _bss_start |
BSS segment start.
Referenced by ResetHandler().
| uint32_t _bss_end |
BSS segment end.
Referenced by ResetHandler().
| funcp_t __init_array_start |
Constructors table start.
Referenced by ResetHandler().
| funcp_t __init_array_end |
Constructors table end.
Referenced by ResetHandler().
| funcp_t __fini_array_start |
Destructors table start.
Referenced by ResetHandler().
| funcp_t __fini_array_end |
Destructors table end.
Referenced by ResetHandler().
| #define CRT0_CONTROL_INIT 0x00000002 |
Control special register initialization value.
The system is setup to run in privileged mode using the PSP stack (dual stack mode).
Definition at line 81 of file crt0.c.
Referenced by ResetHandler().
| #define CRT0_STACKS_FILL_PATTERN 0x55555555 |
Stack segments initialization switch.
Definition at line 88 of file crt0.c.
Referenced by ResetHandler().
| #define CRT0_INIT_STACKS TRUE |
| #define CRT0_INIT_DATA TRUE |
| #define CRT0_INIT_BSS TRUE |
| #define CRT0_CALL_CONSTRUCTORS TRUE |