2016-10-27 06:19 AM
I have implemented the following code I found on this forum to execute the bootloader with register addresses changed to be for the STM32L162 part. I am developing with IAR tools.
PUBWEAK Reboot_DFU
SECTION .text:CODE:REORDER:NOROOT(2)
Reboot_DFU
LDR R0, =0x40023820 ; RCC_APB2ENR, enable APB2 clock so we can write SYSCFG_MEMRMP register
LDR R1, =0x00000001 ; set Bit 0 SYSCFGEN: System configuration controller clock enable
STR R1, [R0, #0]
LDR R0, =0x40010000 ; SYSCFG_MEMRMP
LDR R1, =0x00000001 ; remap ROM at zero
STR R1, [R0, #0]
LDR R0, =0x00000000 ; should be System Memory since we mapped it to 0
LDR SP, [R0, #0] ; assign main stack pointer
LDR R0, [R0, #4] ; load bootloader address
BX R0
System Memory start address is 0x1FF00000 which I did try hardcoding in to load the SP and bootloader address. When I did it this way I could see the above code being executed, the SP was correct, the bootloader address was correctly loaded but the bootloader didn't execute, instead it simply booted the application.
I changed the code to the above where I load the SP and bootloader address from location 0x00000000 which should be remapped to System Memory but when I checked the SP it was for the application (Flash memory).
So it appears by the point I am ready to jump to the bootloader the remap of System memory to 0x00000000 has not taken affect although I can see by checkging the register contents of SYSCFG_MEMRMP that MEM_MODE is set to 0x
Am I missing any setup steps?
2016-10-27 08:13 AM
Not a part I'm using, you're in a better position to debug/evaluate, does the mapping work outside the debugger?
TryLDR R0, =0x1FF00000 ; System Memory
LDR SP, [R0, #0] ; assign main stack pointer
LDR R0, [R0, #4] ; load bootloader address