简体   繁体   English

硬重置后,Atmel SAM3X8E丢失VTOR

[英]Atmel SAM3X8E Loses VTOR After Hard Reset

I seem to be reiterating this question from here and here . 我似乎从这里这里都在重申这个问题。 When I reboot my system after flashing firmware onto an opposing flash bank, the VTOR is 0 (meaning it does not boot from flash) and I cannot run the new firmware. 将固件刷新到相对的闪存组后重新启动系统时,VTOR为0(表示它不从闪存启动),并且我无法运行新固件。

I use the EFC controller to program the firmware binary into the second flash bank. 我使用EFC控制器将固件二进制文件编程到第二个Flash Bank中。 For example, the active firmware is at Flash0, located at 0x0008_0000. 例如,活动固件在Flash0上,位于0x0008_0000。 The implementation guide says that Flash1 is located at 0x000C_0000. 实施指南说Flash1位于0x000C_0000。 I can see the complete firmware to be flashed is contained, without errors, at 0x000C_0000. 我可以看到包含要刷新的完整固件,没有错误,位于0x000C_0000。 Once the firmware is loaded and verified, I switch the GPNVM boot bank: 加载并验证固件后,我将切换GPNVM启动库:

efc_perform_command(EFC0, EFC_FCMD_SGPB, 1); //set GPNVM bit 1
efc_perform_command(EFC0, EFC_FCMD_SGPB, 2); //set GPNVM bit 2
/* Now check to make sure the bit has flipped) */
efc_perform_command(EFC0, EFC_FCMD_GGPB, 0);
status = efc_get_result(EFC0);
printf("GPNVM is now %d\n", status);

/* Now set the VTOR to the flash1 start address) */
__DSB();
__ISB();
SCB->VTOR = ((uint32_t)FLASH1_ADDRESS & SCB_VTOR_TBLOFF_Msk);
/* Checking the VTOR value here shows a result of 0x000C_0000 */
__DSB();
__ISB();

/* Now reset the device by pulling NRSTB pin low */
reset_pull_NRSTB_low();
while(1); 

After executing this code, I again check the VTOR register at 0xE000_ED08 and the value is now 0x0000_0000. 执行此代码后,我再次检查VTOR寄存器0xE000_ED08,现在的值为0x0000_0000。 The firmware does not appear to load as the chip looks to address 0x0000_0000 to start the firmware. 固件似乎未加载,因为芯片的地址为0x0000_0000以启动固件。

Could it be that I have improperly set the GPNVM bits and it is looking for ROM vectors? 可能是我没有正确设置GPNVM位并且正在寻找ROM向量吗? If that is the case, what are the proper GPNVM bits to set? 如果是这种情况,应设置哪些正确的GPNVM位? According to the table on page 33 of the bootloader document, the GPNVM bits should be "0b110" so that GPNVM[1] is 1 and GPNVM[2] is 1 - meaning that the firmware will start from Flash Bank 1. Is this a correct interpretation? 根据引导加载程序文档第33页上的表,GPNVM位应为“ 0b110”,以便GPNVM [1]为1且GPNVM [2]为1-意味着固件将从Flash Bank 1开始。正确的解释?

Ok, of course I knew that finding the solution would make me feel stupid. 好的,我当然知道找到解决方案会让我感到愚蠢。 But here you go... I ultimately changed the linker script in the Device_Startup folder as provided by Atmel and compiled it twice; 但是,您可以执行以下操作……我最终更改了Atmel提供的Device_Startup文件夹中的链接描述文件,并对其进行了两次编译。 each with the FLASH0 and FLASH1 addresses respectively in place, with no other changes to the firmware. 每个都分别具有FLASH0和FLASH1地址,而固件没有其他更改。 And...the firmware binaries were identical! 而且...固件二进制文件是相同的! But that shouldn't be the case according to Atmel. 但是Atmel认为情况并非如此。

I had been confused because it says that the memories are mirrored, which led me to believe that setting the GPNVM only pointed to the start of the flash bank at the same address and remapped the latter half based on GPNVM2. 我一直感到困惑,因为它说内存是镜像的,这使我相信设置GPNVM仅指向闪存库的起始地址是相同的地址,并根据GPNVM2重新映射后半部分。 Instead, it seems as if it actually loads the vector table from the second word of the firmware binary (SP and then PC). 相反,似乎它实际上是从固件二进制文件的第二个字(SP,然后是PC)加载向量表的。

So it does need to be told where to jump inside the contiguous flash bank. 因此,确实需要告知要在连续的闪存组中跳转的位置。 I went into the ASF solution properties to find the ARM/GNU Linker preferences and found the real linker file in the tag section. 我进入ASF解决方案属性以查找ARM / GNU链接器首选项,并在标签部分中找到了真正的链接器文件。 It is not the one that seems to be referenced in my project. 在我的项目中似乎没有引用过它。 I changed it based on the guidelines I mentioned above and it switched over successfully to run the firmware on the opposite bank. 我根据上面提到的指南对其进行了更改,并成功切换到对面的存储库以运行固件。

Easy solution to a seemingly obscure hardware problem. 轻松解决看似晦涩的硬件问题。 Thanks for your help! 谢谢你的帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM