-
Notifications
You must be signed in to change notification settings - Fork 3k
[STM32 NUCLEO] Init MAC address #2743
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -448,3 +448,31 @@ void eth_arch_disable_interrupts(void) | |
{ | ||
NVIC_DisableIRQ(ETH_IRQn); | ||
} | ||
|
||
/** This returns a unique 6-byte MAC address, based on the device UID | ||
* This function overrides hal/common/mbed_interface.c function | ||
* @param mac A 6-byte array to write the MAC address | ||
*/ | ||
void mbed_mac_address(char *mac) { | ||
unsigned char ST_mac_addr[3] = {0x00, 0x80, 0xe1}; // default STMicro mac address | ||
|
||
// Read unic id | ||
#if defined (TARGET_STM32F2) | ||
uint32_t word0 = *(uint32_t *)0x1FFF7A10; | ||
#elif defined (TARGET_STM32F4) | ||
uint32_t word0 = *(uint32_t *)0x1FFF7A10; | ||
#elif defined (TARGET_STM32F7) | ||
uint32_t word0 = *(uint32_t *)0x1FF0F420; | ||
#else | ||
#error MAC address can not be derived from target unique Id | ||
#endif | ||
|
||
mac[0] = ST_mac_addr[0]; | ||
mac[1] = ST_mac_addr[1]; | ||
mac[2] = ST_mac_addr[2]; | ||
mac[3] = (word0 & 0x00ff0000) >> 16; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how unique is the UUID and MSB, LSB? I tried this years ago and found that MSB, LSB didn't provide a great amount of randomness where in a room of 100 boards there would still be 2-5 conflicts. Ended up having to use CRC on the 128 to create 48 unique. Just some memories of bad times to avoid if not already accounted for. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unique Id is unique for each target :-) |
||
mac[4] = (word0 & 0x0000ff00) >> 8; | ||
mac[5] = (word0 & 0x000000ff); | ||
|
||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this globally assigned to ST?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is the official ST MAC address.
http://www.macmonster.co.uk/macoui=0080E1