I'm making a device based on the Atmel ATSAM4S2B mcu, and I want the user to be able to update firmware if they want. For this they need to be able to erase the flash to enter the SAM-BA bootloader that can flash the chip over USB.
At first I was going to add a pin header on the board that can be used to short the erase pin to 3.3V by moving a jumper. But this requires them to open up the case to expose the PCB, risking ESD damage and increasing cost and so on.
So I thought of coding a software erase by tying a GPIO pin to the erase pin and setting it high when a certain command is written over USB. But it just gave me pause.. Is this a good idea? Can it lead to the MCU erasing itself accidentally? I checked with an oscilloscope and GPIO pins seems to output some voltage for around 25ms when powering up and also a small spike when shutting off. However the datasheet of the MCU says that the erase pin is debounced to the system clock and also needs to stay high for at least 200+ ms to activate. So in theory it should be fine, but I can't help thinking I might be missing something. Can someone offer any insight?