MQX stucks in hard fault during the execution of SVC only when bootloader comes in picture

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

MQX stucks in hard fault during the execution of SVC only when bootloader comes in picture

Jump to solution
959 Views
pravinfalcao
Contributor II

I am working on a project where MQX is playing key role. My application works perfect when I flash the code through debugger but when bootloader comes in picture, here is the main issue. I have observed that MQX works perfectly till the function call '_sched_start_internal();'. As soon as it executes the instruction "svc SVC_RUN_SCHED", instead of jumping to SVC handler, it enters in HARD FAULT and DEFAULT_VECTOR is executed. Did anyone face this problem? Can someone help me to come out of this issue?

This issue is exactly same as listed Issues running MQX in DDR on K70 but i think solution is not mentioned.

Thanks,

Pravin

Tags (1)
0 Kudos
1 Solution
553 Views
pravinfalcao
Contributor II

Hi,

I found the solution. This is because of SVC priority. If interrupts are disabled then this problem will occur however if interrupts are enabled, then we will not face this problem.

Thanks!!!

Pravin

View solution in original post

0 Kudos
4 Replies
553 Views
soledad
NXP Employee
NXP Employee

Hi Pravin,

By default, MQX allocates the vector table at the first address of the flash memory, 0x0000-0000. Because probably this region of flash memory is used by your  bootloader,so it will be necessary to reallocate the vector table in a RAM section.

I want to believe that this appnote can be a guideline for your application:

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

This appnote describes how to add the FNET bootloader to Kinetis projects. There is a section that includes adding it to the MQX linker which is the section that I believe you will find useful.

I hope this helps;

Have a great day,
Sol

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

0 Kudos
553 Views
pravinfalcao
Contributor II

Hi Sol,

Thanks but we are storing machine code in serial flash and running from DDR2. Moreover vector is already located at 0x1FFF0000.  Please find the below memory arrangement in linker file.

    vectorrom   (RX): ORIGIN = 0x1FFF0000, LENGTH = 0x00000410

   /* cfmprotrom  (R) : ORIGIN = 0x1FFF0410, LENGTH = 0x00000020*/

    rom         (RX): ORIGIN = 0x08000510, LENGTH = 0x0002FAEF

    ram         (RW): ORIGIN = 0x20000000, LENGTH = 0x0000AFFF

     sram        (RW): ORIGIN = 0x1FFF0430, LENGTH = 0x0000FBCF

    /* kernel space starts after RAM variables (Location of MQX Kernel data + MQX heap) */

    end_of_kd   (RW): ORIGIN = 0x20009FF0, LENGTH = 0x00000000

    /* Boot stack reused by MQX Kernel data */

    bstack      (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200

    end_bstack  (RW): ORIGIN = 0x2000FC00, LENGTH = 0x00000000 

  /*  bstack      (RW): ORIGIN = 0x0A80FA00, LENGTH = 0x00000200

    end_bstack  (RW): ORIGIN = 0x0A80FC00, LENGTH = 0x00000000 */ /* Boot stack end address requires 4B alignment */

0 Kudos
554 Views
pravinfalcao
Contributor II

Hi,

I found the solution. This is because of SVC priority. If interrupts are disabled then this problem will occur however if interrupts are enabled, then we will not face this problem.

Thanks!!!

Pravin

0 Kudos
553 Views
soledad
NXP Employee
NXP Employee

Thank you for sharing your solution!!!

Regards

Soledad

0 Kudos