SCB->VTOR = ((uint32_t) &__Vectors);
#define FLASH_START 0x00006000 #define FLASH_LENGTH 0x3A000
您好,
如果想要指定地址偏移,更推荐在memory_regions.ld里进行修改
在设置完地址便宜后需要在startup选项卡中添加下面这段代码来指定新的中断table:
set $pc = *0x00006004set $sp = *0x00006000set {int}0xE000ED08 = 0x00006000
set $sp = *0x00006000set {int}0xE000ED08 = 0x00006000
跳转后的app,中断无法正常进入,
如果您修改了FLASH的地址,那么Vector需要在程序里进行重定向,如果您使用了bootloader,那么需要在bootloader里重定向:
SCB->VTOR = 0x6000
我重新梳理下我这边的问题,
1、bootloader 引导程序如下,(所占大小为:0~0x6000)
typedef void (*pFunction)(void); pFunction Jump_To_Application; struct arm_vector_table { uint32_t msp; uint32_t reset; }; void Jump_to_APP(uint32_t app_addr) { uint32_t JumpAddress; // printf("jump to app: %#x\r\n", FLASH_APP_ADDR); printf( "(app_addr) & 0x2FFE0000 [0x%08X]\r\n",((*(volatile uint32_t*)app_addr) & 0x2FFE0000 )); /* Test if user code is programmed starting from address "APPLICATION_ADDRESS" */ if (((*(volatile uint32_t*)app_addr) & 0x2FFE0000 ) == 0x20000000)// 上面的值是取出FLASH_APP_ADDR里面的值来 { __set_PRIMASK(1); //关总中断 0打开总中断 JumpAddress = *(volatile uint32_t*) (app_addr + 4); Jump_To_Application = (pFunction) JumpAddress; //printf("jump %#x success \r\n",FLASH_APP_ADDR); //__disable_irq(); // HAL_UART_DeInit(&huart1);//取消外设,避免APP 里用到串口时无法正常使用 __set_MSP(*(volatile uint32_t*) app_addr); //设置SP指针,复位指针 //SCB->VTOR = 0x6000; Jump_To_Application(); //开始跳转 // static struct arm_vector_table *vt; // vt = (struct arm_vector_table *)(app_addr); // vt->msp = *(uint32_t *)app_addr; // vt->reset = *(uint32_t *)(app_addr+4); // SCB->VTOR = ((int)(&(vt->msp)) & 0x1FFFFF80); // __DSB(); // __set_MSP(vt->msp); // __set_PSP(*(uint32_t *)app_addr); // __set_PRIMASK(1); // ((void (*)()) vt->reset)(); // __set_PRIMASK(0); } else { printf( "erorr [0x%08x]\r\n",(*(volatile uint32_t*)app_addr) ); } } void hal_entry(void) { SysTick_Init(1000); ra6t2_gpio_init_func(); ra6t2_flash_init_func(); ra6t2_uart0_init_func(); ra6t2_uart0_dma_init_func(); ra6t2_gpt3_timer_uart_init_func(); Upgrade_Flag = *(__IO uint32_t*)(FLASH_HP_DF_BLOCK_68); printf("---(FLASH_HP_CF_BLOCK_3+4)&0xFF000000 = 0x%08X---\r\n",(FLASH_HP_CF_BLOCK_3+4)&0xFF00000); if(1)//Upgrade == Upgrade_Flag || NotUpgrade == Upgrade_Flag) { //printf("------%#x\r\n",(FLASH_APP_ADDR+4)&0xFF000000); /*跳转到APP1中运行*/ if(((FLASH_HP_CF_BLOCK_3+4)&0xFF000000)==0x00000000) //Judge if start at 0X08XXXXXX. { // printf("jump APP1 running\r\n"); Jump_to_APP(FLASH_HP_CF_BLOCK_3); // Jump to APP } else{ printf("---failed---%#x\r\n",(FLASH_HP_CF_BLOCK_3+4)&0xFF000000); } } // private中的最后一个字节存放是否升级的标志位 printf("---------- Enter BootLoader ----------\r\n"); printf("\r\n"); printf("======== flash pration table =========\r\n"); printf("| name | start addr | size |\r\n"); printf("--------------------------------------\r\n"); printf("| boot | 0x00000000 | 0x00006000 |\r\n"); printf("| app1 | 0x08006000 | 0x0003B000 |\r\n"); //printf("| app2 | 0x0800A000 | 0x00032000 |\r\n"); printf("| private | 0x08000000 | 0x08001000 |\r\n"); printf("======================================\r\n"); printf("Upgrade_Flag = %x\r\n", Upgrade_Flag); printf("----------BootLoader Wait Firmware Update----------\r\n"); while(1) { ParseProtocol_func(); ParseAck_func(); } #if BSP_TZ_SECURE_BUILD /* Enter non-secure code */ R_BSP_NonSecureEnter(); #endif }
该工程是从普通工程参考stm32 ota升级做的bootloader移植,未使用MCUBoot进行生成
2、app部分工程如下,其中调整的
正常编译下载后,app部分无法产生中断,SCB->VTOR = (uint32_t) &__Vectors;该如何处理才能让app产生中断
3、bootloader+app 的运行日志,bootloader正常跳转,而app无法产生中断导致程序无法运行
可以参考此例程中bootloader vector重定向的操作1325.EK-RA2L1_Bootloader.zip