2014-06-23 06:35 AM
I have problem with jump to application by bootloader.
The device used is the STM32F105R8. The bootloader does not jump in the application,it crashes in the function ''Jump_To_Application()''. The code of the bootloader making the jump is: #define 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(); } In the application i have relocate the vector table: int main(void) { // __disable_irq(); /* Set the Vector Table base location at 0x8000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8000); // __enable_irq(); /***************** Add your application code here ***************************/ ........ } I attached the image (bootloader + application) downloaded from flash.2014-06-23 07:36 AM
Wouldn't the code typically in SystemInit() relocate the Vector table?
Your application does not appear to be linked at 0x08008000, the ResetHandler vector points to 0x08007165 which is all 0xFF's a) You could print out values for the SP/PC before you jump b) You should be able to step through the transfer code and into the application, do it in the disassembly view, and pay attention to the register contents, and where it jumps too.2014-06-24 03:35 AM
I am attaching
the
screen shoot
,you
look at
the values
of ST
/ LR
before the jump.The
reallocation
of the vector table
takes place
in the application
, I can notsee
the values that
assumes
ST /
LR
in the application
.
Why the ResetHandler vector points to 0x08007165? Thanks ________________ Attachments : SP_LR_Value.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0pM&d=%2Fa%2F0X0000000bej%2FBTil3SqiG4Z3snRRB8FUsqSistDtorqTzmxM4BR1m48&asPdf=false2014-06-24 06:41 AM
Probably because you haven't set up the target memory parameters correctly, or the linker script / scatter file.
2014-06-24 08:04 AM
I attached the source code.
Can you controller the target memory parameters? Thanks ________________ Attachments : Bootloader.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0du&d=%2Fa%2F0X0000000bei%2FlF9Sfv_k9.Pg7Don3jMcjpIi3UBIqNSJLg6MjTBSga0&asPdf=false2014-06-24 08:46 AM
You have to separate the Boot Loader and the Application. The Application needs to be compiled for the higher address (0x08008000 ?)
2014-06-24 11:37 PM
The Application and Bootloader is separated.
The option target for Application in attached. You can give
me
some suggestions?
Thanks ________________ Attachments : Option_Application.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0fx&d=%2Fa%2F0X0000000beh%2F79pSp4wlNuLzYAqyevmpTo2AVFX.w1Shamk85PVWisE&asPdf=false2014-06-25 02:46 AM
I solved!
The solution consist in settings the parameters in application code: 1) In SystemInit function the ''VECT_TAB_OFFSET'' must be equal as 0x7000 (application address - 0x1000); 2) The Application needs to be compiled for the higher address (0x08008000) with size equal 0x9000 (flash size - VECT_TAB_OFFSET); 3) The first istruction in the main must be NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x8000).2014-06-25 03:22 AM
Sounds like you're modifying code that's already been adapted, the SCB->VTOR needs to end up pointing to 0x08008000, where FLASH_BASE = 0x08000000, VECT_TAB_OFFSET = 0x8000, or FLASH_BASE = 0x08008000, VECT_TAB_OFFSET = 0
system_stm32f1xx.c...
/*!<
Uncomment
the following line if you need to relocate your vector Table in
Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x8000 /*!< Vector Table base offset field.
This value must be a multiple of 0x */
...
void SystemInit (void)
{
/* Reset the RCC clock configuration to the default reset state(for debug purpose) */
/* Set HSION bit */
RCC->CR |= (uint32_t)0x00000001;
...
/* Configure the System clock frequency, HCLK, PCLK2 and PCLK1 prescalers */
/* Configure the Flash Latency cycles and enable prefetch buffer */
SetSysClock();
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM. */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH. */
#endif
}
Personally I prefer letting the linker do it by using SCB->VTOR = __Vectors;
2014-06-25 05:19 AM
The VECT_TAB_OFFSET must be equal 0x7000 ( 0x8000 - offset) else not function! This for application.
You need configure the option device: ________________ Attachments : OptionTarget.JPG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0od&d=%2Fa%2F0X0000000beg%2FkL8FbDF3Dx0X5io6..3K2Z76U7RY3YIiRb6p3ECY2V8&asPdf=false