您尚未登录。

楼主 # 2024-08-21 13:45:44

Gentlepig
会员
注册时间: 2018-10-24
已发帖子: 1,378
积分: 1343.5

daplink源码,为何boot程序里也有SCB->VTOR设置?

这是在main_bootloader.c文件里:

264 int main(void)
  1 {
  2     // initialize vendor sdk
  3     sdk_init();
  4     // init leds and button
  5     gpio_init();
  6     // init settings
  7     config_init();
  8     // Hook for custom boards initialisation
  9     board_bootloader_init();
 10 
 11     // check for invalid app image or rst button press. Should be checksum or CRC but NVIC validation is better than nothing.
 12     // If the interface has set the hold in bootloader setting don't jump to app
 13     if (!reset_button_pressed()
 14             && g_board_info.target_cfg
 15             && validate_bin_nvic((uint8_t *)g_board_info.target_cfg->flash_regions[0].start)
 16             && !config_ram_get_initial_hold_in_bl()) {
 17         // change to the new vector table
 18         SCB->VTOR = g_board_info.target_cfg->flash_regions[0].start; //bootloaders should only have one flash region for interface
 19         // modify stack pointer and start app
 20         modify_stack_pointer_and_start_app((*(uint32_t *)(g_board_info.target_cfg->flash_regions[0].start)),
 21                 (*(uint32_t *)(g_board_info.target_cfg->flash_regions[0].start + 4)));               
 22     }   

这是在main_interface.c文件里:

551 int main(void)
  1 {
  2     // Explicitly set the vector table since the bootloader might not set
  3     // it to what we expect.
  4 #if DAPLINK_ROM_BL_SIZE > 0
  5     SCB->VTOR = SCB_VTOR_TBLOFF_Msk & DAPLINK_ROM_IF_START;
  6 #endif  
  7     // initialize vendor sdk
  8     sdk_init();
  9     
 10     // Initialize CMSIS-RTOS
 11     osKernelInitialize();

这是boot里设置的中断向量表的实际地址,文件在stm32f103xb_bl.c:

37  // stm32f103 target information
  1 target_cfg_t target_device = {
  2     .version                    = kTargetConfigVersion,
  3     .sectors_info               = sectors_info,
  4     .sector_info_length         = (sizeof(sectors_info))/(sizeof(sector_info_t)),
  5     .flash_regions[0].start     = 0x08000000 + KB(48),
  6     .flash_regions[0].end       = 0x08000000 + KB(128),
  7     .flash_regions[0].flags     = kRegionIsDefault,
  8     .ram_regions[0].start       = 0x20000000,
  9     .ram_regions[0].end         = 0x20005000,
 10     /* .flash_algo not needed for bootloader */
 11 };

我看到的iap应用,都是只在app程序里设置SCB->VTOR,为何daplink源码里的boot程序这里,在跳转iap之前,为何也设置了SCB->VTOR?

离线

页脚

工信部备案:粤ICP备20025096号 Powered by FluxBB

感谢为中文互联网持续输出优质内容的各位老铁们。 QQ: 516333132, 微信(wechat): whycan_cn (哇酷网/挖坑网/填坑网) service@whycan.cn