AnsweredAssumed Answered

STM32L476 - Jump to flashloader from user code

Question asked by confalonieri.fabio on Nov 16, 2017
Latest reply on Nov 16, 2017 by confalonieri.fabio

I am trying to jump to flash loader from user application. I am using a custom board based on the STM32L476.

Premising that the standard procedure "Hw Reset + Boot0 pin setup" works flawlessly by using the examples from the forum I implemented the below reset firmware

 

        THUMB
        PUBWEAK Reset_Handler
        SECTION .text:CODE:NOROOT:REORDER(2)
Reset_Handler
;  ORIGINAL
;  LDR     R0, =SystemInit
;       BLX     R0
;       LDR     R0, =__iar_program_start
;       BX      R0
; modified reset checking flash loader
;
  LDR     R0, =0x20017ff0  ; ADR to check FW reload signature
  LDR  R1, =0xDEADBEEF  ; FW reload signature
  LDR  R2,[R0, #0]   ;
  STR  R0,[R0, #0]         ; Reset FW reload signature for successive start up
  CMP  R2,R1               ;
  BEQ  Reboot_Loader  ; Jump to flash loader
;
; NO FLASH LOADER CONTINUE WITH STD RESET
;
  LDR     R0, =SystemInit
        BLX     R0
        LDR     R0, =__iar_program_start
        BX      R0  
;
; reboot to flash loader
;
Reboot_Loader
        LDR  R0, =0x40021060
  LDR  R1, =0x00004001  ; SysCFG + UART1 CLK
  STR  R1, [R0, #0]  ; Set it
  LDR  R0, =0x40010000
  LDR  R1, =0x00000001     ; Remap system memory
  STR  R1, [R0, #0]  ; Set it
  LDR     R0, =0x1FFF0000     ; System memory address
  LDR  SP,[R0, #0]   ; Load SP
  LDR  R0,[R0, #4]   ; Load Start address
  BX  R0     ; Jump to flash loader

 

Unfortunately, when I run the STFlashLoader application  it did not recognise the SMT32L476.

Using the IAR debugger I saw that the jump to flashloader starts and loop inside. Anyhow the debugger show address  1fffxxxx.

 

Any idea ? What I am doing wrong ?

Outcomes