0

I’d like to protect my arduino make with a unique serial number for every device I make. What are the proper ways to do it? Probably there are kind of best practices… Keep it in EEPROM is obviously a bad idea.

I believe that there is some chip that can be added to the circuitry.

The general idea is the following. Circuitry has a hardware which gives a unique id (serial number). Distributor/seller generates the signature using unique id and put it to the eeprom. Arduino program verifies this signature using hardware serial number. Arduino program is distributed in binary or within the device.

  • Why is EEPROM a bad idea for this? – chrisl Nov 16 '19 at 14:11
  • Because it can be rewritten easily. – zhekaus Nov 16 '19 at 14:16
  • And even with an extra chip, the sketch on the Arduino needs to send read and send the ID of the device. One could easily change the sketch to not send the ID from the extra chip, but a custom one. Unless you connect the extra chip directly to the external device or you use encryption, it is still possible to change. What are you trying here? Is it a safety measure, so that no one temperes with your device? Or do you just want to prevent to accidentially override it? – chrisl Nov 16 '19 at 14:55
  • @chrisl, I distribute hex only, no sources. Since that nobody can alter the sketch. I am trying to protect my hex from easy copying. – zhekaus Nov 16 '19 at 15:02
  • "Since that nobody can alter the sketch." This is plain wrong. It is no problem to decompile hex dumps of several KB, especially if you know the hardware. I've done that multiple times. – the busybee Nov 16 '19 at 16:31
2

I still suggest using the eeprom. It is the firmware's job to handle whether or not data in eeprom can be written. You could implement wrapper functions for the arduino which can only read/write after a defined offset. You can set this read-only data with the .eep-file when you upload your sketch. The eeprom file then may be generated programmatically.

Once you have to flash several individual devices with a final firmware version, there are no benefits in using the arduino ide. You can upload the firmware and the eeprom file using avrdude:

avrdude -P YOUR_PORT -b 115200 -p ATmega328P -e -U flash:w:YOUR_FIRMWARE.hex -U eeprom:w:YOUR_EEPROM.eep

It's up to you how to generate the eeprom file (bash/batch, make, pyhton,...).

| improve this answer | |
  • Sounds interesting! Can you add an example how to use it? – zhekaus Nov 16 '19 at 14:34
  • I don't get it. Anybody can upload eeprom file from another arduino. I want to protect my devices from copying. – zhekaus Nov 16 '19 at 15:04
  • @zhekaus doesn't the upload work? You have to run the command from the build directory. You may have to select a programmer, but I think avrdude would force you. The simplest to get an eeprom file to start with might be to initialize the eeprom with temporary firmware which stores the desired values and then read-back the .eep-file using the above command with eeprom:r:initial.eep. – Sim Son Nov 16 '19 at 15:23
  • @zhekaus also, what do you mean by "protect my devices from copying"? An attacker would be able to read or write any unencrypted data the same way you do anyway. – Sim Son Nov 16 '19 at 15:26
  • nobody asks how to upload eeprom. Let's stick to the initial question, please )) – zhekaus Nov 16 '19 at 15:27
0

I found a way! I can use DS2401 or DS2411.

These devices are 64-bit read only memory (ROM) "silicon serial number" devices which are programmed by the manufacturer with a unique 48 bit serial number, an 8 bit product family code, and an 8 bit CRC.

| improve this answer | |
  • 1
    it can be removed, replaced – Juraj Nov 16 '19 at 14:39
  • If it's removed, device won't work. Also, I suppose to keep a signature in eeprom which will be verified with unique id. If it’s not verified, device won’t work. – zhekaus Nov 16 '19 at 14:55
  • 1
    @zhekaus (See my comment at your question,too.) Since your sketch can be decompiled it is no problem to work around any protection you implemented. – the busybee Nov 16 '19 at 16:32
  • @thebusybee You are right. But it requires extra skills, much more advances than avrdude using. My makes are not rocket science. I simply want to have a reasonable protection, nothing fancy or extremely robust. – zhekaus Nov 16 '19 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.