diff --git a/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp b/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp index 801caa30fe..827c58f5db 100644 --- a/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp +++ b/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp @@ -136,7 +136,7 @@ static ETH_TxPacketConfig TxConfig; #endif // ETH_IP_VERSION_V2 -__weak uint8_t mbed_otp_mac_address(char *mac); +MBED_WEAK uint8_t mbed_otp_mac_address(char *mac); void mbed_default_mac_address(char *mac); #ifdef __cplusplus @@ -852,7 +852,7 @@ void mbed_mac_address(char *mac) return; } -__weak uint8_t mbed_otp_mac_address(char *mac) +MBED_WEAK uint8_t mbed_otp_mac_address(char *mac) { return 0; } diff --git a/targets/TARGET_STM/README.md b/targets/TARGET_STM/README.md index 245a93f666..f4ba7e53dd 100644 --- a/targets/TARGET_STM/README.md +++ b/targets/TARGET_STM/README.md @@ -458,7 +458,40 @@ https://github.com/ARMmbed/mbed-os/blob/master/connectivity/drivers/emac/TARGET_ Option is also to define your own `HAL_ETH_MspInit` function, you then have to add **USE_USER_DEFINED_HAL_ETH_MSPINIT** macro. +To change the default MAC address in STM32, +If we have the function mbed_otp_mac_address() in the user application,the default ethernet address +can be changed. +Because as this is defined as weak in mbed-os/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp +``` +#include "platform/mbed_toolchain.h" +MBED_WEAK uint8_t mbed_otp_mac_address(char *mac). +``` +Please find the code snippet here for reference: + +``` +.. +uint8_t mbed_otp_mac_address(char *mac); +uint8_t mbed_otp_mac_address(char *mac) +{ + unsigned char ST_mac_addr[6] = {0x00, 0x88, 0xe0,0x90,0x80,0x70}; // New User mac address + // printf("%s:%s\n",__FILE__,__func__); + memcpy(mac,ST_mac_addr,sizeof(ST_mac_addr)); + return 1; +} + +int main() +{ + // Bring up the ethernet interface + printf("Ethernet socket example\n"); + uint8_t MyMAC[6]; + printf("return of set_mac_address:%d\n",net.set_mac_address(MyMAC,sizeof(MyMAC))); + + net.connect(); + printf("MAC address %s\n",net.get_mac_address()); +... + +``` ### Asynchronous SPI limitation The current Asynchronous SPI implementation will not be able to support high speeds (MHz Range).