本帖最后由 sxcem 于 2017-2-18 12:58 编辑
app 程序加上这么一句
int main(void)
{
SCB->VTOR = ((uint32_t)0x08000000) | (0x40000) //app 0x8040000 开始
...
}
IAP 程序
void main()
{
//先读下 app 位置 得到的地址修改下面 0x20000000的值 我的是0x20020000
printf("APP_ADDRESS : %x == 0x20020000 ? \r\n",((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ));
// if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20000000) //f746g
if (((*(__IO uint32_t*)USER_FLASH_FIRST_PAGE_ADDRESS) & 0x2FFE0000 ) == 0x20020000) //f746g
{
printf("enter app ok \r\n");
// LCD_UsrLog ((char *)" State: enter app ok ...\n");
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (USER_FLASH_FIRST_PAGE_ADDRESS + 4);
Jump_To_Application = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) USER_FLASH_FIRST_PAGE_ADDRESS);
Jump_To_Application();
/* do nothing */
while(1);
}
else
{/* Otherwise, do nothing */
/* LED3 (RED) ON to indicate bad software (when not valid stack address) */
printf("enter app Ng \r\n");
//LCD_UsrLog ((char *)" State: enter app NG ...\n");
BSP_LED_Init(LED1);
BSP_LED_On(LED1);
/* do nothing */
while(1);
}
while(1);
}
//很奇怪 为什么我设定的是 基地址+40000 应该 是0x20000000 获取的映射地址却是0x20020000 不过上面的代码就可以跳到自己的程序了
|