RAM vector table? K60 and MQX 4.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

RAM vector table? K60 and MQX 4.0

Jump to solution
1,566 Views
gavroche123
Contributor II

I seem to have permanently bricked the K60 trying to get this to work, so I'm not in the happiest frame of mind right now...


I am not using a bootloader but was trying to follow the app notes AN4379 / 4368as well as other postings here in order to use a RAM vector table so I could use the kernel level ISRs.


I rebuilt the libs with the

#define MQX_ROM_VECTORS    0

in the icf I have the line:-

place at address mem:__ICFEDIT_region_RAM_start__ { readwrite section .vectors_ram };

However, my app fell over as soon as the scheduler started, presumably as a result of the vector table not actaully being present in RAM (looking at the map file, there was no evidence  of it being put at the start of RAM).

The porblem being that the icf examples posted bear little resemblance to the example ones

Can someone please elaborate on how to configure MQX to use the RAM vector table ?

1 Solution
666 Views
gavroche123
Contributor II

Thanks. Looking at the difference between your map file and mine, I could see that I had no A2 section. This led me to think that something had gone wrong with my library build.

Indeed it had - I had not built all of the components (Build All is not what it appears) so there was a stale component. Batch building has fixed it and I'm now running my kernel ISR!

View solution in original post

0 Kudos
6 Replies
666 Views
gavroche123
Contributor II

Yes, I am using the linker file you mention, with the web hvac app. It all works fine.

The problem is that i need to use kernel ints. So I recompiled MQX with the #define to use RAM vectors.

My understanding is that this still places the vector table in Flash at 0x0, but also sets the VTOR pointer to the start of RAM, where it expects to find a copy of said table?

But in my case there is no copy there. So there first int that gets called when the scheduler starts blasts off into hyperspace.

So - what is responsible for making that copy ? There is a line in the icf file :

place at address mem:__ICFEDIT_region_RAM_start__ { readwrite section .vectors_ram };

But is this it? Or is there some other setting I'm missing? An example would be useful, thanks.

0 Kudos
666 Views
Martin_
NXP Employee
NXP Employee

After build with IAR 6.50, hello2 example, MQX 4.0.1 libs build with MQX_ROM_VECTORS 0 I can see in my .map file:

"A2":                                           0x400

  rw section .vectors_ram-1

                                   0x1fff0000   0x400  <Init block>

    .vectors_ram          inited   0x1fff0000   0x400  vectors.o [3]

                                 - 0x1fff0400   0x400

and

ram_vector              0x1fff0000  0x400  Data  Gb  vectors.o [3]

Now, I was a bit wrong with IAR, I double check on hardware the startup process. The IAR library makes a copy of vectors to fill 0x1FFF0000--0x1FFF003F. Only 16 vectors from the vector table in ROM. The rest is left untouched by IAR startup code. Then, I can see the actual writes to vector table in RAM is done in _psp_int_install() MQX function. The callstack looks like this:

psp_int_install_callstack.JPG

and after _psp_int_install() executes, the vector table at 0x1FFF0040 is filled with addresses of _int_kernel_isr(). So, in conclusion, it seems that with IAR, only 16 vectors are actually copied from ROM to RAM. Remaining vectors are just filled with _int_kernel_isr(). Thus, you need to call _int_install_kernel_isr() for all your custom kernel interrupt routines with vector numbers >= 16.

667 Views
gavroche123
Contributor II

Thanks. Looking at the difference between your map file and mine, I could see that I had no A2 section. This led me to think that something had gone wrong with my library build.

Indeed it had - I had not built all of the components (Build All is not what it appears) so there was a stale component. Batch building has fixed it and I'm now running my kernel ISR!

0 Kudos
666 Views
Martin_
NXP Employee
NXP Employee

TWR-K60F120M

MQX 4.0 (also MQX 4.0.1)

IAR 6.50

user configuration of twrk60f120m user_config.h:

#define MQX_ROM_VECTORS 0

#define BSPCFG_ENABLE_ITTYF 1

#define BSP_DEFAULT_IO_CHANNEL "ittyf:"

Build MQX libraries. Then build /mqx/examples/hello2 application for internal flash Debug target. Load hello2 executable to MCU and run.

I break in idle task, in debugger I can see Cortex-M4 VTOR = 0x1FFF0000. At address 0x1FFF0000 I can see vector table, most of vectors point to _int_kernel_isr().

In general with the supported toolchain, all need is to build BSP and PSP with #define MQX_ROM_VECTORS 0.

0 Kudos
666 Views
gavroche123
Contributor II

At 0x1FFF0000 I get my variables (as per my map file), no vectors. My VTOR is pointing there!

The question is - how do i get the linker to put the table at 0x1fff000? I tried another icf file and it basically bricked the board.

From following some postings I've found here the icf files do not bear much resemblance to   the demo ones.

Thanks

0 Kudos
666 Views
Martin_
NXP Employee
NXP Employee

Typically you don't put vector table directly to RAM for internal flash targets. The vector table is located physically in internal flash in non-volatile memory and the startup code makes a copy from flash to RAM. Usually this is toolchain dependent, for example in CodeWarrior the startup code takes some symbols defined in the linker command file and makes the copy from source to destination. You should study documentation for your compiler and linker and see how it makes ROM to RAM copy at startup.

To start, I would recommend linking your application with the MQX delivered linker command file, for example for TWR-K60F120M debug target this one:

  ${MQX_ROOT_DIR}\lib\twrk60f120m.iar\debug\bsp\intflash.icf

Are you using this linker file to link your application ? Is this working with standard example ?

0 Kudos