After FLASH_Init which return status 0 and some FLASH_GetProperty which also returns correct values I try execute below which return status 103 :
regPrimask = DisableGlobalIRQ();
statusF = FLASH_Erase(&configF, 0x42000, 4096, key);
EnableGlobalIRQ(regPrimask);
a FLASH registers is as follow : registers.png
after callFtfxRunCommand((FTFx_REG8_ACCESS_TYPE)(&FTFx->FSTAT)); the FTFE-FSTAT became 0xa0 (10100000) which correspond to status 103
Command execution looks like from right place (RAM) :
ame : config->runCmdFuncAddr.commadAddr
Details:536872649
Default:536872649
Decimal:536872649
Hex:0x200006c9
Binary:100000000000000000011011001001
Octal:04000003311
Change in erase address to 40000 or 41000 gives same result
What is wrong?
Solved! Go to Solution.
I don't think the clocking is the issue. I suggest you swap the MCU and execute the same example to see if the problem still persists.
It is important to mention that the MCU must be in RUN mode before executing the command, if a command attempts to be executed in HSRUN mode the device will be trapped.
Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar
I found this post :
all looks exactly as on Mike screenshots except ram address value (because I have different device) and that all it doesn't work
Hello Molbuy
This error indicates that the instruction code is invalid or the address is out of bound.
Which value are you writing in the variable "key"?
Do you have this same problem with the parameters of the SDK example?
I will be waiting for your reply, if you have more questions do not hesitate to ask me.
Best regards,
Omar
Hello Omar.
The key is :
uint32_t key = FOUR_CHAR_CODE('k', 'f', 'e', 'k');
and it taken from fsl_ftfx_controller.h, moreover, if execution of code reached the "callFtfxRunCommand" then key passed before successfully.
Also, as you can see the address of "callFtfxRunCommand" is 0x200006c9 which in range of upper sram region for that device.
Where can I see appropriate sdk example?
Hello
Thank you for your reply, the key is correct and the command is in SRAM.
I suggest you test your device with the SDK example to check if this problem still persists. You can import the example in the MCUXpresso in the option "Import SDK examples(s)"
Please let me know the results, if you have more questions do not hesitate to ask me.
Best regards,
Omar
below is my result :
PFlash Example Start
PFlash Information:
Total Program Flash Size: 512 KB, Hex: (0x80000)
Program Flash Sector Size: 4 KB, Hex: (0x1000)
Flash is UNSECURE!
Erase a sector of flash
---- HALTED DUE TO FLASH ERROR! ----
I just copy a "main" function of flash.c to my project with minor corrections, then run it from main loop
Thank you for letting me know your findings. I did the same test with different memory locations and the sector erase was successfully executed.
I suggest you check the value in the register FPROTn to verify if this feature is not enabled.
To disable this feature you can refer to chapter 17.4.4.6 of the reference manual: https://www.nxp.com/docs/en/reference-manual/KE1xFP100M168SF0RM.pdf
Let me know if this helps, if you have more questions do not hesitate to ask me.
Best regards,
Omar
can it relate to clocking?
I currently clock flash from PLL
core clock 120mgz, bus 60mgz, flash 17.14mgz (divcore/7)
I don't think the clocking is the issue. I suggest you swap the MCU and execute the same example to see if the problem still persists.
It is important to mention that the MCU must be in RUN mode before executing the command, if a command attempts to be executed in HSRUN mode the device will be trapped.
Let me know if this is helpful, if you have more questions do not hesitate to ask me.
Best regards,
Omar
Yes, switching to RUN mode solve problem
A code from 18f_pflashof sdk examples passed without errors
thanks
Yes, a device currently run in HSRUN mode
I will try bit latter to switch to RUN mode and back to HSRUN on the fly and let you know
currently I boosted core clock to 144mgz
FTFE registers look ok, all FPROT = 0xFF