Hi Filip Trajkovic,
Whether your new code is secure the chip to the highest level? disable mass erase, disable back door key, enable secure in the flash configuration filed.
When you use JLINK commander, you need to connect it at first.
1. connect, choose the MK66 chip
2. input : s, choose the SWD
Then go on follow the command, if it can't find the core, then input: unlock kinetis
If you still can't unlock it, I am afraid your chip is secured to the highest level(can't unlock again) or it is damaged(refer to the document I give you).
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------