Skip to content
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

[STM32 NUCLEO] Init MAC address #2743

Merged
merged 1 commit into from
Sep 24, 2016
Merged

Conversation

jeromecoutant
Copy link
Collaborator

Description

This patch set a MAC address depending on the target unique Id of each MCU.

Status

READY

Tests with STM32 NUCLEO boards are OK (ARM/IAR/GCC)

* @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
Copy link
Contributor

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?

Copy link
Collaborator Author

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

mac[0] = ST_mac_addr[0];
mac[1] = ST_mac_addr[1];
mac[2] = ST_mac_addr[2];
mac[3] = (word0 & 0x00ff0000) >> 16;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unique Id is unique for each target :-)
But it's true it is 96 bits...
As I set the ST Id in the 3 first MAC bytes, I checked with boards around me, and using MSB looks quite OK to get some random Id...

@sg- sg- added the needs: CI label Sep 22, 2016
@sg-
Copy link
Contributor

sg- commented Sep 22, 2016

/morph test

@sg-
Copy link
Contributor

sg- commented Sep 22, 2016

@mbed-bot: TEST

HOST_OSES=ALL
BUILD_TOOLCHAINS=ALL
TARGETS=ALL

@mbed-bot
Copy link

Result: SUCCESS

Your command has finished executing! Here's what you wrote!

/morph test

Output

mbed Build Number: 919

All builds and test passed!

@mbed-bot
Copy link

[Build 965]
SUCCESS: Building succeeded and tests were run! Be sure to check the test results

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 23, 2016

@jeromecoutant Please see the comments above about the uniqueness of mac address

@sg- sg- merged commit 363c041 into ARMmbed:master Sep 24, 2016
@sg-
Copy link
Contributor

sg- commented Sep 25, 2016

@jeromecoutant @andreaslarssonublox

There is a duplicate mbed_mac_address symbol now that #2743 and #2728 have been merged. I'll revert this for now #2808 since it seems that mbed_mac_address should be defined by a board before generically for all device given there is a WEAK version of the function.

Build failures:
18:10:59   * UBLOX_C029::ARM::TESTS-MBED_DRIVERS-STATS
18:10:59         Building project stats (UBLOX_C029, ARM)
18:10:59         Scan: ARM
18:10:59         Scan: FEATURE_IPV4
18:10:59         Scan: stats
18:10:59         Compile [100.0%]: main.cpp
18:10:59         [Warning] greentea_serial.h@13,0:  #1-D: last line of file ends without a newline
18:10:59         Link: stats
18:10:59         Error: L6200E: Symbol mbed_mac_address multiply defined (by stm32xx_emac.o and stm32f4_eth_init.o).
18:10:59         Not enough information to list the image map.
18:10:59         Finished: 1 information, 0 warning and 1 error messages.

@jeromecoutant
Copy link
Collaborator Author

@andreaslarssonublox

Do I remove mbed_mac_address function in TARGET_STM/TARGET_STM32F4/TARGET_UBLOX_C029/stm32f4_eth_init.c

or you prefer to keep your own function, and I can add
#if !defined (TARGET_UBLOX_C029)
in the generic STM32 function ?

@andreaslarssonublox
Copy link

@jeromecoutant
We would prefer to use our own MAC address.

@jeromecoutant
Copy link
Collaborator Author

Hi

I understand.
New Pull Request is on going, but I remaned your function from mbed_mac_address to mbed_otp_mac_address.

And add this in emac.c file:

void mbed_mac_address(char *mac) {
if (mbed_otp_mac_address(mac)) {
return;
} else {
mbed_default_mac_address(mac);
}
return;
}

I think it should be OK for you ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants