Hi,
we are using an LPC5526, and we wanted some sort of Code Read Protection like we are used to with for instance LPC546xx devices:
- Lock the device in Production, so it can't be read over SWD or SPI/I2C etc (FlashMagic) anymore
- Unlock the device, so it can be reprogrammed in Production.
So we implemented the locking mechanism, as described in LPC552x: How to write CMPA to disable debug subdomains from application?
Important note: to be able to unlock, the device should not be sealed (there is no way to unlock a sealed device), so use the 'development' mode.
However, unlocking a device will just do that: it won't erase the device like we are used to with the LPC546xx.
So we added a full Flash erase before unlocking.
To be able to do that we implemented is in a RAM function, seeLPC55xx (Mass) Flash erase with IAP
Now when testing this, we found that sometimes the device gets bricked:
- The bootloader/application no longer runs, so we are not able to unlock anymore
- The device cannot be reached:
- When trying to connect over SWD connection fails (SW-DAP can't even be found..., which it can when it is correctly locked)
- Also FlashMagic cannot connect
After some testing we suspected that a connected (Segger) debugger causes this.
We can't explain why, but now we always disconnect the debugger (physically!) before locking/unlocking, and we no longer see bricked devices.
Is there some explanation for this, or another way to prevent this situation?
Is there a way to unbrick our products (in case SW-DAP can't be found)?
Thanks in advance,
Jan Pieter de Ruiter
Airios