Page 1 of 1

how to insert MAC address, s/n at factory

Posted: Thu Oct 25, 2018 10:43 pm
by mzimmers
Hi, all -

In large part due to the help I've received from this forum, our ESP32 based product is nearing completion. It's time I gave some attention to incorporating it into our manufacturing process. The current challenge is how to "provision" the boards; that is, insert a unique MAC address and serial number into them when we first program the devices.

This is the first FreeRTOS based product we've built (everything else has been Linux or bare-metal). On the other platforms, the procedure is to allocate a known location within the binary for these items, and to run a program that edits the binary, putting the correct information into this known location, and recalculating the checksum. I have absolutely no idea whether this is even feasible for FreeRTOS binaries. I'm not even sure how I'd go about this, unless there's a way to set aside a data partition for this purpose.

I could go into more detail, but really I'd like to hear how other people handle this issue. Thanks for any ideas or suggestions...

Re: how to insert MAC address, s/n at factory

Posted: Thu Oct 25, 2018 11:10 pm
by ESP_igrr
One of the options is to provision all such settings in an NVS partition. A couple of utilities are provided to generate these NVS binaries in factory: NVS partition generation utility (https://docs.espressif.com/projects/esp ... n_gen.html) and Mass manufacturing utility (https://docs.espressif.com/projects/esp ... s_mfg.html).
If the settings are not meant to change, you can put them into a separate smaller NVS partition, which you can open read only. Then if you implement a factory reset feature, you can wipe only the main NVS partition, and preserve the read only one written in the factory.

Re: how to insert MAC address, s/n at factory

Posted: Fri Oct 26, 2018 8:20 pm
by stoikos
can we use BLK3 for that?

Re: how to insert MAC address, s/n at factory

Posted: Fri Oct 26, 2018 10:04 pm
by fly135
Don't all the ESP32 chips come from the factory with a unique MAC? And if the MAC is unique, why not derive your serial # from the MAC?

John A

Re: how to insert MAC address, s/n at factory

Posted: Sat Oct 27, 2018 2:21 pm
by ESP_igrr
Re. BLK3: yes you can, but at the moment espefuse.py lacks some convenience functions to write MAC address into BLK3.

Re. default MAC address: indeed every ESP32 has a unique address written into Efuse at production time. So if the only thing you need is the unique MAC, no actions required.
However sometimes customers use their own MAC address ranges, and also often additional information (such as certificates, keys, API URLs, country settings) needs to be provisioned.

Re: how to insert MAC address, s/n at factory

Posted: Mon Oct 29, 2018 10:13 pm
by mzimmers
Fly: my company purchases blocks of MAC addresses for our products, and wishes to use these. Our serial numbers have meaning (first 3 digits denotes product ID), so we need control over this as well.

I think the manufacturing utility will work for us. I'm already storing a data structure in NVS which my app uses. It would be nice if I could use this for the MAC/serial number provisioning as well.

My structure looks like this:

struct DeviceDetails
{
uint8_t macAddr[6];
char serialNbr[NBR_CHARS_SER_NBR];
// a bunch of other stuff
char label[16]; // will be checked at startup to verify NVS is programmed.
};

struct NvsBlob
{
uint32_t writeCnt;
DeviceDetails config[NBR_CONFIGS];
};

At boot time, I verify the label. If it's not valid, I erase the blob and create a new one with a valid label. Currently, I hard code a bunch of defaults into this struct, which is fine for most items, but not for MAC and serial number. I wonder if I could write a manufacturing utility that would create this blob for me? It would just need three fields: the MAC, the s/n and the label.