How do I debug EM3xx programming issues?
There are several possible causes of EM3xx programming issues. Some examples are described below.
One possible cause for not being able to program EM3xx flash is having enabled read and write protection inadvertently. This is easy to identify, as em3xx_load will display a message stating that read protection is enabled. To recover the device, simply disable read protection with the following command:
This operation will also erase the main flash block.
Another possible cause could be data corruption in the main flash block. This could be caused by programming a corrupt image into flash, where the application is in a tight reset loop that prevents the debugger from interfacing with the target device. In such a case, the EM3xx can be forced to enter FIB monitor mode, which will bypass the application, allowing the debugger to access the target and erase the corrupt image. This is achieved by shorting pin PA5 to ground on a power-up/boot-up event. You can verify that you know have a serial wire access to the device by issuing the following command, which reads the EUI-64 from the flash:
This should display valid EUI-64 without any errors. Then, continuing to hold PA5 low, run either of the following commands:
The command ‘masserase’ will perform a global erase operation and the entire flash block is erased at once, while the command ‘erase’ does a page by page erase operation. Once erased, PA5 can be removed from ground. Once the above action is done, programming operations on the EM3xx chip should now return to normal.