Friday, 16 May 2014

Vector table relocation in bootloader application


I've written a bootloader application for NXP Kinetis microcontroller. Following are the things I did to do the same: 1. Created a bootloader application in CFlash addresses 0x0000 to 0x8000 2. Created my main application code from addresses 0x8000 to 0x1FFFF



This code is working fine. Now my doubt is, I have ISRs placed in both bootloader as well as main application code and didn't use any ISR vector relocation. Is it necessary to relocate the vector tables in main application?


PS: I may not be facing the issue just because the ISRs in both the apps are same.



Answer



You do not need to relocate the vector table--the toolchain should correctly locate your vector table in your binary--but you do need to tell the MCU where the correct vector table is located, as well as where the stack pointer should start, when you jump from bootloader to application. By default, on ARM cores, the vector table is found at the very beginning of your application binary. The first entry will be the initial stack pointer, and the second entry will be the reset vector (the application entry point). The rest of the entries are defined by the specific ARM architecture as well as the specific implementation.


At startup or a hardware reset, the hardware will initialize the Vector Table Offset Register to 0x00000000, set the stack pointer to the first value in the vector table, and then jump to the location given in the second entry in the table. But when you jump from a bootloader to the application, you have to do each of those things yourself.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...