I'm working with an S32K116. When I
kinetis mdm mass_erase
load
)OpenOCD crashes with an assertion failure in src/flash/nor/kinetis.c:1492
. If I restart OpenOCD and try to flash the chip again, I get the message that the MCU is in secured state.
As far as I understand, this happens because kinetis_probe()
detects the EEPROM partitioning and thus does not allocate sectors
or prot_blocks
(kinetis.c:3022
).
If I add a check for num_prot_blocks == 0
before the assert (see the attached patch), OpenOCD no longer crashes and the MCU does not go into secured state.
I'm not sure if this is the correct place to fix it --- the assertion is kind of obvious, but I don't understand why the MCU goes into secured state, or why not failing the assertion prevents going into secured state.
Thanks for reporting!
I was able to reproduce the problem on the older K66FX1M0
Your solution is correct, but...
Please be aware that OpenOCD project requires submitting patches to the Gerrit review system, we are not able to accept patches from mails and tickets. See https://openocd.org/doc/doxygen/html/patchguide.html
In this case I made an exception as I want to remove the
assert()
to prevent the MCU locking effect (and I'm the author of this bug ;-)Please test
8719: flash/nor/kinetis: fix assertion during flash write | https://review.openocd.org/c/openocd/+/8719
I added your mail to Suggested-by clause of the commit message. I hope it's enough to express your credit.
BTW Don't you want to contribute a S32K1xx part of
kinetis_nvm_partition
handler?You already managed it in python, so it should be easy to rewrite to C...
Thanks for the swift response and submitting the patch, I'll test it on Monday. No worries about credit, I'm just happy if we don't have to maintain a patched version ;)
I'll look into writing the partition handler.
Just tested the patch, it works fine :)