Good morning
Gooe morning
I attach a video to explain what happens.
I erase and write the sector starting at address 0x1000. If a use a breakpoint in the function FlashCommandSequence() the erasing and the writing is successful. If I remove the breakpoint
it craches.
I use a KE processor, running at 120MHz. In the video the command is sent through a console on the serial port.
The strange additionallly is it was working at the first test, now that's the happening.
I need a suggestion.
Thank You
Pietro
Glad I stumbled on to this, I ran into a very similar problem on the KE18 trying to program the program flash. In my case, the first sector programmed correctly, but subsequent ones had some bytes that would read back as 0xFF, even though the flash program operation indicated no errors had occurred. In studying the fsl_flash.c file, I believe the secret was disabling the flash speculation in the MSCM register to commit. Once I disabled that to program the flash sector, it verified correctly.
Hi David,
Thanks for your experience sharing.
Next time, if you have the question, you also can create your own question post, we will help you directly in your post.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello everybody
This question is still open for me. If someone has suggestions is very welcome...
Thank You
Pietro
Hi Pietro,
What the IDE you are using?
I open your project with KDS, but there has some invalid project notes:
I find in your package, there's no board, drivers folder, any problems on your side?
Please also tell me the problem reflect steps in your project.
I am testing it on my TWR-KE18F board.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hi Pietro,
I checked your code, I find your code when run the flash_ops_write function, the code will be reset.
But run the erase have no problem.
So, I check your erase and program code, I find in your erase function, before you launch the flash operation, you disable the interrupt, after it finished, it enable the interrupt.
But in the program function, you didn't do it, so when you do the flash operation, your flash program will be interrupt by the PIT interrupt, then the MCU will have problems, it will reset the system, now I add the interrupt disable code before the program function, the reset problem will be disappear.
__disable_irq();
status = flash_ops_write( fbuf, start, length );
__enable_irq();
But, your code function seem still have problem, I check the memory, I find the code didn't write to the according address. Do you check your code function before? Whether it can write successfully to your according address?
If your function also have problem, I suggest you refer to our official KE18 SDK flash code, you can port the official code to your own project.
Wish it helps you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank You for this analysis. I have tested the example in the SDK and it Works. Still it is not Clear what happens in the driver I use, working fine for a total bootload. I will decide what to do, to have a working version to deliver. I hope the light on the subject will come at least incidentally....
Thank You
Pietro
HI Pietro,
You are welcome.
I highly suggest you port our working SDK flash code to your own project, then test it again.
Any help you need from me, just let me know.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank You,,
The project is made for a board using the same processor, there is no specific informations on the tower board. I have just deleted some specific files and adapted to produce the bug. It is working as is on the TWR-KE18F board. The cleaning has left some path of the original project but they appear to be innocent.
I have now cleaned the project files manually and the warnings do not appear any more.
Unfortunately I am trying to attach the new cleaned project but I do not find the option to attach it..
I will see further if I find the problem and send the new project. If You can use as is it is working by my side.
Very much THANK YOU
Pietro
Hei all of You
I am very grateful for the support. I tried whatever but what happens escape any logic. The flash operation is in RAM. I tried to disable the interrupt while in flash operation but nothing changes.
The incomprehensible is that the crap happens when erasing the sector beginning at 0x1000, where some configuration data are.
After a bootload, so a large amount of flash is erased and written without any problems, the end of bootloading sequence calls the small routine that erases and writes the sector at address 0x1000. And all proceeds regularly.
If I try to call the same procedure directly without the full bootload it crahes.
And it is doing exactly the same thing.
I resume, the same procedure after a bootload is successful, called at once crashes. It is totally illogic.
Every suggestion is welcome...
Thank You
Pietro
Hi Pietro,
Please tell me the full name of your KE chip, also tell me what the flash clock frequency you are using?
Besides, please check your code size, whether it is larger than 0x1000, you must make sure the 0X1000 is not your code area.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank You
I am using the NXP MKE18F512VLH16, I tested also on the TWR-KE18F with the same result. I use the 120MHz clock out of the SDK function
BOARD_BootClockRUN().. My board is working at 5Volts.
I also tried to slow down the clock at 60 MHz, replacing the divCore with kSCG_SysClkDivBy2 in the g_sysClkConfig_BOARD_BootClockRUN structure, the result is the same.
I will try to produce an exposable example of my project so I can publish.
Thank You
Pietro
And here it is..
I attached to the previous post. I try to write to the address 0x1000 than to 0x2000.
All of the strange things happen,,
Thank You very much for the support.
Pietro
Hi Pietro,
Thank you for your updated information.
I will help you check you code, please wait patiently.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hei Kerry
Let me know if You have some findings.. I still do not get the points with the guns I have,,,
Best Regards
Pietro
Hi Customer,
Mark's reply is correct, before you do the flash launch command, you need to disable the globle interrupt, after the flash operation finished, you can enable the interrupt again.
Please try it again.
If you still have problems about it, please kindly let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hei
I am struggling to find an accomodation. I see now if I process a first cycle of erase/writing in the sector using the breakpoints, I can repeat the cycle on the same sector without breakpoints and it works.
To me appears a weakness of the flash.
Suggestions welcome.
Pietro
Hello Pietro
If deleting code in the same plane as 0x1000 you need to run the command code in SRAM.
If your interrupt vectors or any interrupt code is in Flash in the same plane as being deleted or programmed you must disable interrupts when it is executing.
Regards
Mark
uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html