Hello Hesham AL-Matary, please add a blank line after the subject in your Git commit messages.
Please have a look at the attached document regarding the low-level ARM startup. In particular all functions called by the bsp_start_hook_0() and bsp_start_hook_1() must reside in the .bsp_start_text section. Similar .bsp_start_data for the data. This is very important for some BSPs which operate with a boot memory map (e.g. LPC24XX with boot from external NOR flash).
-- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.Title: Low-Level Start on ARM
Low-Level Start on ARM
Memory Map
ARM controllers typically have quite a scattered memory map. Smaller systems may have several disconnected on-chip memory regions. The linker command file infrastructure available for ARM board support packages (BSP) allows a flexible usage of memory regions. A BSP requires usually three linker command files which use the INCLUDE directive to provide a single set of definitions
-
the basic linker command file linkcmds.base,
-
the architecture specific linker command file linkcmds.armv4 or linkcmds.armv7m,
-
the BSP specific linker command file linkcmds.bsp_name.
The configure macro RTEMS_BSP_LINKCMDS will copy linkcmds.bsp_name to linkcmds during the BSP configuration. It will be installed it into the BSP specific installation path. This path will be added to the GCC search path via the -B option and the linker will use this file instead of its default file.
The BSP specific linker command file defines the distribution of physically available memory regions and the architecture. It may override default values used by the more general files.
Region | Usage |
---|---|
REGION_START |
low-level start code and data |
REGION_VECTOR |
mode stacks; vector table if bsp_vector_table_in_start_section symbol is not defined |
REGION_TEXT |
text sections |
REGION_TEXT_LOAD |
load region for text sections |
REGION_RODATA |
read-only data sections |
REGION_RODATA_LOAD |
load region for read-only data sections |
REGION_DATA |
read-write data sections |
REGION_DATA_LOAD |
load region for read-write data sections |
REGION_FAST_TEXT |
fast text section |
REGION_FAST_TEXT_LOAD |
load region for fast text section |
REGION_FAST_DATA |
fast data section |
REGION_FAST_DATA_LOAD |
load region for fast data section |
REGION_BSS |
zero-initialized read-write data section |
REGION_WORK |
RTEMS work space and C program heap |
REGION_STACK |
optional region for thread stacks (may be of zero size) |
Symbol | ARMv4 Default | ARMv7-M Default | Usage |
---|---|---|---|
bsp_section_robarrier_align |
1 |
1 |
barrier alignment between text and read-only data sections |
bsp_section_rwbarrier_align |
1 |
1 |
barrier alignment between read-only and read-write data sections |
bsp_stack_align |
8 |
8 |
stack alignment |
bsp_stack_abt_size |
128 |
0 |
abort mode stack size |
bsp_stack_fiq_size |
128 |
0 |
fast interrupt mode stack size |
bsp_stack_irq_size |
512 |
0 |
interrupt mode stack size |
bsp_stack_svc_size |
512 |
0 |
supervisor mode stack size |
bsp_stack_und_size |
128 |
0 |
undefined mode stack size |
bsp_stack_main_size |
0 |
4096 |
main stack size |
bsp_processor_count |
1 |
1 |
the processor count of the system in SMP configurations |
bsp_vector_table_in_start_section |
undefined |
undefined |
indicates if the vector table remains in the start section |
Example with MMU
This example is used on an ARM Cortex-A processor based BSP. The ARM controller with a memory management unit (MMU) need 16KiB to store the translation table (bsp_translation_table_base). This system has only one physical memory region, e.g. a DDR2 SDRAM. The interrupt and abort mode stacks sizes are increased (bsp_stack_irq_size and bsp_stack_abt_size). A read-write barrier of 1MiB is introduced to separate the read-write from the read-only sections (bsp_section_rwbarrier_align). This helps to set up a read-only protection with the MMU which uses a page size of 1MiB. Since the start region (REGION_START) is mapped to 0x0 and resides in a writeable memory (e.g. it is not a flash memory) we can use the vector table used for exception processing in the start section during the whole system lifetime (bsp_vector_table_in_start_section). Since this is used on a SMP configuration, the processor count is set to reserve enough stack space for all mode stacks (bsp_processor_count).
MEMORY { RAM : ORIGIN = 0x00000000, LENGTH = 256M - 16k RAM_MMU : ORIGIN = 0x0fffc000, LENGTH = 16k } REGION_ALIAS ("REGION_START", RAM); REGION_ALIAS ("REGION_VECTOR", RAM); REGION_ALIAS ("REGION_TEXT", RAM); REGION_ALIAS ("REGION_TEXT_LOAD", RAM); REGION_ALIAS ("REGION_RODATA", RAM); REGION_ALIAS ("REGION_RODATA_LOAD", RAM); REGION_ALIAS ("REGION_DATA", RAM); REGION_ALIAS ("REGION_DATA_LOAD", RAM); REGION_ALIAS ("REGION_FAST_TEXT", RAM); REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM); REGION_ALIAS ("REGION_FAST_DATA", RAM); REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM); REGION_ALIAS ("REGION_BSS", RAM); REGION_ALIAS ("REGION_WORK", RAM); REGION_ALIAS ("REGION_STACK", RAM); bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096; bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024; bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1M; bsp_vector_table_in_start_section = 1; bsp_translation_table_base = ORIGIN (RAM_MMU); bsp_processor_count = DEFINED (bsp_processor_count) ? bsp_processor_count : 4; INCLUDE linkcmds.armv4
Example without MMU
This example is used on an ARM7TDMI based BSP. The external flash memory provides regions used for low-level BSP start and the load regions of other sections. The internal SRAM provides the regions for the vector table and mode stacks, the fast text section and the thread stacks. The internal USB peripheral RAM provides a region for the fast data section. The text, read-only data, read-write data and the work space are located in the external SDRAM.
MEMORY { RAM_INT : ORIGIN = 0x40000000, LENGTH = 64k RAM_USB : ORIGIN = 0x7fd00000, LENGTH = 16k RAM_EXT : ORIGIN = 0xa0400000, LENGTH = 4M ROM_BOOT : ORIGIN = 0x81000000, LENGTH = 16k ROM_EXT : ORIGIN = 0x81010000, LENGTH = 2M - 64k } REGION_ALIAS ("REGION_START", ROM_BOOT); REGION_ALIAS ("REGION_VECTOR", RAM_INT); REGION_ALIAS ("REGION_TEXT", RAM_EXT); REGION_ALIAS ("REGION_TEXT_LOAD", ROM_EXT); REGION_ALIAS ("REGION_RODATA", RAM_EXT); REGION_ALIAS ("REGION_RODATA_LOAD", ROM_EXT); REGION_ALIAS ("REGION_DATA", RAM_EXT); REGION_ALIAS ("REGION_DATA_LOAD", ROM_EXT); REGION_ALIAS ("REGION_FAST_TEXT", RAM_INT); REGION_ALIAS ("REGION_FAST_TEXT_LOAD", ROM_BOOT); REGION_ALIAS ("REGION_FAST_DATA", RAM_USB); REGION_ALIAS ("REGION_FAST_DATA_LOAD", ROM_BOOT); REGION_ALIAS ("REGION_BSS", RAM_EXT); REGION_ALIAS ("REGION_WORK", RAM_EXT); REGION_ALIAS ("REGION_STACK", RAM_INT); INCLUDE linkcmds.armv4
Low-Level BSP Start
The BSP entry symbol is _start. The boot process must jump to this symbol to initiate the low-level BSP start which will hopefully end up in a running RTEMS application. At this point the start region must be initialized and accessible. Since the first instructions of the start code contain only program counter relative references it is possible to run this code with an address offset (e.g. the boot flash is mapped to a special memory region in boot mode). The first stage boot loader on systems with a MMU and cache should
-
disable the MMU,
-
flush and invalidate the caches,
-
disable the cache,
-
invalidate the branch predictor.
The low-level start performs the following steps:
-
The mode stacks are initialized.
-
The Neon and VFP unit is enabled if necessary.
-
Branch to bsp_start_hook_0. This hook should perform the following actions:
-
Set up the PLL.
-
Make the start memory accessible on its intended location.
-
Additional start memory initialization steps, e.g. change flash access parameter from default boot values to optimized values.
-
-
The hook returns and the start code runs now on its intended location. The vector table is copied to its final destination if necessary.
-
Branch to bsp_start_hook_1. This hook should perform the following actions:
-
Set final memory mappings, e.g. change from boot to normal memory map.
-
Initialize memory used by other sections.
-
Initialize MMU and cache.
-
Copy the sections from its load to the runtime areas with bsp_start_copy_sections.
-
Clear the BSS section (zero-initialized read-write data) with bsp_start_clear_bss.
-
-
The hook returns and the start code calls boot_card. This function will not return.
Depending on the system the start hooks must only use code and data that resides in the start region. For this purpose a bsp_start_memcpy function is provided. This memory copy variant executes from the stack and may be used to initialize memory attributes of the currently running code.
_______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel