How do I offset vector table jump addresses?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How do I offset vector table jump addresses?

ソリューションへジャンプ
2,568件の閲覧回数
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,775件の閲覧回数
jonathanscott
Contributor III

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

元の投稿で解決策を見る

0 件の賞賛
返信
5 返答(返信)
1,775件の閲覧回数
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,775件の閲覧回数
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,775件の閲覧回数
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,776件の閲覧回数
jonathanscott
Contributor III

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

0 件の賞賛
返信
1,775件の閲覧回数
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.