Flash writing problem, content updates not until reset

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

Flash writing problem, content updates not until reset

Jump to solution
978 Views
lasseh
Contributor I

Hi,

I am trying to write K60 flash (program flash only, two 512KB blocks, no FlexNVM) using "Standard Software Flash Driver For FTFx" driver by Freescale. Flash clock is 25MHz. The executed program code is in the lower flash block (0-512KB) while my erase and write test are targeting the upper half. I have understood this is a valid situation.

Erase works, and write function does not report errors. But after phrase write commands, for example 256 bytes, when I am reading data back with memcpy, some phrases read back correctly but some seem to be still in erased condition showing 0xff. Reading memory using JTAG shows usually pretty much same result (seems like states of some phrases may be different). However, when I reset Kinetis and my IDE re-reads flash content of Kinetis, written data reads back correct!

Somehow it seems like FlashProgramPhrase (FlashCommandSequence) continues before the write operation is completely ready. I have not modified code related to CCIF handling.

I suspected the IDE on PC could try doing interfering flash reads through JTAG when the memory view is open, but closing it doesn't help. (I'd expect seeing some kind of error from the driver in this situation.) Just to exclude some things I also tried to turn FMC cache off ( FMC_PFB23CR = FMC_PFB23CR & FMC_PFB23CR_B23RWSC_MASK; ) but it did not make any difference.

Any ideas what I could be doing wrong, or what would be worth trying? Thanks!

Labels (1)
0 Kudos
1 Solution
630 Views
mjbcswitzerland
Specialist V

Hi

1. Some debuggers don't update the memory view ()correctly so make sure that you command a refresh of this to be sure that you are seeîng the latest Flash content

2. The K60 has some caching enabled by default and it may be returning old data from its cache of the Flash area you are viewing. There is a command to flush the cache so try performing that after the write to be sure that what you read back is really from the flash. Since flash programming is performed by the flash module and not by writes to memory it is bypassing the cache and so the content may not be synchronised.

Regards

Mark

View solution in original post

0 Kudos
3 Replies
630 Views
perlam_i_au
Senior Contributor I

Could you please share the mask set of your device??

0 Kudos
631 Views
mjbcswitzerland
Specialist V

Hi

1. Some debuggers don't update the memory view ()correctly so make sure that you command a refresh of this to be sure that you are seeîng the latest Flash content

2. The K60 has some caching enabled by default and it may be returning old data from its cache of the Flash area you are viewing. There is a command to flush the cache so try performing that after the write to be sure that what you read back is really from the flash. Since flash programming is performed by the flash module and not by writes to memory it is bypassing the cache and so the content may not be synchronised.

Regards

Mark

0 Kudos
630 Views
lasseh
Contributor I

Thank you both for help. It actually was a cache problem, but not FMC like I first assumed.

I had manually enabled CODE_CACHE early in init. Disabling it made flash operations work as expected. (I also disabled FMC for the area that was written, but it did not seem to be the primary cause of problem.)

0 Kudos