How do I offset vector table jump addresses?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How do I offset vector table jump addresses?

跳至解决方案
2,753 次查看
jonathanscott
Contributor III

Hello,

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;

/*-Sizes-*/
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!

标签 (1)
0 项奖励
回复
1 解答
1,960 次查看
jonathanscott
Contributor III

Solved.  PRIMASK was set in the bootloader and never cleared.

在原帖中查看解决方案

0 项奖励
回复
5 回复数
1,960 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hello,

I would recommend customer to refer AN4368 chapter 5 Developing new user applications about how to modify linker file and redirect vector table.

More detailed info, please check below link:

http://cache.freescale.com/files/microcontrollers/doc/app_note/AN4368.pdf


Wish it help.

best regards,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

1,960 次查看
jonathanscott
Contributor III

Thank you, Ma, although the examples in that AN weren't very useful using IAR.  Regardless, I now have the bootloader jumping to the correct location.  The problem, though, is that my application interrupts don't seem to work.  To demonstrate, I generated a test application project using the same bootloader project (both attached).  The application contains a timer "TIMER1", which expires after 250ms, setting the FTM0_TOF bit.  Despite TOIE and TOF being set, though, the code never jumps to the ISR, which is properly listed in the vector table.  Can you figure out why?  It's driving me crazy!

IAR_TEST is the top-level workspace and application project.

K10_Bootloader is the bootloader project.

The extra "src" file is located where it is because the compiler couldn't find the files after I copied the project and changing the include paths didn't fix it(sorry).

Thank you,

Jonathan

0 项奖励
回复
1,960 次查看
Hui_Ma
NXP TechSupport
NXP TechSupport

Hello,

Please check attached project, which is using TimerInt_LDD component based on FRDM-K20D50M board with CodeWarrior for MCU V10.6. It will generate timer interrupt every 250ms.
Wish it help.

best regards,
Ma Hui

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
1,961 次查看
jonathanscott
Contributor III

Solved.  PRIMASK was set in the bootloader and never cleared.

0 项奖励
回复
1,960 次查看
Wlodek_D_
Senior Contributor II

Hello,

Thank you for your post, however please consider moving it to the right community place (e.g. Kinetis Microcontrollers ) to get it visible for active members.

For details please see general advice Where to post a Discussion?

Thank you for using Freescale Community.