AnsweredAssumed Answered

How to disable NMI on MKL02Z32?

Question asked by Aron Papp on Jan 28, 2018
Latest reply on Jan 29, 2018 by Kerry Zhou



We are using a MKL02Z32CAF4R MCU. The programming is done in MCUExpresso, and after generating the .axf file, we use openocd to download it to the MCU through an LPC-Link2 (direct download from MCUExpresso did not work).


In our circuit a sensor is connected to the NMI_b pin, which is pulling it down to GND. The official guide ( advises to change the content of the Flash configuration in the "startup_*.c" file. We made the update, but the value of the FOPT Byte did not change in the FTFA, thus had no impact on the boot process. (Change in startup_mkl02z4.c highlighted with red)


__attribute__ ((used,section(".FlashConfig"))) const struct { unsigned int word1; unsigned int word2; unsigned int word3; unsigned int word4; } Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFBFE};


openocd also complains about the checksum, but it confirms to change the register on the desired address (0x40D):

Error: checksum mismatch - attempting binary compare
diff 0 address 0x0000040d. Was 0xff instead of 0xfb

Thanks for your help,




We tired to program the MCU via Keil uVision, and using the LPCLink2 programmer after flashing the verify was OK, and the FOPT was updated to 251 (0xFB). I can confirm, it works for both JLINK and CMSIS firmawares.

The failing command for the openocd programming:

openocd -f /usr/share/openocd/scripts/interface/cmsis-dap.cfg -f /usr/share/openocd/scripts/target/klx.cfg -c "init" -c "kinetis mdm halt" -c "program MKL02Z32CAF4R.axf verify reset exit"

If we find the correct parameters I will let you know. 



With the following command one can enable openocd to write the protected memory area:

-c "kinetis fcf_source write"

You can also write for example 0xFB to FOPT directly with the following:

-c "kinetis fopt 0xFB"