Hello.
I have been trying all the ways to use the EEPROM of the K10 MCU on KDS 3.1.0.
Here are the steps I made.
1.- In Processor Expert I set the EEPROM size to 2048 bytes and the EEPROM backup size to 32K. This gives a FlexNVM Partition code: 0x03, EEPROM Data Set Size: 0x23.
2.- I enable the Cpu_SetFlexNVMPartition(), Cpu_SetFlexRAMFunction(), Cpu_GetFlexNVMPartitionCode();
3.- I made a routine so it will only try once in the lifetime of the firmware to set the partition. It always fails to create, I assume that is because a function in Flash cannot modify it and have no idea how to execute the Cpu_SetFlexNVMPartition() to RAM.
4.- I tried from the Debug Configurations, Advanced Options,Enable Partitioning for the device enabled with the value of 2303. In this process I also do a mass erase.
5.- After I do the step above I cannot debug, it goes to an error and I cannot step. I uncheck the option Enable Partitioning and check the Preserve Partitioning and uncheck the mass erase option. I can debug, the function Cpu_GetFlexNVMPartitionCode() returns a partition but partition size 3F instead of 24 and 0D instead of 03. I test an no Information is saved on EEPROM
I tried also form CodeWarrior the same as above, I am able to debug when set the partition from the debugger but the same result.
Also made new project only for testing the EEPROM and the same..
Has anyone got to work the EEPROM?
Many Thanks
Original Attachment has been moved to: EEPROM_TEST.rar
Hello,
I'm using MK20DX256VLL7 controller. I am trying to use FlexNVM as mentioned above. But I am not able to partition using the Cpu_SetFlexNVMPartition() method. Everytime it fails.
My EEPROM Data Set Size is 512 bytes, D Flash 24 KB and EEPROM Backup size is 8KB. So I am passing FTFL_PDD_Cmd_ProgramPartition_Init(FTFL_BASE_PTR, 0x30 | FTFL_PDD_EEPROM_DATA_SIZE_512_B, FTFL_PDD_EEPROM_BACKUP_SIZE_8_KB) into my code (0x35) but it stop working.
Can anyone please suggest what am i missing?
Thanks in advance!
Thanks Marek,
I did eventually figure that out and do have EEEProm functioning. Two other things I determined:
- You must initialize EEEProm before starting MQXlite. I put the initialization routine just after PE_low_level_init, before PEX_RTOS_START in main.c. If you initialize in mqx_tasks.c you will get a CPU interrupt. I haven't had time to investigate why but I have a couple hunches.
- This little snippet of code, part of an initialization function from another thread, will crash because EEERDY is not checked after the write and before the read:
if (PartitionCode == FLEX_NVM_REQUESTED_PARTITION_CODE)
{
*((uint32_t *)0x14000000) += 1;
printf("Number of MCU resets form last Mass erase:",*((uint32_t *)0x14000000), "");
}
Hope this helps people. EEEProm is a neat feature but non trivial setup.
Joe
Hello all,
It seems that the issue is caused by incorrect value of the partitioning code. If you see the latest version of the K10P100M72SF1RM reference manual, there is the following table with possible value of EEPROM data set size codes:
The only correct value is 0x33 for the 2048 Bytes of EEPROM data set size.
Note: The FCCOB4[5:4] bits are used for definition of the split factor on MCUs that contains two blocks of Flex NVM. But this MK10DX256VLL7 contains one block of Flex NVM and these bits must be set to 0b11.
Best Regards,
Marek Neuzil
Thanks Marek,
I must be making progress because 0x33 is the only combination that completely locks up the processor ;-). Using PE to setup Flash Memory Organization and code you posted on a different thread causes my K10 to crash into a continuous reboot loop.
Can you verify - must the Cpu_SetFlexNVMPartition() method be run from RAM?
I am using PE. I used this: Relocating Code and Data Using the KDS GCC Linker File for Kinetis to put both Cpu_SetFlexNVMPartition() and Cpu_StartCmdAndWaitForCmdDoneOnTheStack() into RAM using __attribute__ ((section(".mydata"))).
Joe
Hello Joe,
The subroutine that do the partitioning must be in the RAM. This is done by the driver (part of the Cpu_SetFlexNVMPartition() method). You needn't to put this function into RAM. In addition, when you put a part of your code into RAM you must use proper configuration of the debugger and mustn't execute reset during debugging (otherwise the code in the RAM is deleted and must be written again by the debugger). Some debuggers also support execution of the reset after uploading code into target device. This option must be disabled otherwise the code is deleted in the RAM.
I would recommend using of the code in the FLASH memory only. Using code in RAM can cause the issue you have encountered.
Best Regards,
Marek Neuzil
Hello Juan,
For i haven't the chip of MK10DX256VLL7, so i test on K20DX256VLL7.
And , yes, on my side , when run the function of res = Cpu_SetFlexNVMPartition();
the register of FTFL_FSTAT->ACCERR is 1:Access error detected .
I will continue check .
BR
Alice
Hello Juan,
What about your debug error ? Please take a screenshot about it .
I test your project on my side , when debug , it have no error , below is some screenshot
about run the project step by shep:
Hope it helps
Alice
Hello Alice
Many thanks for your response.
In the screenshots the program goes to the default: case that is not working, it should go to the FLEX_NVM_REQUESTED_PARTITION_CODE: case. That shows that the EEPROM is not configured as expected, other value than 2303;
In fact I can write an read the EEPROM but when I restart, power cycle or debug (saving partition) the info is lost.
When I set the partition from the debuger is where I can't debug, I atach teh screenshots.
Thanks for your help
Juan
Hello Juan,
Does this thread can help you ?Return ERR_FAILED when calling Cpu_SetFlexNVMPartition() using KDS, PE and K10
Please erase all when debug .
BR
Alice