Hi NXP
I want to configure the FlexNVM for use as EEPROM data. However when I generate the PE code it doesn't generate the methods CPU_GetFlexNVMPartitionCode() or CPU_SetFlexNVMPartition().
So I cannot configure the FlexNVM on startup.
I am using KDS 3.0.0, KSDK 1.3.0 on Windows 10 generating code for MK20DX256VLK10
I am now stuck and not sure if it is a problem with my PE settings or a bug within the PE itself.
I have looked up similar examples in the NXP site such as 607244 In this example the Methods list for the cpu component includes the option to generate the above methods. On my KDS/PE I don't get this option. See screenshots below.
Below is my EEPROM configuration.
Below when hovering over the FlexNVM option it indicates to call SetFlexNVMPartition() to configure the EEPROM but this function is not generated for my build.
And I don't get a SetFlexNVMPartition() method in the CPU list of methods.
Below, just to confirm CPU type.
Also attached is a demo K20 project where I try to configure the EEPROM in the CPU component settings.
Any help on this would be much appreciated.
Thank you
Sean
Original Attachment has been moved to: USB_K20TEST.zip
Solved! Go to Solution.
Hello Sean,
Does this function can meet your requirement ?
I yes , please add the component of "fsl_flash" on your project , it include most of the operate of flash.
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello ,
The SetFlexNVMPartition() method is when we create one Processor Expert project (without KSDK) on
kds, your project is KSDK+PE, pay attention that the two are different。
About create the PE project , when you create project , please select the None in the kinetis SDK:
Hope it helps
.
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Alice
Thank you for the quick response.
Our existing project already uses KDSK code (e.g. for USB) so I don't think we can regenerate the project without KSDK.
Is there a mechanism to configure the FlexNVM when developing with KSDK and PE together.
Ideally I would like to add some code that on startup checks to see if the FlexNVM is configured, and if it isn't then to configure it.
Can you suggest the best way to achieve this in our current project setup.
Thanks again
regards
Sean
Hello Sean,
Does this function can meet your requirement ?
I yes , please add the component of "fsl_flash" on your project , it include most of the operate of flash.
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Alice
That looks ideal. I will try this function in my project.
Is it safe to call this function on every bootup, or should I add code to detect if the FlexNVM is already configured?
Thank you for the quick reply.
regards
Sean
Hi Alice
One additional question I have ;
The fsl_flash component generates the structure for the FLASH_SSD_CONFIG when I 'Generate Code' in PE.
But the DFLashSize and EEESize fields are shown as zero. From my FlexNVM configuration in the cpu component I would expect my DFlashSize to be 224Kbyte and 32Kbyte respectively.
Are the values in flash1_InitConfig0 correct for my configuration or do I have to overwrite them before calling the DEFlashPartition() function? Or does it not matter?
My FlexNVM settings are ;
regards
Sean
Hi Alice
I have tried the DEFlashPartition() method but I still have problems trying to write to EEPROM.
The DEFlashPartition() now returns the code 0x20 and the flashConfig structure looks like the FlexNVM has been configured as I expect with 128 bytes EEPROM space in 32 Kbytes of FlexNVM.
When I read the EEPROM space directly at 0x14000000 I read FFs, which seems OK as it is blank.
I then try to write to the EEPROM via the EEEWrite() method.
This returns a code of zero (OK?) but the EEPROM data at 0x14000000 remains at FF (I try to write 0x1234abcd)
Can you advise me if I am doing anything incorrectly here, or maybe missing a step.
Below is my code, the bootloader_InitFlash() puts the Flash function into ram and I then try to read/write to EEPROM. Read is OK, reads 0xFFFFFFFF, but also reads 0xFFFFFFFF after the EEWrite()
And below is the contents of the FlashConfig structure, which looks OK, 128 bytes of EEPROM and 0x38000 bytes of DFlash.
Thank you
regards
Sean
I think I have resolved this problem. I should only call DEFlashPartition() once when not configured. If I do this then I can write to the EEPROM area OK.
I check if the FlexNVM is already partitioned by looking at the EESize in the flashpartition structure.
if ( flash1_InitConfig0.EEESize != 0x80 )
{
// DEFlashPartition should only be called once when FlexNVM is not setup.
// So after first factory boot up this function should never be called again.
result = DEFlashPartition ( &flash1_InitConfig0, 0x37, 0x03, g_FlashLaunchCommand ) ;
}
// Test write and read to EEPROM
eepromData = 0x12345678 ;
result = EEEWrite ( &flash1_InitConfig0, 0x14000000, 4, (uint8_t*) &eepromData ) ;
eepromData = * ((unsigned int*) 0x14000000) ;
So I think my FlexNVM is working OK. I can also write to the DFlash Space which is not allocated to EEPROM emulation.
Thanks Alice for helping me with this.
regards
Sean