mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 01:05:54 +08:00
stm32h7:ethernet Use UUID for MAC
This commit is contained in:
committed by
David Sidrane
parent
154a87993f
commit
31bb58548d
@@ -55,6 +55,7 @@
|
||||
#include "stm32_gpio.h"
|
||||
#include "stm32_rcc.h"
|
||||
#include "stm32_ethernet.h"
|
||||
#include "stm32_uid.h"
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
@@ -4356,6 +4357,8 @@ static inline int stm32_ethinitialize(int intf)
|
||||
#endif
|
||||
{
|
||||
struct stm32_ethmac_s *priv;
|
||||
uint8_t uid[12];
|
||||
uint64_t crc;
|
||||
|
||||
ninfo("intf: %d\n", intf);
|
||||
|
||||
@@ -4386,6 +4389,20 @@ static inline int stm32_ethinitialize(int intf)
|
||||
priv->txpoll = wd_create(); /* Create periodic poll timer */
|
||||
priv->txtimeout = wd_create(); /* Create TX timeout timer */
|
||||
|
||||
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;
|
||||
|
||||
/* Configure GPIO pins to support Ethernet */
|
||||
|
||||
stm32_ethgpioconfig(priv);
|
||||
|
||||
Reference in New Issue
Block a user