2010-02-19 07:15 AM
stm32: entering DFU Program Mode
2011-05-17 04:40 AM
Use a location in RAM.
-Clive On a 64KB RAM part I use the following sequence to restart the system and get it into the system loader. I use different keys to perform other critical functions prior to enabling other features, or dropping into the main application. ie Instead of disabling features on a running system, I reboot and do the work in a very controlled set of conditions with no interrupts or anything else. I would do this in assembler, and avoid using library code, again to control the conditions, and limit the code called outside my control. *((unsigned long *)0x2000FFF0) = 0xDEADBEEF; NVIC_GenerateSystemReset(); Then very early in the restart in STM32F10x.s Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main LDR R0, =0x2000FFF0 LDR R1, =0xDEADBEEF LDR R2, [R0, #0] STR R0, [R0, #0] ; Invalidate CMP R2, R1 BEQ Reboot_Loader ; ldr r1, =0xDEADxxxx ; cmp r2, r1 ; beq Function_xxxx LDR R0, =__initial_sp LDR R1, =0x20010000 LDR R2, =0xE5E5E5E5 Clear_Heap STR R2, [R0, #0] ADD R0, #4 CMP R0, R1 BNE Clear_Heap LDR R0, =__main BX R0 ENDP ALIGN Reboot_Loader PROC EXPORT Reboot_Loader LDR R0, =0x1FFFF000 ; System Loader ROM LDR SP,[R0, #0] ; Initial Stack LDR R0,[R0, #4] ; Initial Program Counter BX R0 ENDP2011-05-17 04:40 AM
2011-05-17 04:40 AM
hi chikos and clive1
thanks for your help guys!
I'm going to use the option byte method. Doing it clive1's way was what I've been wanting to do initially. But since I want to use another persistent flag...
By the way, in case anyone wants to use option bytes method:
- the user option byte 0x1FFFF802 is reserved for a few hardware configuration flags, while the Data0 and Data1 bytes at 0x1FFFF804 can freely be used
- don't forget to erase the option bytes before programming them
- the inverse option byte will be computed by the FPEC automatically