Freedom k64F Switching Between two applications bootloader code

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

Freedom k64F Switching Between two applications bootloader code

820 Views
aas_jav
Contributor I

Hello , i am new to K64F board, what i want to do is to have a bootloader code in my app which can write new app code in memory location and decides which app to execute based on the value in eprom. Basically i want to update my app code so i want to partition my ram into two parts running code will be on first part new coming code will be saved on another part and i want to shift program counter location based on the value stored in eprom either 1 or 0. 

Tags (1)
0 Kudos
3 Replies

618 Views
mjbcswitzerland
Specialist V

Hi Aashir

One potential method is to use the SWAP BLOCK functionality in the K64, which allows you to swap between two code bases (one in the lower half of memory and the other in the upper half of memory) - see
https://community.nxp.com/thread/445528
https://community.nxp.com/thread/439189

Also, the uTasker project contains the ability to have one code base but to chose a set of tasks to operate at run time (based on a DIP switch or parameter) as well as to swap between different such configurations during run time (option MULTISTART). Furthermore, it includes multiple boot loaders :[http://www.utasker.com/docs/uTasker/uTaskerSerialLoader.pdf / http://www.utasker.com/docs/uTasker/uTasker_BM_Loader.pdf] which can be used together to achieve many variations of such.

Most is available in the free open source version on Github or, for professional requirements, a supported version with advanced features is also available.


Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
Kinetis K64:
- http://www.utasker.com/kinetis/FRDM-K64F.html
- http://www.utasker.com/kinetis/TWR-K64F120M.html
- http://www.utasker.com/kinetis/TEENSY_3.5.html
- http://www.utasker.com/kinetis/Hexiwear-K64F.html

0 Kudos

618 Views
aas_jav
Contributor I

Hi Mark, Thanks for the guidance but the first link you gave is not available and i can't find a suitable example of swapping between flash memory in application for IAP. Basically my application will flash the code received over IP and then shift the control to new application burned and right now i cant find any direction to move forward? Do i need to work with PC and SP? 

0 Kudos

618 Views
mjbcswitzerland
Specialist V

Hi Aashir

I don't have any problems with the links - the first is to another forum entry - if the links don't work for you just do a search in the forum for "SWAP" and you will find these and possibly others.

If you check the uTasker open source project it includes an API that is simple to use.
fnSwapMemory(1); returns the present state of the SWAP blocks
    #define SWAP_STATE_UNINITIALISED       3
    #define SWAP_STATE_SWAPPED             2
    #define SWAP_STATE_USING_1             1
    #define SWAP_STATE_USING_0             0
    #define SWAP_COMMAND_FAILURE          -1
    #define SWAP_ERASE_FAILURE            -2

Once new code has been copied it is swapped using
fnSwapMemory(0);


At http://www.utasker.com/kinetis/FRDM-K64F.html you will find binaries that allow you to test this on a FRDM-K64F, as well as loading new code via USB, SD card or Web Browser.

If you are doing it for a school project you will find all that you need to experiment and learn in the open source version. Should you have a professional requirement it is all available as a supported turn-key solution that will avoid any project risks or delays.

Regards

Mark

P.S. No CPU register level coding is usually needed to do such things, although there is a routine called

extern void start_application(unsigned long app_link_location);
that is available in case one wants to jump to another application without going through a reset at the the usual reset vector location (which indeed sets PC and SP accordingly).

0 Kudos