Altera_Forum
Honored Contributor
13 years agoUnique MAC address without using a flash memory and without prompting the user?
Dear Sirs,
I am facing a little challenge with MAC addresses here. The default way of assigning a MAC address is by reading it from flash memory. Below is an example (fromnios2eds/examples/software/web_server_rgmii/network_utilities.c): error_t get_board_mac_addr(unsigned char mac_addr)
{
error_t error = 0;
alt_u32 signature;
/* Get the flash sector with the MAC address. */
error = FindLastFlashSectorOffset(&last_flash_sector_offset);
if (!error)
last_flash_sector = EXT_FLASH_BASE + last_flash_sector_offset;
/* This last_flash_sector region of flash is examined to see if
* valid network settings are present, indicated by a signature of 0x00005afe at
* the first address of the last flash sector. This hex value is chosen as the
* signature since it looks like the english word "SAFE", meaning that it is
* safe to use these network address values.
*/
if (!error)
{
signature = IORD_32DIRECT(last_flash_sector, 0);
if (signature != 0x00005afe)
{
error = generate_and_store_mac_addr();
}
}
if (!error)
{
mac_addr = IORD_8DIRECT(last_flash_sector, 4);
mac_addr = IORD_8DIRECT(last_flash_sector, 5);
mac_addr = IORD_8DIRECT(last_flash_sector, 6);
mac_addr = IORD_8DIRECT(last_flash_sector, 7);
mac_addr = IORD_8DIRECT(last_flash_sector, 8);
mac_addr = IORD_8DIRECT(last_flash_sector, 9);
printf("Your Ethernet MAC address is %02x:%02x:%02x:%02x:%02x:%02x\n",
mac_addr,
mac_addr,
mac_addr,
mac_addr,
mac_addr,
mac_addr);
}
return error;
}
If that fails, then a user is prompted for the board serial number to generate MAC address. Is there any other way? What I am trying to do here is not to use a flash memory, and not to prompt the user for anything. My setup is the following: 1) Arria II GX 6G board 2) Marvell 88E1111 10/100/1000 PHY 3) TSE 4) Two streaming mSGDMA instances (one for read/one for write). 5) PCIe IP Core The board is controlled by the host over PCIe. I was wondering if there is some sort of unique PCIe device serial number, or maybe PHY has something unique in it so that I can access it using MDIO? Any hints/ideas are very much appreciated. Thanks!