1

I need a way to both ID (a sketch/compiled hex) and later on, identify based on this ID the project that got uploaded to my Arduino microcontroller. As of right now, I have explored multiple options for storing the ID and reading the ID from the Arduino. The ID would be a custom string or later on multiple strings. Here are the 3 options I have been thinking about with their pros and cons:


Option 1:

Writing: A custom function that would be added to every sketch before compilation, containing the ID information and a serial connection setup

Reading: The function would dump the ID over the serial connection using a fixed baud, after this, the projects original serial and baud would be initialized. The microcontroller would need to be rebooted in order for the user to be able to read the ID from it.

Pros: Easy to implement.

Cons: Would require manual or software restart of the microcontroller in order to read the ID


Option 2:

Writing: writing the ID to the EEPROM

Reading: reading the ID from the EEPROM over the serial connection.

Pros: Would probably not interference with the original code

Cons: it wears the EEPROM, it might need its own function in the sketch to read the ID from the EEPROM thus making it a complicated Option1.


Option 3: Editing the HEX file to include a signature

Writing: add the ID to the hex file itself (hex editing), after compiling it.

Reading: dumping the hex file and decoding the string.

Pros: No baud or serial needed to be set?

Cons: Probably slow, can end up producing a bad hex file, hard to implement properly with larger ID-s and structures


Example data:

project="marlin2.1", config="prusa", version="8.80", env1="pin2"

As said, the basic idea is storing an ID but I would late want to expand this and store more information like a struct. This solution should be able to Target as many Arduino models as possible. I am looking for the best way that I might have missed to achieve this task or any recommendations.

  • 1
    Which Arduino...? – Majenko Sep 18 '18 at 22:17
  • Please tell what the ID is for (add the extra information to your question). Reading the eeprom does not wear it. With Option 1, the arduino dumps data by itself. That is odd. There are at least 10 other options. An other option is to include a .h file that has a generated ID. The compiler can put the compilation date and time in the sketch. The smallest arduino board can still do some decrypting, so you might put an encrypted ID in the arduino. Some arduino boards have a microcontroller that has an ID of its own. All the 1-Wire devices have an ID, just add a 1 dollar 1-Wire device. and so on. – Jot Sep 19 '18 at 2:19
  • I have added some examples to the top post. And about the eeprom I was talking about constantly rewriting the eeprom that it might wear it, every new sketch would have its own data set that would be readable from the Arduino using the computer. – BoKKeR Sep 19 '18 at 6:00
  • Option 1 and 3 are kind of identical. – Gerben Sep 19 '18 at 9:37
  • Option 3 would eliminate the need to setup a serial connection in every sketch. And I don't know if its possible to dump the hex file from every Arduino model. But beyond these points yes, option 1 and 3 are almost identical. I did not try option 3 in practice yet, but I think that it is possible to achieve a working edit/write/read/decode process. – BoKKeR Sep 19 '18 at 13:01
-1

I'd go with #2. If you are concerned that you will eventually burn-out your EEPROM (100.000 write cycles per ATmega328 ds), try writing a macro, which will dictate at which upload you want new ID to be written in EEPROM. Heck, instead of writing all of these onboard, why don't you maintain an offline lookup database and encode things yourself? It would still require writing to EEPROM but you could encode your information in a couple of ints.

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.