Can Flashx driver be use to write to the "Data Flash" of the FlexNVM? The FlashNVM example show the example of writing to the EEPROM partition. How do I change it so it write to the "Data Flash"?
Solved! Go to Solution.
Hi,
I just checked the early release and unfortunately it seems that the flashx driver can only be used in the P-Flash.
This is a software limitation, because you can treat the remaining D-Flash as P-Flash and write, read to it using flash routines.
You could either try to modify the flashx driver or migrate your own driver to MQX.
You can find examples in the C90TFS flash drivers where the D-Flash region is treated as P-Flash.
You can try to migrate this driver to your application.
Hi,
I just checked the early release and unfortunately it seems that the flashx driver can only be used in the P-Flash.
This is a software limitation, because you can treat the remaining D-Flash as P-Flash and write, read to it using flash routines.
You could either try to modify the flashx driver or migrate your own driver to MQX.
You can find examples in the C90TFS flash drivers where the D-Flash region is treated as P-Flash.
You can try to migrate this driver to your application.
Thanks.
Hi Huan,
The FTFL write and erase sector functions do not translate the FlexNVM 32-bit address to 24-bit address. To access the FlexNVM/bank1 flash bit-23 of the write_addr used in the command_array[1] needs to be set.
I added simple address check and translation as shown below.
From the ftfl_flash_erase_sector()
write_addr = (_mem_size) from_ptr;
#if 1 //DES 1=test,0=default code
if(write_addr & 0x10000000) //DES Hack that looks at address and if in the 0x10000000 range we assume access is for FlexNVM/bank1 flash block and we set bit 23 to gain access
write_addr |= 0x00800000;
#endif
From the ftfl_flash_write_sector()
write_addr = (_mem_size) to_ptr; //DES??? should this have check of dev_ptr->FLAGS to translate address to NVM/bank1 by setting bit 23?
#if 1 //DES 1=test,0=default code
if(write_addr & 0x10000000) //DES Hack that looks at address and if in the 0x10000000 range we assume access is for FlexNVM/bank1 flash block and we set bit 23 to gain access
write_addr |= 0x00800000;
#endif
From my comments above I was thinking that a “better” solution would be to use the dev_ptr->FLAGS but your expertise probably can do better than that.
So know the attached is ZIP with all files I touched and project working for both program and data flash space.
Terminal Output:
MQX Flash Example
Flash file flashx:bank0 opened
Size of the flash file: 0x40000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
Bytes are blank.
Type a string to be written to the end of file (32 chars max.):flashx:bank0 test
Data written to the flash.
Now you can power down and power up your device
and then retry the test to see if the string was written correctly.
Flash example finished.
MQX NVM Flash Example
Flash file flashx_nvm:bank1 opened
Size of the flash file: 0x8000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
Bytes are blank.
Type a string to be written to the end of file (32 chars max.):
Type a string to be written to the end of file (32 chars max.):flashx_nvm:bank1 test
Data written to the flash.
Now you can power down and power up your device
and then retry the test to see if the string was written correctly.
Flash example finished.
MQX Flash Example
Flash file flashx:bank0 opened
Size of the flash file: 0x40000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
String found: flashx:bank0 test
Type a string to be written to the end of file (32 chars max.):MQX Flash Example
Data written to the flash.
Now you can power down and power up your device
and then retry the test to see if the string was written correctly.
Flash example finished.
MQX NVM Flash Example
Flash file flashx_nvm:bank1 opened
Size of the flash file: 0x8000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
String found: flashx_nvm:bank1 test
Type a string to be written to the end of file (32 chars max.):
Type a string to be written to the end of file (32 chars max.):MQX NVM Flash Example
Data written to the flash.
Now you can power down and power up your device
and rthen retry the test to see if the string was written correctly.
Flash example finished.
MQX Flash Example
Flash file flashx:bank0 opened
Size of the flash file: 0x40000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
String found: MQX Flash Example
Type a string to be written to the end of file (32 chars max.):Good Bye bank0
Data written to the flash.
Now you can power down and power up your device
and then retry the test to see if the string was written correctly.
Flash example finished.
MQX NVM Flash Example
Flash file flashx_nvm:bank1 opened
Size of the flash file: 0x8000 Bytes
Flash sector cache enabled.
Reading last 32 Bytes.
String found: MQX NVM Flash Example
Type a string to be written to the end of file (32 chars max.):
Type a string to be written to the end of file (32 chars max.):Good Bye bank1
Data written to the flash.
Now you can power down and power up your device
and then retry the test to see if the string was written correctly.
Flash example finished.
I've forwarded my results to our MQX Development team for improving this solution.
Regards,
David
PS
This was done with MQX4.0 (I have early release).
Hi David,
I just checked the code you sent. Awesome !!
I have one question, I hope you can clarify this.
According to the code, it seems that you are opening the flexnvm block 1 using the entire D-Flash right?
What if I have a partition for EEE. As far as I know when you open a file using the flashx driver. This is open at the bottom of the block you are using. And if you have a EEE partition, this would not be a conflict between both drivers?
Regards,
Alejandro
Hi Alejandro,
You are absolutely correct. The assumption is the entire FlexNVM flash is being accessed as data flash and not using any EEE capability.
The other senarios I have not considered. Hopefully I can have more free time to add more capability or someone else might beat me to the solution.
Regards,
David
Hi,
Which FlashX driver are you refering to?
To the MQX driver? or an specific example?
There's an example call "flexnvm" under Freescale\Freescale MQX 3.8\mqx\examples\. That example writes/read to the "FlexEEPROM" partition using Flashx driver. How do I get it to read/write to "Data Flash" partition of the FlexNVM? Any tips would be appreciated. Thanks.
I have not delved into this as deep as I wanted, but I believe you should use the flashx driver for the data flash.
But after skimming through the BSP code I noticed that the FlexRam and Flashx drivers are hardcoded to its corresponding block of flash. In other words the Flashx works only for P-Flash and the FlexRam works only in the D-Flash.
But the device supports writing to D-flash as in P-Flash.
I will check in the early release of MQX 4.0, perhaps there are a few changes.