summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-04-05 22:37:06 +1100
committerDamien George <damien.p.george@gmail.com>2019-04-05 22:37:06 +1100
commitfd523c53c37b36a9c343b1061d08e65e920dffa0 (patch)
treeb3ac52d54e3b23a2f6f48e22bf5049628b3f21aa
parent4f936afc441da48ab8043ec108a2a2f6a92fdd6e (diff)
stm32/network_wiznet5k: Automatically set MAC if device doesn't have one
-rw-r--r--ports/stm32/network_wiznet5k.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/ports/stm32/network_wiznet5k.c b/ports/stm32/network_wiznet5k.c
index e0fc5d5ba..3bbe639ac 100644
--- a/ports/stm32/network_wiznet5k.c
+++ b/ports/stm32/network_wiznet5k.c
@@ -128,6 +128,14 @@ STATIC void wiznet5k_init(void) {
// Seems we need a small delay after init
mp_hal_delay_ms(250);
+ // If the device doesn't have a MAC address then set one
+ uint8_t mac[6];
+ getSHAR(mac);
+ if ((mac[0] | mac[1] | mac[2] | mac[3] | mac[4] | mac[5]) == 0) {
+ mp_hal_get_mac(MP_HAL_MAC_ETH0, mac);
+ setSHAR(mac);
+ }
+
// Hook the Wiznet into lwIP
wiznet5k_lwip_init(&wiznet5k_obj);
}