2010-05-07 10:20 AM
Jump to internal bootloader
#bootloader-gpio2011-05-17 04:50 AM
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-m32011-05-17 04:50 AM
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();
2011-05-17 04:50 AM
I
2011-05-17 04:50 AM
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.
2011-05-17 04:50 AM
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
2011-05-17 04:50 AM
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.2013-06-30 05:38 AM
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!2013-06-30 07:12 AM
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.2013-06-30 07:03 PM
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.pdfI 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!2013-08-20 11:37 PM
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