Skip to content

Commit 97b9754

Browse files
authored
Merge pull request #14838 from katherrafi/set_mac_address
Eth: STM32: Updating documentation on mbed_otp_mac_address()
2 parents 7350b03 + a9e9564 commit 97b9754

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static ETH_TxPacketConfig TxConfig;
136136

137137
#endif // ETH_IP_VERSION_V2
138138

139-
__weak uint8_t mbed_otp_mac_address(char *mac);
139+
MBED_WEAK uint8_t mbed_otp_mac_address(char *mac);
140140
void mbed_default_mac_address(char *mac);
141141

142142
#ifdef __cplusplus
@@ -852,7 +852,7 @@ void mbed_mac_address(char *mac)
852852
return;
853853
}
854854

855-
__weak uint8_t mbed_otp_mac_address(char *mac)
855+
MBED_WEAK uint8_t mbed_otp_mac_address(char *mac)
856856
{
857857
return 0;
858858
}

targets/TARGET_STM/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,40 @@ https://github.com/ARMmbed/mbed-os/blob/master/connectivity/drivers/emac/TARGET_
458458
Option is also to define your own `HAL_ETH_MspInit` function,
459459
you then have to add **USE_USER_DEFINED_HAL_ETH_MSPINIT** macro.
460460

461+
To change the default MAC address in STM32,
462+
If we have the function mbed_otp_mac_address() in the user application,the default ethernet address
463+
can be changed.
464+
Because as this is defined as weak in mbed-os/connectivity/drivers/emac/TARGET_STM/stm32xx_emac.cpp
465+
```
466+
#include "platform/mbed_toolchain.h"
467+
MBED_WEAK uint8_t mbed_otp_mac_address(char *mac).
468+
```
469+
470+
Please find the code snippet here for reference:
461471

472+
```
473+
..
474+
uint8_t mbed_otp_mac_address(char *mac);
475+
uint8_t mbed_otp_mac_address(char *mac)
476+
{
477+
unsigned char ST_mac_addr[6] = {0x00, 0x88, 0xe0,0x90,0x80,0x70}; // New User mac address
478+
// printf("%s:%s\n",__FILE__,__func__);
479+
memcpy(mac,ST_mac_addr,sizeof(ST_mac_addr));
480+
return 1;
481+
}
482+
483+
int main()
484+
{
485+
// Bring up the ethernet interface
486+
printf("Ethernet socket example\n");
487+
uint8_t MyMAC[6];
488+
printf("return of set_mac_address:%d\n",net.set_mac_address(MyMAC,sizeof(MyMAC)));
489+
490+
net.connect();
491+
printf("MAC address %s\n",net.get_mac_address());
492+
...
493+
494+
```
462495
### Asynchronous SPI limitation
463496

464497
The current Asynchronous SPI implementation will not be able to support high speeds (MHz Range).

0 commit comments

Comments
 (0)