Preventing reprogrammig

I am just starting to work with the Seeeduino XIAO, and I am designing a product I may want to sell. Once I have flashed the code into the chip, I want to make sure it cannot be altered. How do I alter the chip so it will no longer load new code?

Thanks in advance for any suggestions.


You need to read the datasheet of the device and check whether it provides any functionality for that. Most devices do not provide a way of locking down completely but some do. Can you provide a link to the datasheet of your device?

You could also look into preventing access to the device e.g. not exposing the pins for programming and covering the device in a substance that hardens after applying it on top of the device.

What is the reason you do not want anyone to alter your product? In some applications seals are used on the casing to prove manipulation.

I am pretty sure there is not going to be a way to prevent new code being put on the chip. You can usually prevent someone from reading your code from the chip. Read the datasheet, in particular the section on code protection.

From the datasheet...

Programming the Flash or RAM memories is only possible when the device is not protected by the
NVMCTRL security bit. The programming procedure is as follows:


The security bit allows the entire chip to be locked from external access for code security. The security bit
can be written by a dedicated command, Set Security Bit (SSB). Once set, the only way to clear the
security bit is through a debugger Chip Erase command. After issuing the SSB command, the PROGE
error bit can be checked.
In order to increase the security level it is recommended to enable the internal BOD33 when the security
bit is set.

So yes you can protect the chip from programming and reading.

From the datasheet...andSo yes you can protect the chip from programming and reading.

The SAMD21 chip is designed to protect the original program and even its data, but with a debugger you can do a full chip erase and write your own software into it.

There are very few modern microcontrollers that allow complete disabling or password protection of all debug features and SAMD21 is not one of them.

This feature is currently reintroduced again (in the old days they used ROM devices) for application where the customer cannot be trusted for legal reason e.g., smart metering or where companies want to prevent customers from modifying the product and lock them into their ecosystem.

There are protected one time programmable chips which cannot be read or reprogrammed. These are usually 8bit MCUs intended for mass market products. But l guess your main concern is to prevent access to your existing code in flash memory, not to prevent someone wiping the flash memory, then completely replacing your code with theirs.
