Bootloader mqx k64f

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

Bootloader mqx k64f

1,943 Views
emanueletrapani
Contributor III

hi, i use frdmk64f with cw 10.6, mqx 4.1.

i want to do a bootloader using mqx OS. my question is: before i jump from the bootloader to the application how can i deinitialize (or close) mqx (or other peripheral automaticallhy started)?

i use the same code for application and the bootloader: the example gpio modified. the different is:

application: started from address 0x000C0000, use vector_ram, and blinking led1

bootloader: started from address 0x00000000, use vector_rom, blinking led2 and do the jump.

jump function:

extern void preparation_application(void) 

    SCB_VTOR = 0x1fff0000;

    asm volatile("cpsid i");

    _int_disable();//i dont know which is better to use for interrupt disabling

}

extern void start_application(unsigned long app_link_location) 

    asm(" ldr sp, [r0,#0]"); // load the stack pointer value from the program's reset vector 

    asm("mov lr, #0xffffffff");//asm("mov sp, r0");

    asm(" ldr pc, [r0,#4]");// load the program counter value from the program's reset vector to cause operation to continue from there

}

i know that i set the linker file for the application correctly because if i build a simple file with only the istruction for the jump i can se that the application run well.

the problem is when i run the bootloader code. in debug mode i can see that the jump is done correctly. load the sp and the pc from the correct location. but at certain point the code come back to the bootloader and run in this infinite loop.

so i think that i don't do correctly the deinitialization of the bootloader before the jump.

i try to use the function _mqx_exit(0) but somethings go wrong and it do not come back at the main application that call _mqx().

thank you

5 Replies

1,341 Views
emanueletrapani
Contributor III

ok, i found the problem. the application try to disable the hardware watchdog for the second time and then restart. the first time the bootloader disabled it. so i commented that function in the init hardware bsp file of the application.

therefore the application stop in another initialization routine. i seen in debug mode that, after the jump, MSP has a wrong valour. i solved it adding these lines to the function:

extern void preparation_application(void) 

    SCB_VTOR = 0x1fff0000;

    asm("mov r0, #0xfc00");

    asm("movt r0, #0x2002");

    _int_disable();

    asm(" msr MSP, r0");

}

now it runs well

1,341 Views
aureliengrange
Contributor II

Hi,

I find this post very interesting.

Do you know if it is possible to use the same part of code for the bootloader and for the application about RCTS stack(FTP server,...)?

It will be nice to use MQX & RCTS as bootloader but the space needed is important => using only one rcts stack for bootloader and application can save space...

0 Kudos
Reply

1,341 Views
emanueletrapani
Contributor III

i have not idea.

0 Kudos
Reply

1,341 Views
soledad
NXP Employee
NXP Employee

Hello Emanuele,

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

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.

In addition please check the below threads

A bootloader via MQX RTCS

MQX Bootloader

Please let me know if this helps!!


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

0 Kudos
Reply

1,341 Views
emanueletrapani
Contributor III

thank you soledad for the answer.

i read this appnote but it explanes just how to set the linker file to write the app in the correct part of the flash and the vector_ram setting.

i found on the web the latest version of the FNET and try to port it in an example application for cwc10.6 frdmk64f. but i could not, i hoped to found an example application that it integrates the FNET system but i don't found it.

so i try to use an example application of mqx and try to do, inside it, a jump to the application i wrote in the middle of the flash. but i think i had problem with mqx deinitialization of the bootloader.

used somebody mqx for a bootloader?

0 Kudos
Reply