2016-12-06 02:31 AM
I have problem with jump to application by bootloader after reset.
The device used is the STM32F098.The code of the bootloader making the jump is:
&sharpdefine APPLICATIONADDRESS (uint32_t)0x08008000
/* Test if user code is programmed starting from address 'ApplicationAddress' */
if (((*(__IO uint32_t*)APPLICATIONADDRESS) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (APPLICATIONADDRESS + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) APPLICATIONADDRESS); Jump_To_Application(); }the first time after download application, jump to program works perfectly.
But when reset occure, the application deleted and program start at bootloader !
#problem-jump-application-after-reset2016-12-06 05:23 AM
Hey there,
you need to be more verbose otherwise it's hard to help you efficiently.
At the end you mentioned that after reset the application gets deleted. How did you verify this? How can an app be deleted? Does this your bootloader allows? Under which conditions?
I assume you are using your own bootloader which starts from 0x0800 0000 and your app starts at 0x0800 8000, is that right?
Have you checked with ST-Link utility, that the application code is in the 0x0800 8000 range after reset or the memory is empty?
I'm not familiar with F0 devices much, but I assume this will be the same, don't forget to relocate your vector table for your application.
How do you jump into your bootloader and your main app? Do you always jump into your bootloader and from there to your app or not?
Have a nice day,
Renegade
2016-12-06 05:49 AM
Hi,
Sorry for my short response.
As you said, my bootloader start at 0x0800000 and my application at 0x08008000.
My simple application consist of blinky a led. when bootloader jump to application, I can see
that it work perfectly. I also check memory register and compare it with .hex file ( everything is ok).
So, the problem is when i power down my board and restart it, i can see through
st link utility, memory register empty.
here before reset
here after reset (or restart my board)
I relocate my vector table like this :
linker file : .RAMVectorTable(NOLOAD): {*(.RAMVectorTable)} >VTRAM
main application:
int main(void)
{ uint32_t ui32_VectorIndex = 0;for(ui32_VectorIndex = 0; ui32_VectorIndex < 48; ui32_VectorIndex++)
{ VectorTable[ui32_VectorIndex] = *(__IO uint32_t*)((uint32_t)APPLICATION_ADDRESS + (ui32_VectorIndex << 2)); }/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);Any ideas please
2016-12-06 07:14 AM
at 0x0800000, there is my bootloader program and also after reset.
Just app is missing.
My bootloader download binary file, flash area memory at 0x08008000 and jump to app...like application note
2016-12-06 07:22 AM
Well it is going to fail the stack pointer check with 0xFFFFFFFF in the base vector. ie it's not pointing to 0x2000xxxx so the sanity check doesn't allow it to call the application.
You need to review what code you have in the loader or the application that can erase the flash. Instrument that, and understand why/how it is called/used.
2016-12-06 07:49 AM
What about your memory at 0x0800 0000? Is it also empty? Or only your main app is missing?
Which operations is your bootloader performing? Can you describe the process a bit more?
Thanks,
Renegade
PS: Have you looked at this application note:
? Maybe this can help a lot. :)2016-12-06 09:38 AM
As Clive said,
there has to be something in your bootloader code, what erases the code in the flash. I hardly think the flash is erased by itself...
Try to debug your code right after reset and go through your bootloader step by step to see, what the bootloader does with your main application. In my opinion you have some function erasing the flash sector/page by sector/page if some condition is not met... This removes your app after reset. Just my opinion.
Good luck with your application!
Have a nice day,
Renegade
2016-12-06 11:05 AM
/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE);This needs to enable the clock, not reset
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
The ST example code is broken, has been for a few years...