A Porting For AN4370SW

Document created by Kan_Li Employee on May 5, 2013Last modified by Kan_Li Employee on Jun 4, 2013
Version 1Show Document
  • View in full screen mode


Recently I did a porting based on AN4370SW for a customer to support TWR-K20D72M, and with some modification in source code, header file and link file as well, it works well as expected. The following simple describes what I have done:

1.Copy the project file folder for K20D50M "AN4370SW\Source\Device\app\dfu_bootloader\iar_ew\kinetis_k20" and rename is as "kinetis_k20d70m"

a1.JPG

2.Change the target settings as well as the flash loader.

a1.JPG

a1.JPG

3. Replace the header file for K20D50M and include it in derivative.h. The header file for K20D72M can be found from KINETIS_72MHz_SRC(http://cache.freescale.com/files/32bit/software/KINETIS_72MHz_SRC.zip?fpsp=1&WT_TYPE=Lab%20and%20Test%20Software&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=zip&WT_ASSET=Downloads&sr=9)

 

4.Modify the interrupt table in cstartup_M.s, which is more likely a K60's vertor table.

 

5.Search the code related with the macro "MCU_MK20D5", and add similar code snippet for K20D72M , You may easily find them by search the keyword "MCU_MK20D7". That code parts include initialization for MCG, and PIT0 and USB interrupt enablements, some definition in bootloader.h .

 

6. Copy the link file from K20D50M, and modify the PFLASH size,SRAM size and DFLASH size as shown below:

a1.JPG

 

Perform MassErase before programming . and then you may press the SW1 on TWR-K20D72M to select which mode to enter after download the application firmware: pressing SW1 to enter bootloader mode and releasing it to enter application mode.

 

a1.JPG

7. Build image for this DFU bootloader.

Actually the bareboard projects in KINETIS_72MHz_SRC can be used for that purpose, and only link file needs some modification to put the image starting from 0xA000, since exception table redirection has already been done in these projects.

3.JPG

after that, user needs change some settings in the CW projects to use the new link file:

1.JPG

and generate S19 file as the output as well as the map file:

2.JPG

after compiling , you will have a xxx.afx.s19 file, but that is not the final format, we still need to transform it to bin format, and it can be done by a small tool in "C:\Program Files\Freescale\CW MCU v10.3\MCU\prog"

7.JPG

There are some settings for this tool to transform the S19 file, by clicking Burner->Burner Dialog, you will see some option views, please set them as below:

4.JPG

6.JPG

Referring to the above figure, maybe you would wonder how to set up the Origin and Length field, actually Origin is the value where the image starts from just as the link file specified , and Length is calculated by the results from the map file. Please refer to the following figure for details.

5.JPG

0x3550 = 0x1c90 + 0x18c0.

 

I also attached the burner's configuration file and image link file as well as the image for reference. Please copy the link file in "KINETIS_72MHz_SRC\build\cw\linker_files".

 

Please kindly refer to the attachment for more details.

 

Hope that helps,

 

B.R

Kan

Outcomes