IAP jump to APP, but it don't work.HELP!!!
Hi,
I was doing IAP&App in STM32F030rc.
When I finish IAP and APP, and run from IAP to jump to APP, it can not be realized. I have try many ways, but useless. Please help me, I have waste a lot of time for this function.
IAP project:
#define APPADDRESS 0x08020000;
typedef void (*pFunction)(void); pFunction Jump_To_Application;uint32_t JumpAddress;uint32_t ApplicationAddress = APPADDRESS;int main(void)
{//NVIC_SetVectorTable();
/* USER CODE BEGIN 1 *//* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();/* Configure the system clock */
SystemClock_Config();/* Initialize all configured peripherals */
MX_GPIO_Init(); // MX_RTC_Init(); MX_USART1_UART_Init(); MX_ADC_Init(); // MX_I2C1_Init(); MX_USART2_UART_Init(); //MX_USART3_UART_Init(); //MX_USART5_UART_Init();/* USER CODE BEGIN 2 */
log_init(); USART_Prepare(); JumpToApp();....
}
void JumpToApp(void)
{ /* check the APP address stack point is correct, because the first 4 bytes store the stack address, default is 0x20000000 */ TRACE_DBG_STRING(DEBUG_MODULE, LOG_LVL_INFO, 'JumpToApp:%x', ((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ));if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000)
{ __set_PRIMASK(1);TRACE_DBG_STRING(DEBUG_MODULE, LOG_LVL_INFO, 'JumpToApp2:%x', *(__IO uint32_t*) (ApplicationAddress + 4));
/* Move the 4 bytes to APP address */
JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4); /* Point to the APP entry address */ Jump_To_Application = (pFunction) JumpAddress; /* Reset the top of the stack point address */ __set_MSP(*(__IO uint32_t*) ApplicationAddress); /* Jump to the reset function */ Jump_To_Application(); }}================================================
APP project:
#define APPADDRESS 0x08020000;
uint32_t ApplicationAddress = APPADDRESS;int main(void)
{/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init();/* Configure the system clock */
SystemClock_Config(); NVIC_SetVectorTable();//__set_PRIMASK(0); /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_RTC_Init(); MX_USART1_UART_Init(); MX_ADC_Init(); MX_I2C1_Init(); MX_USART2_UART_Init(); MX_USART3_UART_Init(); MX_USART5_UART_Init();.....
}
void NVIC_SetVectorTable(void)
{ U8 i; U32 *pVecTab=(U32 *)(0x20000000); for(i = 0; i < 48; i++) { *(pVecTab++) = *(__IO U32*)(ApplicationAddress + (i<<2)); } __HAL_RCC_SYSCFG_CLK_ENABLE(); __HAL_SYSCFG_REMAPMEMORY_SRAM();}And of course, I have changed the .ICF file.
IAP project:
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*//* IcfEditorFile='$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml' *//*-Specials-*/define symbol __ICFEDIT_intvec_start__ = 0x08000000;/*-Memory Regions-*/define symbol __ICFEDIT_region_ROM_start__ = 0x08000000;define symbol __ICFEDIT_region_ROM_end__ = 0x0801FFFF;define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;/*-Sizes-*/define symbol __ICFEDIT_size_cstack__ = 0x400;define symbol __ICFEDIT_size_heap__ = 0x200;/**** End of ICF editor section. ###ICF###*/define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };initialize by copy { readwrite };
do not initialize { section .noinit };place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite, block CSTACK, block HEAP };export symbol __ICFEDIT_region_RAM_start__;
export symbol __ICFEDIT_region_RAM_end__;=============================================
APP project:
/*###ICF### Section handled by ICF editor, don't touch! ****/
/*-Editor annotation file-*//* IcfEditorFile='$TOOLKIT_DIR$\config\ide\IcfEditor\cortex_v1_0.xml' *//*-Specials-*/define symbol __ICFEDIT_intvec_start__ = 0x08020000;/*-Memory Regions-*/define symbol __ICFEDIT_region_ROM_start__ = 0x08020000;define symbol __ICFEDIT_region_ROM_end__ = 0x0803FFFF;define symbol __ICFEDIT_region_RAM_start__ = 0x20000000;define symbol __ICFEDIT_region_RAM_end__ = 0x20007FFF;/*-Sizes-*/define symbol __ICFEDIT_size_cstack__ = 0x400;define symbol __ICFEDIT_size_heap__ = 0x200;/**** End of ICF editor section. ###ICF###*/define memory mem with size = 4G;
define region ROM_region = mem:[from __ICFEDIT_region_ROM_start__ to __ICFEDIT_region_ROM_end__];define region RAM_region = mem:[from __ICFEDIT_region_RAM_start__ to __ICFEDIT_region_RAM_end__];define block CSTACK with alignment = 8, size = __ICFEDIT_size_cstack__ { };
define block HEAP with alignment = 8, size = __ICFEDIT_size_heap__ { };initialize by copy { readwrite };
do not initialize { section .noinit };place at address mem:__ICFEDIT_intvec_start__ { readonly section .intvec };
place in ROM_region { readonly };
place in RAM_region { readwrite, block CSTACK, block HEAP };export symbol __ICFEDIT_region_RAM_start__;
export symbol __ICFEDIT_region_RAM_end__;