2012-03-16 05:34 AM
Hello, I’m trying to force my device (STM32F417) into system memory boot without physically setting the boot pins (cannot access them) and resetting the board i.e. jump to it from my application when the user requests and then re-flash using USB and the DfuSe application.
Where I stuck is when the user send a reprogram command over the USB the following code is ran:
SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1FFF0004));
hw_DeInit();
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
RCC_SYSCLKConfig(RCC_SYSCLKSource_HSI);
__set_PRIMASK(1);
__set_MSP(0x20001000);
SysMemBootJump();
while(1);
but the DfuSe application doesn’t detect the device. And after a period of time >10secs the device will restart.
Can anyone help or give me direction as to the possible issue.
Re-flashing using IAP isn’t really an option as the user cannot reset the board easily and all GPIO pins are taken therefore cannot detect a re-flash is required on restart.
Cheers for any help you can give.
2012-03-16 08:46 AM
Re-flashing using IAP isn’t really an option as the user cannot reset the board easily and all GPIO pins are taken therefore cannot detect a re-flash is required on restart.
Why couldn't you just park a magic value in SRAM and key off of that? Similarly a different value could vector straight into the System ROM as you check for it in the ResetHandler.2012-03-16 10:35 AM
Cheers for that clive1, I have implemented it how you said and it works perfect now.
2012-04-20 06:37 AM
Hi Clive, Hi Eamonn
Would it be possible to share some code alighting this ? I read a lot about it, but I m still not comfortable with it... :( Thanks in advance, Greg2012-04-20 07:43 AM
Take a look at this thread, I can revisit this some more if required
https://community.st.com/0D50X00009XkbZhSAJ
and perhapshttps://community.st.com/0D50X00009XkafZSAR
Edit: Fixed DEAD LINKs, original post from Apr 20 2012
Reset_Handler PROC EXPORT Reset_Handler [WEAK] IMPORT __main ;... LDR R0, =0x2000FFF0 ; Address for RAM signature LDR R1, =0xDEADBEEF LDR R2, [R0, #0] STR R0, [R0, #0] ; Invalidate CMP R2, R1 BEQ Reboot_Loader LDR R1, =0xDEADDEAD CMP R2, R1 BEQ Reboot_RAM ; Other APPs within FLASH LDR R0, =0x08004000 ; APP1_FLASH LDR R1, =0xDEAD0001 CMP R2, R1 BEQ Reboot LDR R0, =0x08008000 ; APP2_FLASH LDR R1, =0xDEAD0002 CMP R2, R1 BEQ Reboot ; Add other choices ;... LDR R0, =__main BX R0 ENDP .. ; Vector into System Loader Reboot_Loader PROC EXPORT Reboot_Loader LDR R0, =0x1FFFF000 ; ROM Base LDR SP,[R0, #0] LDR R0,[R0, #4] BX R0 ENDP Reboot_RAM PROC EXPORT Reboot_RAM LDR R0, =0x20000000 ; RAM Base LDR SP,[R0, #0] LDR R0,[R0, #4] BX R0 ENDP ; More Generic Reboot PROC EXPORT Reboot LDR SP,[R0, #0] LDR R0,[R0, #4] BX R0 ENDP
2012-04-23 07:27 AM
I really wish to Thank you!!!
It worked perfectly,My little scheme used to set the boot pin during the reset step is now obsolete.I don't no if there is a typo or if it was because of STM32F2xx family, but for me the bootloader is at 0x1FFF0000Thank you very much for this useful illustration.Greg2012-04-23 08:17 AM
I don't no if there is a typo or if it was because of STM32F2xx family, but for me the bootloader is at 0x1FFF0000
It's an STM32F103 thing, adjust as required/appropriate, the code was mainly for illustration. Ditto with the RAM locations, and the magic codes.