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:
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
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
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.