AnsweredAssumed Answered

How do I offset vector table jump addresses?

Question asked by Jonathan Scott on May 9, 2014
Latest reply on May 15, 2014 by Jonathan Scott


I am integrating the new Kinetis bootloader into my MK10DX128VMP5 project.  I have my main application included in the bootloader project as a binary file which is placed at 0x00008000, with lower addresses reserved for the bootloader.  The bootloader works fine, but when the main app is built, its vector table doesn't know that the application will ultimately start at at 0x00008000 instead of 0x00000000. So, a jump location within the table might be 0x00000123, but the actual target code is at 0x0008123.  The end result is that the bootloader jumps to the wrong place and none of my interrupts work.  How do I compensate for this offset when my main app is built?  Changing linker addresses just seems to offset everything in parallel, maintaining the offset.  There seems to be a lot of info about vector reallocation (which I'm not sure that I need), but not so much about vector redirection / offsetting.  The table location is ok, it's just the entries that need to be offset.  It's strange, because I had done something similar months ago with CW and didn't have this problem.  Now I'm using IAR.


I have to assume the solution is in the linker.  My linker looks like this.


define symbol m_interrupts_start       = 0x00008000;
define symbol m_interrupts_end         = 0x000083FF;

define symbol m_text_start             = 0x00008400;
define symbol m_text_end               = 0x0001FFFF;

define symbol m_data_start             = 0x1FFFE000;
define symbol m_data_end               = 0x1FFFFFFF;

define symbol m_data_2_start           = 0x20000000;
define symbol m_data_2_end             = 0x20001FFF;


define symbol __size_cstack__        = 0x0800;
define symbol __size_heap__          = 0x0000;


define memory mem with size = 4G;

define region ROM_region   = mem:[from m_interrupts_start to m_interrupts_end] | mem:[from m_text_start to m_text_end];

define region RAM_region   = mem:[from m_data_start to m_data_end];

define region m_data_2_region = mem:[from m_data_2_start to m_data_2_end];


define block CSTACK    with alignment = 8, size = __size_cstack__   { };
define block HEAP      with alignment = 8, size = __size_heap__     { };

define exported symbol __VECTOR_TABLE_START = m_interrupts_start;
define exported symbol __vect_table = m_interrupts_start;

define exported symbol __VECTOR_TABLE = 0x1fffe000;
define exported symbol __VECTOR_RAM = 0x1fffe000;

initialize by copy { readwrite };
do not initialize  { section .noinit };
place at address mem: m_interrupts_start { readonly section .intvec };
place in ROM_region   { readonly };
place in RAM_region { readwrite, block CSTACK, block HEAP };
place in m_data_2_region {section m_data_2};


Thank you in advance!