diff options
author | Stefan Agner <stefan.agner@toradex.com> | 2017-05-12 16:23:51 -0700 |
---|---|---|
committer | Stefan Agner <stefan.agner@toradex.com> | 2017-05-16 12:34:26 -0700 |
commit | cc59882c7f0efe34baecd6ff68e1b2053a492112 (patch) | |
tree | 7036019e0cf719b6ac2f94a93a9f4f9df62ee549 /platform | |
parent | a1efb7f2ebf90307a692a1f54a03bd14714371f5 (diff) |
restore stackpointer in vector table
When using the elf file format the vector table gets linked directly
to 0x0 (0x180000 for data bus/A7 bus). U-Boots bootaux command tries
to be helpful and writes the start address to that location (since
this was necessary for binary files which have a relocated vector
table). This is not usually a problem, since we restore the stack
pointer imeaditly at the beginning.
However, the FreeRTOS port code relies on a complete vector table
(see prvPortStartFirstTask in Source/portable/GCC/ARM_CM4F/port.c).
This needs to be fixed in U-Boot: U-Boot should not write into the
vector table if it is provided by the elf binary.
For now, work around by restoring the stack pointer entry in the
vector table in the firmware startup code.
Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
Diffstat (limited to 'platform')
-rw-r--r-- | platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S b/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S index 328fa9b..2a97408 100644 --- a/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S +++ b/platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S @@ -204,12 +204,18 @@ __isr_vector: .weak Reset_Handler .type Reset_Handler, %function Reset_Handler: + cpsid i /* Mask interrupts */ /* * Set stack pointer manually. Not all loading mechanism setup stack * e.g. when using elf file format with Toradex U-Boot 2016.11 */ - ldr sp,=__stack; - cpsid i /* Mask interrupts */ + ldr sp,=__stack + /* + * When the vector table above is linked to 0x00000000 and we use elf + * U-Boot overwrites the stackpointer with 0... restore it... + */ + ldr r1,=__isr_vector + str sp, [r1] #ifndef __NO_SYSTEM_INIT bl SystemInit #endif |