Reputation: 513
So the issue I'm having revolves around programming a bunch esp8266 ESP-12 with ardunio code.
The main issue is that each esp8266 needs to have a token which allows it to authenticate with our server, however going through and changing token = ___
each time requires a full recompile and takes almost a minute from start to finish (which is a lot when flashing 1000's of boards).
In short is there a simpler way to include run time vars that doesn't involve recompiling the whole thing?
Upvotes: 1
Views: 417
Reputation: 1910
You could put the ID into EEPROM but if you inly want to flash one file (Flash content) you can use
static const uint32_t UniqueID __attribute__((section(".progmem"))) = 0x12345678;
but you will not know the address in flash and it may change when you recompile.
PROGMEM reference
You can also define a section to a known address in Flash (may be in the end of memory) I know this works with GCC but never tested in Arduino IDE.
static const uint32_t UniqueID __attribute__((section(".mySection"))) = 0x12345678;
Last solution is to simply define an address in the code where to read with pgm_read_*
The .hex file can then easily be modified with srec_cat
to change the ID and then be flashed.
This can be used in production to give unique ID to each chip.
Upvotes: 1
Reputation: 49331
I'm not familiar with ESP8266, but most MCUs you can do one or more of the following, depending whether the programmer allows programming parts of the flash separately or whether it has an externally programmable EEPROM:
Upvotes: 1