Kinetis K20 FlexNVM Read Issue

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

Kinetis K20 FlexNVM Read Issue

Jump to solution
1,349 Views
jsteve17
Contributor III

I have an application running on a Kinetis K20 (MK20DX256VLQ10), with MQX 4.0, compiled with CW 10.3.  I have a weird issue with reading the data flash immediately after programming a virgin device.  To re-create, I do a full erase of the chip, program my application and data (which goes in the dataflash @ 0x10000000), then execute.  When I try to read the data flash I get a bus fault and am returned 0xFF for all values.  It doesn't matter how many times I reset the controller, it always fails.  However, all I have to do is stop the debugger and start a new debug session, and it magically works from there on out.  This is also true if I program the device and then run stand-alone.  If I program a virgin device and then try to power it up, the reads don't work.  I know this, because my graphics for the display are held in the data flash, so nothing appears on the screen when the reads aren't working.  However, I reconnect to the J-Link and reprogram, and everything runs fine from there on out. 

 

I have dumped the registers in both cases, and don't see anything that could explain this.  I did notice that the flash bank control registers (FMC_PFB0CR & FMC_PFB1CR) are set to 0x3002001F on the first program attempt, and then 0x30020000 after I stop and restart the debugger.  So, I'm wondering what the debugger is doing that is magically solving this issue.

 

I have attached a dump of the register contents of both a failed flash read and a good flash read.

Original Attachment has been moved to: bad_read.regs.zip

Original Attachment has been moved to: good_read.regs.zip

Labels (1)
Tags (2)
0 Kudos
1 Solution
718 Views
jsteve17
Contributor III

I didn't realize that partitioning the FlexNVM did a full erase of the Flex flash.  So when I was restarting my debugger, it was reloading the contents, and since it was already partitioned, worked from there on out.  So, the solution is to program the partition size using the FCCOB registers with the production programmer, and then load the application.

View solution in original post

0 Kudos
4 Replies
718 Views
big_steve
Contributor III

Hi,

i am working on the same issue and i need some advice.
1. Please how did you programmed Data Flash (the dataflash @ 0x10000000) from the workspace or project? I would like to save to Data Flash some pictures for LCD.
2. How is it possible at program runtime read and write to Data Flash? In other half of Data Flash i need to save at runtime a big amout of data. In flashx driver of MQX is possible just to open a "flashx:bank0" or "flashx:flexram0" but there is no possibility to open FlexNVM (also Data Flash).

I have same MXQ4.0 and same CW10.3. I am just working with Kinetis K40 with 256kB FlexNVM (Data Flash).

0 Kudos
718 Views
rogerfl
Contributor III

Do you mind contributing - or do you know of any - example code that does the program partition. I'm struggling with it, getting an ACCERR. I think it is because I'm not erasing successfully before trying to partition. DPART is 0xb instead of 0xf even after I execute a block erase on the data flash.

Roger

0 Kudos
718 Views
jsteve17
Contributor III

I should have mentioned, I'm also using the flexnvm for EEPROM.  I have it partitioned as 224K Data / 32K EEPROM.  So you will see in the registers that the bad read has the DEPART and EESIZE set different than the good read registers.  This is just because the bad registers were read before my EEPROM initialization.  However, like I said, I can restart as many times as I want, and it will not work.  So the flash partition doesn't seem to have any affect on this issue.

0 Kudos
719 Views
jsteve17
Contributor III

I didn't realize that partitioning the FlexNVM did a full erase of the Flex flash.  So when I was restarting my debugger, it was reloading the contents, and since it was already partitioned, worked from there on out.  So, the solution is to program the partition size using the FCCOB registers with the production programmer, and then load the application.

0 Kudos