How to put vectors in ram with processor expert?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to put vectors in ram with processor expert?

Jump to solution
1,804 Views
robotjosh
Contributor IV

Processor expert has linker options in cpu build options.  There is a dropdown that lets you specify default interrupt locations in internal flash, external flash, internal ram or external ram.  The internal flash option is default and works correctly.  If you change that dropdown from internal flash to internal ram, it changes the m_interrupts section to start at 0x1fff0000.  I have to setup the debugger to jump to 0x410 to start, but it breaks after the first pop because the stack pointer is not correctly setup.  Am I doing something wrong or could this be a bug?

Tags (2)
1 Solution
443 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Josh Jordan:

The bug found by colleague Marek was resolved, but your issue is different. The "Default memory for interrupts" is for debugging purposes only, but it is not the correct way to place vectors in RAM, so leave it as INTERNAL FLASH.

There is a bug in the MQXLite component which does not allow to install vectors in RAM by default. It was already reported (ticket PEXMCU-255, fix on progress).

My suggested workaround:

1- Disable linker file generation from CPU component -> Build options -> Generate linker file:

pastedImage_5.png

2- Open the linker file (ProcessorExpert.ld) and reserve space in RAM by creating a new segment (e.g. "m_interrupts_ram").

3- Rest the size of reserved space from "m_data" segment.

4- Edit the ".interrupts" section declaration as next:

  __vector_table_FLASH = ORIGIN(m_interrupts);

  .interrupts : AT(__vector_table_FLASH)

  {

    __vector_table = .;

    . = ALIGN(4);

    KEEP(*(.vectortable))

    . = ALIGN(4);

  } > m_interrupts_ram    /* <- Allocate vector table in new RAM segment */

  vector_table_size = SIZEOF(.interrupts);

5- Add 3 new values to the ".romp" section. This will trigger the vector table copy from Flash to RAM during startup.

  .romp : AT(_romp_at)

  {

    __S_romp = _romp_at;

    LONG(__vector_table_FLASH)

    LONG(__vector_table)

    LONG(vector_table_size)

    ...

6- From MQXLite component go to Configuration parameters -> User settings -> Definitions. Set the MQX_ROM_VECTORS macro as below:

pastedImage_1.png

Attached is a KDS v3.0.0 project for K22FN512 with these changes, for your reference.

I hope this helps.


Regards!,
Jorge Gonzalez

View solution in original post

0 Kudos
11 Replies
443 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

I am not able to reproduce the problem. Could you provide me more details about you project, please? I need to know the PEx product and version (e.g. CW MCU 10.6, PExDrv 10.4.2, KDS 2.0.0), the CPU name and compiler.

Best Regards,

Marek Neuzil

0 Kudos
443 Views
robotjosh
Contributor IV

This is in KDS 1.1.1, PEX 1.1.1.RT6_b1433-0202, cpu is MK22FN512VLH12.  This is with processor expert enabled and kinetis sdk disabled.

0 Kudos
443 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

Finally, I have been able to reproduce the problem - the RAM generator configation of an MK22FN512VLH12 Processor Expert project (in Processor Expert project without SDK) does not work in KDS 2.0.0 with ARM GCC compiler (Segger J-link and P&E universal multilink have been used). I have reported the issue to the responsible development team.

Thank you for reporting of this issue.

Best Regards,

Marek Neuzil

0 Kudos
443 Views
robotjosh
Contributor IV

Any progress on this?

0 Kudos
443 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

The problem has been fixed in the upcoming release of KDS 3.0.0 (it will be published in a few days). There were a bug in the startup file of the application, see the change of stack pointer initialization.

pastedImage_0.png

Best Regards,

Marek Neuzil

443 Views
robotjosh
Contributor IV

This doesn't work.  I installed kds 3, created a project with processor expert and mqxlite, and put vectors in ram.  It runs from the debugger but without the debugger it goes into a reset loop.  This project requires that it run without the debugger attached.

I'm trying to modify the linker script to work, noticed there is no ENTRY statement.  I added the ENTRY statement but it appears codewarrior doesn't support that.  How do you specify the entry point in code warrior linker script?  I can't find any documents on how codewarrior linker scripting works.

0 Kudos
443 Views
marek_neuzil
NXP Employee
NXP Employee

Hello,

When you use the MQXLite component in the project the interrupt vectors are controlled by the the MQXLite driver. See the MQXLite help - interrupt properties and methods that are provided. In this case set the "Default memory for interrupts" property to INTERNAL FLASH.

For example, when you add an AsynchroSerial component into the project (UART0 is allocated) and enable interrupts, the UART0 interrupts are installed by the following code in the Init method:

  /* Allocate interrupt vectors */

  /* {MQXLite RTOS Adapter} Save old and set new interrupt vector (function handler and ISR parameter) */

  /* Note: Exception handler for interrupt is not saved, because it is not modified */

  DeviceDataPrv->SavedISRSettings.isrData = _int_get_isr_data(LDD_ivIndex_INT_UART0_RX_TX);

  DeviceDataPrv->SavedISRSettings.isrFunction = _int_install_isr(LDD_ivIndex_INT_UART0_RX_TX, ASerialLdd1_Interrupt, DeviceDataPrv);

  /* {MQXLite RTOS Adapter} Save old and set new interrupt vector (function handler and ISR parameter) */

  /* Note: Exception handler for interrupt is not saved, because it is not modified */

  DeviceDataPrv->SavedISRSettings.isrData = _int_get_isr_data(LDD_ivIndex_INT_UART0_ERR);

  DeviceDataPrv->SavedISRSettings.isrFunction = _int_install_isr(LDD_ivIndex_INT_UART0_ERR, ASerialLdd1_Interrupt, DeviceDataPrv);

Best Regards,

Marek Neuzil

0 Kudos
443 Views
robotjosh
Contributor IV

Thanks for the explanation.  I am still having the issue where using mqxlite with vectors in ram causes a reset loop unless the debugger is attached.  This must be able to run in the field without a debugger attached because we cannot ask clients to attach a debugger in the field just so the product can boot up.  Using KDS 3.0 still goes into a reset loop without a debugger attached.  Please advise how to use mqxlite with vectors in ram without a debugger attached.

0 Kudos
444 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Josh Jordan:

The bug found by colleague Marek was resolved, but your issue is different. The "Default memory for interrupts" is for debugging purposes only, but it is not the correct way to place vectors in RAM, so leave it as INTERNAL FLASH.

There is a bug in the MQXLite component which does not allow to install vectors in RAM by default. It was already reported (ticket PEXMCU-255, fix on progress).

My suggested workaround:

1- Disable linker file generation from CPU component -> Build options -> Generate linker file:

pastedImage_5.png

2- Open the linker file (ProcessorExpert.ld) and reserve space in RAM by creating a new segment (e.g. "m_interrupts_ram").

3- Rest the size of reserved space from "m_data" segment.

4- Edit the ".interrupts" section declaration as next:

  __vector_table_FLASH = ORIGIN(m_interrupts);

  .interrupts : AT(__vector_table_FLASH)

  {

    __vector_table = .;

    . = ALIGN(4);

    KEEP(*(.vectortable))

    . = ALIGN(4);

  } > m_interrupts_ram    /* <- Allocate vector table in new RAM segment */

  vector_table_size = SIZEOF(.interrupts);

5- Add 3 new values to the ".romp" section. This will trigger the vector table copy from Flash to RAM during startup.

  .romp : AT(_romp_at)

  {

    __S_romp = _romp_at;

    LONG(__vector_table_FLASH)

    LONG(__vector_table)

    LONG(vector_table_size)

    ...

6- From MQXLite component go to Configuration parameters -> User settings -> Definitions. Set the MQX_ROM_VECTORS macro as below:

pastedImage_1.png

Attached is a KDS v3.0.0 project for K22FN512 with these changes, for your reference.

I hope this helps.


Regards!,
Jorge Gonzalez

View solution in original post

0 Kudos
443 Views
robotjosh
Contributor IV

I was able to port solution to the K60F on codewarrior and it worked.

443 Views
robotjosh
Contributor IV

Thanks for fixing this eventually!  I'll mark it correct when I get back to this issue and observe it work.

0 Kudos