Bootloader: problems with starting MQX app

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

Bootloader: problems with starting MQX app

Jump to solution
1,349 Views
dmitriym
Contributor II

Hello!

I want to update my mcu software with serial port. So i created a bootloader using processor expert for uploading S19 records to flash. For testing a bootloader i created a test program with processor expert. The bootloader with the test programm works fine, but now i have problem with starting my main MQX application. I prepared the MQX project, but my main application doesn't start:

1) set vector table of main application to be placed in RAM in user_config.h and builded BSP and PSP libraries:

#define MQX_ROM_VECTORS                           0

2) created new linker file:

shifted the adresses:

bootloader(RX): ORIGIN = 0x00000000, LENGTH = 0x00003000
boot_flags(RW): ORIGIN = 0x00003000, LENGTH = 0x00001000

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

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

rom (RX): ORIGIN = 0x00004420, LENGTH = 0x0004BBE0  /* Code + Const data */

my_rom (RW): ORIGIN = 0x00050000, LENGTH = 0x00030000  /* my data */

ram (RW): ORIGIN = 0x1FFF0000, LENGTH = 0x00020000  /* SRAM - RW data */

  

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

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

  

/* Boot stack reused by MQX Kernel data */

bstack      (RW): ORIGIN = 0x2000FA00, LENGTH = 0x00000200  /* Boot stack */

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

commented:

    /*.cfmprotect :

    {

        KEEP(*(.cfmconfig))

        . = ALIGN (0x8);

    } > cfmprotrom*/

So i don't understand what i missed. Can anybody help me?

0 Kudos
Reply
1 Solution
708 Views
dmitriym
Contributor II

The problem is solved.

Problem was in the stack pointer before initialization of MQX. Simmilar problem: Problem of initialization of MQX after jumping to the start of MQX application ( _boot() )

View solution in original post

0 Kudos
Reply
3 Replies
709 Views
dmitriym
Contributor II

The problem is solved.

Problem was in the stack pointer before initialization of MQX. Simmilar problem: Problem of initialization of MQX after jumping to the start of MQX application ( _boot() )

0 Kudos
Reply
708 Views
soledad
NXP Employee
NXP Employee

Hi,

By default, MQX allocates the vector table at the first address of the flash memory, 0x0000-0000. Because this region of flash memory is used by the your bootloader, 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.


Have a great day,
Regards
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply
708 Views
dmitriym
Contributor II

Hello,

I understand that reallocating vector table to the RAM is nessesary for MQX app to use it with bootloader. To allocate vector table in RAM we need to set in user_config.h:

#define MQX_ROM_VECTORS     0 

I've already done it and rebuild BSP and PSP libraries. And vector table is in the RAM. The MQX application starts and works normal with the vector table in RAM, when i try to debug it without bootloader (with linker file without shifting memory sections). But this MQX application is not working when I use it with bootloader (with modified linker file that i have already posted). When i try to debug it with bootloader i jump to the correct addres in memory where __boot(); of MQX app exists. Start to execute programm, but then somewhere the MQX programm stops.

I tried to jump to __boot(); while debugging only MQX app without bootloader, and it starts normaly, but in main() while starting MQX in function _mqx( (MQX_INITIALIZATION_STRUCT_PTR) &MQX_init_struct ); crashes function _mem_zero((pointer) kernel_data, (_mem_size) sizeof(KERNEL_DATA_STRUCT));. And i don't understand why

I think that with bootloader the MQX app crashes in the same place.

And as have already said the test app created with processor expert without MQX starts and runs normaly.

0 Kudos
Reply