diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2020-11-24 00:38:09 -0700 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2020-11-24 00:53:28 -0700 |
commit | 2478a549b9f64c50310da41c861b8f86fdea2861 (patch) | |
tree | 3a62960f83453f354cbf309ac0722ed2ea6c27c7 /02-usart/linker/linker_script.ld | |
parent | 9dab2bf91ed3e6af7c7b07590ccc8c3b211a763a (diff) | |
download | stm32l4-2478a549b9f64c50310da41c861b8f86fdea2861.tar.gz stm32l4-2478a549b9f64c50310da41c861b8f86fdea2861.tar.bz2 stm32l4-2478a549b9f64c50310da41c861b8f86fdea2861.zip |
Add new system for startup.
Now instead of init() and main() being responsible for all
initialization, individual modules can link in their own
initialization routines.
There are 7 levels for these initializiation routines.
So far these are how the levels are defined
level 0 - Here the world is dark. Nothing is initialized.
This level is responsible for initializing the
system clock.
level 1 - The system clock has been configured, but nothing else. Not
even global variables. This level is responsible for loading
the data sections from flash and clearing the .bss section.
level 2 - USART2 is enabled and set to be the main kernel logging
vehicle. From this point on klogf(...) can be used.
level 3 - The NVIC is reset to point to the flash. From this point
on interrupts can be received. I expect this is where
most core initialization routines will take place
levels 4 to 7 - User initializiation levels.
main - main() is called after all 8 initialization levels have executed,
so in a sense main() is like a 9th initialization level, except
that there is can be only one main() routine whereas there can be
multiple initalization routines per level.
Diffstat (limited to '02-usart/linker/linker_script.ld')
-rw-r--r-- | 02-usart/linker/linker_script.ld | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/02-usart/linker/linker_script.ld b/02-usart/linker/linker_script.ld index 348d03b..9a9f5b3 100644 --- a/02-usart/linker/linker_script.ld +++ b/02-usart/linker/linker_script.ld @@ -23,8 +23,27 @@ SECTIONS *(.data); DATA_SEGMENT_STOP = .; + INIT_ROUTINES_FLASH_START = + LOADADDR(.data) + (DATA_SEGMENT_STOP - DATA_SEGMENT_START); + + INITS_START = .; + *(.init0); + *(.init1); + *(.init2); + *(.init3); + *(.init4); + *(.init5); + *(.init6); + *(.init7); + INITS_END = .; + + INIT_ROUTINES_FLASH_STOP = + LOADADDR(.data) + (INITS_END - DATA_SEGMENT_START); + /* Align by 4 so we can optimize the copier to use uint32's. */ . = ALIGN(0x04); + + *(.noinit); } >sram1 AT>flash BSS_START = .; |