AnsweredAssumed Answered

Unprotecting Flash in KL26 (???)

Question asked by Mark Butcher on Mar 25, 2014
Latest reply on Mar 27, 2014 by Mark Butcher

Hi All


I just had a mishap. Using the Flash programming utility of Codewarrior I loaded a hex file thinking that it was an srec hex file (whereby it was Intel hex).

The result was that it was handled as a binary file and loaded its ASCII content to flash.

The FTFA_PROT values were set with "0B38" - or 0x30, 0x42, 0x36, 0x38 which has protected a number of flash sectors from being erased/programmed, including sector 0.


This device doesn't have an NVM special mode and it is not possible to modify the PROT values using a debugger so that sector 0 can be erased.

Codewarrior can't do an erase of the protected sectors and nor can any other tools that I have - also a mass erase is blocked when any sector is protected.


FSEC is at 0x32 (mass storage enabled and not secured) and FOPT 0x39 (fast init and reset pin dedicated, NMI enabled and OUTDIV1 is 0x01) but these seem to be harmless.


Trying to load a small program to SRAM to unlock and erase sector 0 hasn't been successful since the code exceptions on every instruction (can't execute a single line), NMI is '1' so I don't see what is stopping it...


Is there a standard way out? Would EZPORT allow unprotecting?







- being curious I couldn't resist looking into this some more and am getting the feeling that whatever I loaded to the board has really made the device unusable.
- If I load code to the SRAM I can read back the code normally. It is however impossible to run the code. Below I have copied a clip from the debugger screen showing that the disassemble window shows all good (code in SRAM from the address) - I also moved the PC to an instruction that doesn't use memory to ensure that it is purely internal. WHen executing a single step the hard fault exception is called (I think - since it jumps to an address that happens to be programmed at the Flash address 0x0000000c).
- When I load the same code to a KL25 board with no weird Flash configuration it has no problems and can step the code.

Is it possible that some configuration is not allowing instruction execution in SRAM? I didn't find any setting that would block core instruction accesses.