Dear all,
I´m trying to test Flash IFR reading/writing on a K82 Kinetis MCU and I´m stuck on reading (not yet tried to write, which I guess is more complex).
I´m using MCUXpresso and fsl_ftfx_flash driver to just:
- Init flash driver (FLASH_Init(&config) --> OK)
- get properties (FLASH_GetSecurityState(&config, &securityStatus)-->OK-->UNSECURE)
- read IFR bytes (FLASH_ReadOnce and FLASH_ReadResource --> ACCESS ERROR)
I receive this access error whatever index, start values or read size I try. I also tried in DEBUG mode (PEMicro probe) and "normal" run mode (erase all flash and program firmware with KinetisFlashTool).
Could someone give a clue on this? I´m only trying to read the user available IFR bytes from firmware, which I think should be possible. Or is this funtionality restricted to ROM bootloader?
Regards,
Dear Raul,
Thank you very much for your response. However, I had already taken a look at pflash example, and there is no use at all of FLASH_ReadResource or FLASH_ReadOnce routines, at least in my SDK (SDK_2.x_MK80FN256xxx15). Could it be SDK dependant? Maybe old versions of the SDK had a more complete example?
Regards,
Hello @cabl,
Sorry for the confusion. The example does not include the FLASH_ReadResource or FLASH_ReadOnce. Nonetheless, it could be a good idea to add them in the example after checking if the flash is unsecure.
/* Test pflash basic opeation only if flash is unsecure. */
if (kFTFx_SecurityStateNotSecure == securityStatus) {
Could you please test the example and add the FLASH_ReadResource and/or FLASH_ReadOnce at some point after the lines above?
Best regards, Raul.
Thanks, Raul, for your suggestion.
I did so and manage to read IFR registers; then I copied the code to my project and it failed again, so I guess there must something in my initialization code:
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
that is making the IFR read fail. Can you think of a reason why the same code can fail with different Pins/clocks/peripheral initialization?
Regards,
I´m pretty sure it has to do with clocks configuration of my project; after copying clock setup from pflash example, IFR read works as expected (with all the code, peripherals and pins of my project up and running).
I´ll keep investigating further what exactly makes IFR read fail in my HSRUN clock setup.
Regards,
Finally I´ve found that IFR read cannot be done under HSRUN configuration, no matter that the core, system, flash...frequencies are the same as in RUN mode: in HSRUN IFR read do not work, whereas in RUN mode does.
On pag. 76 of the Reference Manual the NOTE says: "Flash erase and programming operations are not allowed in HSRUN modes", but Iy says nothing about IFR read.
On page 830 it says: "Attempts to launch a flash command in HSRUN mode will be trapped with the ACCERR flag being set". I think now the problem is clear: many procedures of fsl_ftfx_flash driver (Init, GetProperty, GetSecurityState...) depend only on software or reading registries, but operations related to launching flash commands always fail because they are prohibited in HSRUN mode.
Thanks again for your support.
Regards,