Gonzalo Avila Alterach

Bricked MKL05Z32 after programming with USBDM

Discussion created by Gonzalo Avila Alterach on Jun 28, 2017
Latest reply on Jun 29, 2017 by Gonzalo Avila Alterach

Hi everyone.


I'm having a weird issue with a MKL05Z32 microcontroller. I'm using a custom board with only the main components populated (decoupling cap near uC, 3.3v regulator + cap and 10 pin header). It worked fine a couple of times, but after progamming it with USBDM with a certain program, the security status turned into "secure", and it can't be mass erased anymore.


I've changed the chip only to find that the same thing happened again, first download worked but it was bricked after that  


Using USBDM and checking the MDM Status, it seems that the microcontroller enters the mass erase stage, but it never clears the MASS_ERASE_ACK bit. It also seems like the FLASH_RDY bit gets set and cleared randomly . So the mass erase process timeouts and fails.


I even tried using openocd with a raspberry pi to attempt to erase it, but the same thing is happening


I have the project in Dropbox, so I checked how the uploaded elf file changed after it started failing, and I've realised that it might have started failing after disabling NMI pin (setting FOPT register value in 0x40C with value 0xFB instead of 0xFF). The other bytes regarding security are the default (0x7E for FSEC, FF everyting else). But why would that interfere with the programming?

Could it be that somehow the security bits were written in a wrong order or something similar? I will discard this board and keep nmi just as it was, but I'd like to know what the real reason is...


Other causes were discarded, don't think it was ESD (the microcontroller was soldered with an antistatic strap with proper grounding), temperature (we only soldered the 3 swd pins ,1 for the LED and 4 supply pins).


Any ideas?

Many thanks,