Attached is the sample project that can easily recreate the issue. I'm trying to write a bootloader for the MKV31F512 but for some reason can not write/erase to anything in the write flash block (my part seems to partition the first and second 256KB). I'm simply using Processor Expert in this case to initialize my CPU configuration as well as create the Flash config and bring in the KSDK driver. If you build and run the code as is it will read prior to erasing, then erase and read, then write 4 bytes and read again. If you step through the code it will work properly. I have a define called FLASH_ADDRESS that is set to 0x40000 at the moment, if you set that to something like 0x10000 it will crash. I have yet to find an explanation for this and I have tried the flash demo on a KV31F tower board and for some reason I am able to write to the lower addresses so there must be something fundamental that I am glossing over. Thanks.
Original Attachment has been moved to: FlashTest.zip
Hello Steven,
I test on my side much times , at the result , i find the workaround .
There is no error on the configuration of the PE, you only disable these code of the file "PE_low_level_init.c" :
then save , build , debug .
I also attached my result project , it work well on my side , i also erase start at 0x10000, you can
also test it on your project .
Hope it helps
Have a great day,
Alice Yang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Alice,
Thank you very much. I have no idea why this fixed it but it did. I created a similar issue:
MKV31F not able to write/erase to flash using baremetal PE (KDS 3.0)
In regards to doing the same task without KSDK and am having similar results writing to the same flash addresses. The reason I'm going the baremetal route is the fact that using KSDK has made my bootloader project grow much too large for my liking. If you could perhaps take a look at what I'm doing wrong there when you have a moment I'd greatly appreciate it as well. Thanks.
Hello,
Have a look at this link:
Dealing with Code Size in Kinetis SDK v2.x Projects | MCU on Eclipse
Regards,
Santiago