cancel
Showing results for 
Search instead for 
Did you mean: 

Jump to internal bootloader

trevor23
Associate III
Posted on May 07, 2010 at 19:20

Jump to internal bootloader

#bootloader-gpio
27 REPLIES 27
Posted on May 17, 2011 at 13:50

I would say this is a THUMB2 issue, the assembler is apparently just allowing regular THUMB instructions.

.thumb or perhaps -mcpu=cortex-m3 or .cpu cortex-m3

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
brmo
Associate
Posted on May 17, 2011 at 13:50

If you want to jump from your application code to the internal bootloader of the STM you have to reset also the SysTick, because the bootloader needs the counter to measure the baudrate (see AN2606).

 

USART_DeInit(USART1);

 

SysTick->CTRL = 0x04;

 

SysTick->VAL = 0;

 

 

temp = *(volatile unsigned int*)0x1FFFF004;

 

Jump_To_Bootloader = (pFunction)temp;

 

__set_MSP(*(volatile unsigned int *)0x1FFFF000);

 

Jump_To_Bootloader();

linmj
Associate
Posted on May 17, 2011 at 13:50

I

http://www.cosmetics-mac.com/

Posted on May 17, 2011 at 13:50

But what project doesn't have half a dozen interrupts running, and perhaps a couple of DMA transfers Doing it the way you describe is a trap for the unwary, ready to be fallen into.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nospamas
Associate
Posted on May 17, 2011 at 13:50

Has somebody figured it out until now if it's possible to j

ump from the application into the internal ST bootloader without having to force BOOT0 high? I would certainly make great use out of this and won't need to bother to develop my second stage bootloader.

Regards,

Alex

Posted on May 17, 2011 at 13:50

Yes. The state of the BOOTx pins is irrelevant. You simply have to call into the boot loader code in ''close to reset conditions''. ie no interrupts, clock/peripherals in reset states, and stack in the right location.

Unless your application is very simple, or you can unwind the setup you've done to the STM32, one of the better routes in to reset the STM32 and quickly branch into the Internal Boot Loader.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jkasten
Associate
Posted on June 30, 2013 at 14:38

I have a STM32F205RGY6(in a Sony Smartwatch) and trying to get it to the bootloader from my firmware. I tried your example code but it seems that using SCB->AIRCR = AIRCR_VECTKEY_MASK | (u32)0x04; clears the RAM as it just boots right back up into my firmware. I tried NVIC_SystemReset(); and get the same thing. (I didnt' see ''NVIC_GenerateSystemReset'' in the c libraries)

So I tried to put the ASM code for your ''Reboot_Loader'' as the first 4 lines in ''Reset_Handler'' in startup_stm32f2xx.S but I just get a blank screen and the USB DFU doesn't seem to enable. Do I need to so something before calling the bootloader if I want DFU mode to be enabled?

Thanks!

Posted on June 30, 2013 at 16:12

The code in this thread relates to F1 devices, as I recall the System Loader for the F2/F4 is at a different address, and that you might want to map the ROM at zero before entering DFU.

Not sure about the RAM clearing, this is usually done by code, not the processor, so I'd have to understand what was being done a little better.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
jkasten
Associate
Posted on July 01, 2013 at 04:03

Thank you for replying quickly!

Ah your right it is a different address for this chip. It is 0x1FFF0000 instead of 0x1FFFF000. http://www.st.com/st-web-ui/static/active/en/resource/technical/document/application_note/CD00167594.pdf

I tried running 0x1FFF0000 from the Reset_Handler and i see the same results. Do you think it might be using USART instead of DFU USB?

Anther angle I was trying (I know you said this wasn't reliable) was trying to run it from C code (Calling address 0x1FFF0004) after everything has been initialized. If I do some deinit of somethings and then call the bootloader I get the device to show up in the device manager on my Windows pc as a unknown device. I forced the driver for the DFU programming but I just get ''A request for the USB device descriptor failed.'' with an error code of 10. Probably because I am not quite setting it to a default state I am guessing?

Also not sure what was wrong with the magic memory detecting on boot but it seems like it is working now. However still have the same issue with the bootloader, nothing on the screen and DFU mode doesn't turn on. Any ideas?

Thanks!

Stephan Scherer
Associate II
Posted on August 21, 2013 at 08:37

Hi,

I try something similar. I want to to start a second function with my bootloader. 

The reset itself works fine, but if i enter the function i get a HardFault Error.

Here my bootloader:

Reset_Handler    PROC

                 EXPORT  Reset_Handler             [WEAK]

        IMPORT  SystemInit

        IMPORT  __main

                 LDR    R0, =SystemInit

                 BLX    R0

     LDR R0, =0x2001FFF0

     LDR R1, =0xDEADBEEF

     LDR R2, [R0, #0]

     STR R0, [R0, #0]; Invalidate

     CMP R2,R1

     BEQ Reboot_Loader

    

                 LDR     R0, =__main

                 BX      R0

                 ENDP

    

Reboot_Loader    PROC

     EXPORT    Reboot_Loader

     LDR    R0, =0x0803C000

                 BX     R0

                 ENDP

I use a STM32F2xx. Can anyone give me a hint where the problem is?

Thanks in advance.

Stephan