Buy off the shelf chips with preprogrammed Mac addresses. They're cheap as chips and save a lot of hassle. Normally they have an i2c interface.
Friends, I figured out the UID in STM - it's not a serial number, it's a mixture of production data: the position of the future chip on the plate, the plate number in the order and and the order number. Moreover, all this is in a funny mixture of formats: BCD, BIN, ASCII. Separating any part gives a high probability of getting the same values in a short period of time.
As a result, I came to the conclusion: can not use the UID, the most reliable use of EEPROM with a sector of the global OID, the easiest way is to use a locally administrable OID and form it during firmware.
stm32_get_uniqueid(uid);
crc = crc64(uid, 12);
/* Specify as localy administrated address */
priv->dev.d_mac.ether.ether_addr_octet[0] = (crc >> 0) | 0x02;
priv->dev.d_mac.ether.ether_addr_octet[0] &= ~0x1;
priv->dev.d_mac.ether.ether_addr_octet[1] = crc >> 8;
priv->dev.d_mac.ether.ether_addr_octet[2] = crc >> 16;
priv->dev.d_mac.ether.ether_addr_octet[3] = crc >> 24;
priv->dev.d_mac.ether.ether_addr_octet[4] = crc >> 32;
priv->dev.d_mac.ether.ether_addr_octet[5] = crc >> 40;
p.s. Octavo Systems, can you guys replace the 24AA32 in your SiP products with 24AA025E48 in the future? Having a MAC address preprogrammed would be very useful, and all your products have Ethernet support.
NuttX uses the CRC of the UID to get a locally administered MAC:Code: [Select]stm32_get_uniqueid(uid);
crc = crc64(uid, 12);
/* Specify as localy administrated address */
priv->dev.d_mac.ether.ether_addr_octet[0] = (crc >> 0) | 0x02;
priv->dev.d_mac.ether.ether_addr_octet[0] &= ~0x1;
priv->dev.d_mac.ether.ether_addr_octet[1] = crc >> 8;
priv->dev.d_mac.ether.ether_addr_octet[2] = crc >> 16;
priv->dev.d_mac.ether.ether_addr_octet[3] = crc >> 24;
priv->dev.d_mac.ether.ether_addr_octet[4] = crc >> 32;
priv->dev.d_mac.ether.ether_addr_octet[5] = crc >> 40;
Don't forget that the MAC doesn't have to be unique globally, locally unique within a broadcast domain is enough.
fchk
Totally unreliable. You will have a significant chance of a duplicate every few billion units.
Totally unreliable. You will have a significant chance of a duplicate every few billion units.
If the whole 48 bits are random, you'd more likely conflict with a completely different device on the same network than two of your own conflicting with each other.
You only have to worry about a Mac collision when the units are in the same subnet, no? Outside the subnet packets are routed via the gateway, not the local arp tables.
It's not quite the same as the birthday paradox, because you're only ever selecting a small fraction of the set at once, unless 77,000 of these will be installed on the same subnet, then you've got the 50% chance of a duplicate mac.
Are you aware of any specific vulnerabilities in the STM 32F4 ethernet implementation?
Is there anyone selling small blocks of MAC addresses?
Is there any downside to buying the 4096-MAC block?