2018-03-24 02:22 PM
hi
im trying to implement dual boot using BFB2 bank switching on this chip, and after the code is burned in the second bank (ox80800000), it doesnt boot.
i single stepped through the bootloader code, and it seems that the bootloader checks the first bank address to be between 0x20000000 and 0x20040000, which fails because the initial SP is located near the end of SRAM which is at 0x20050000.for this chip.
could it be a bug in the bootloader code, or something im missing ?
alternatively, how can i locate __init_sp in some lower address ?
Solved! Go to Solution.
2018-03-24 04:10 PM
Just write a lower value in the first vector and load the SP with __init_sp in Reset_Handler
For GNU/GCC the stack is frequently defined in the .LD linker script.
...
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size__Vectors DCD 0x20002000 ; Top of Stack - Nominal RAM address, set to __initial_sp later
DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD MemManage_Handler ; MPU Fault Handler...
; Reset handler
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __mainLDR SP,=__initial_sp ;; Set SP, for Keil also done in __main as I recall
LDR R0, =SystemInit
BLX R0 LDR R0, =__main BX R0 ENDP2018-03-24 04:10 PM
Just write a lower value in the first vector and load the SP with __init_sp in Reset_Handler
For GNU/GCC the stack is frequently defined in the .LD linker script.
...
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY EXPORT __Vectors EXPORT __Vectors_End EXPORT __Vectors_Size__Vectors DCD 0x20002000 ; Top of Stack - Nominal RAM address, set to __initial_sp later
DCD Reset_Handler ; Reset Handler DCD NMI_Handler ; NMI Handler DCD HardFault_Handler ; Hard Fault Handler DCD MemManage_Handler ; MPU Fault Handler...
; Reset handler
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT SystemInit IMPORT __mainLDR SP,=__initial_sp ;; Set SP, for Keil also done in __main as I recall
LDR R0, =SystemInit
BLX R0 LDR R0, =__main BX R0 ENDP2018-03-25 11:26 PM
thanks, worked perfecly