cancel
Showing results for 
Search instead for 
Did you mean: 

Help with application jump to system memory boot

eamonn
Associate II
Posted on March 16, 2012 at 13:34

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.

6 REPLIES 6
Posted on March 16, 2012 at 16:46

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.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
eamonn
Associate II
Posted on March 16, 2012 at 18:35

Cheers for that clive1, I have implemented it how you said and it works perfect now.

gregoire
Associate II
Posted on April 20, 2012 at 15:37

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,

Greg

Posted on April 20, 2012 at 16:43

Take a look at this thread, I can revisit this some more if required

https://community.st.com/0D50X00009XkbZhSAJ

and perhaps

https://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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
gregoire
Associate II
Posted on April 23, 2012 at 16:27

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 0x1FFF0000

Thank you very much for this useful illustration.

Greg

Posted on April 23, 2012 at 17:17

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..