Porting AN4368 to K70

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Porting AN4368 to K70

跳至解决方案
1,750 次查看
mrupp_viatechno
Contributor III

I am attempting to create a bootloader, for a K70, using the ideas in AN4368.  My problem is with the flash driver supplied.  In particular the routine 'Flash_ByteProgram".  It is returning a 'Flash access error'.  In flash_FTFL.h the flash write command is defined as 0x06 using '#define FlashCmd_ProgramLongWord    0x06'.  However looking at the K70 reference manual there is no 0x06 command.  See section 30.4.10.2.  There is a 'Program Phrase' command that writes eight bytes.  Is the flash driver supplied with AN4368 incorrect?  Is a corrected one available?

 

I have attached both flash_FTFL.c and flash_FTFL.h that were supplied with AN4368.

 

1 解答
1,155 次查看
PaoloRenzo
Contributor V

Look at AN4370SW. It includes functional routines for K70 flash configuration

 

Hope this helps

 

在原帖中查看解决方案

5 回复数
1,155 次查看
squadmcu
NXP Employee
NXP Employee

The Documentation for Kinetis K70 (Graphic LCD 120/150 MHz MCUs) can be found at "K70_120 Product Summary Page", Freescale folks are constantly uploading new resources (like ANs) to help you all.

Definitely, that page deserves a bookmark


0 项奖励
回复
1,156 次查看
PaoloRenzo
Contributor V

Look at AN4370SW. It includes functional routines for K70 flash configuration

 

Hope this helps

 

1,155 次查看
mrupp_viatechno
Contributor III

The code in AN4370SW uses the correct Flash command (0x07) but it still has bugs.  It only works when the number of data bytes in the S record is an integral number of 'phrases'.  The default in CodeWarrior 10.2 does not have this.  I needed to change the projects ARM Linker Output so that the 'Max S-Record Length' is 84.  It defaults to 80 which results in 9.5 phrases per S record.  Also, the address in the S record must be on an 8-byte boundary (not four as tested in the program). 

 

Changing the 'Max S-Record Length' to 84 created a file where each record had an integral number of 'phrases' and the address was on 8-byte boundaries.  Programming the flash then worked.

 

However, I am worried about the future.  Specified the 'Max S-Record Length' as 84; but did not specify a minimum. What's to stop CW 10.3 from using 80 regardless of the Max setting.  Also I did not see any way to tell the linker to create S records that have addresses on 8-byte boundaries.  But this is a problem for another day. 

 

Thanks for your help.

 

 

 

 

0 项奖励
回复
1,155 次查看
mjbcswitzerland
Specialist V

Hi

 

I can't help with the application note code but older code's FLASH driver can be adapted to the devices with FPU by respecting the following points:

- the FLASH granularity (smallest block that can be erased) is 4k rather than 2k

- writes to flash have to be done in 'phrases' of 8 bytes rather than as long words

 

The driver changes are quite easy but there can be a bigger impact on the higher layers which may neen adaptation to work with the larger write/erase size restrictions.

 

 

However not only the Flash is different - the PLL setup needs to be calculated differently since the PLL works internally twices as fast.

If using the DMA controller this is a little different (it has groups that need to be set up correctly to avoid conflicts).

The USB source clock set up is a little different.

 

Therefore you may find that the application note in question requires a more thorough K70 target configuration review before it is completely operation.

 

Regards

 

Mark

 

P,S. I have K70 loaders for UART (S-rec), USB CDC device, USB-MSD device, SD card and Ethernet (FTP, TFT or Web server) but unfortunately not for a USB-stick....

 

0 项奖励
回复
1,155 次查看
mrupp_viatechno
Contributor III

I am using MQX which handles the PLL and DMA.

0 项奖励
回复