Skip to content

Commit b7dbb74

Browse files
committed
drivers: ethernet: stm32hal: Fixes source address control
The default configuration for all STM32 microcontrollers in HAL is to replace the ehternet MAC address with the address configured in replace address zero. In "modules/hal", Grep for: macDefaultConf.SourceAddrControl = ETH_SOURCEADDRESS_REPLACE_ADDR0; But this is a bad thing for bridging. Since Zephyr ethernet LL code always writes the source address, this patch has no impact on normal operation. And has the benefit of maintaining the source MAC address of bridged packets. Signed-off-by: Marcelo Roberto Jimenez <marcelo.jimenez@gmail.com>
1 parent 9c1fbc8 commit b7dbb74

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

drivers/ethernet/eth_stm32_hal_v1.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,11 @@ void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *s
239239

240240
heth->Init.Speed = PHY_LINK_IS_SPEED_100M(state->speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
241241

242+
/* The default configuration is ETH_SOURCEADDRESS_REPLACE_ADDR0,
243+
* which is bad for bridging.
244+
*/
245+
mac_config.SourceAddrControl = ETH_SOURCEADDRESS_DISABLE;
246+
242247
hal_ret = HAL_ETH_ConfigMAC(heth, NULL);
243248
if (hal_ret != HAL_OK) {
244249
LOG_ERR("HAL_ETH_ConfigMAC: failed: %d", hal_ret);

drivers/ethernet/eth_stm32_hal_v2.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,11 @@ void eth_stm32_set_mac_config(const struct device *dev, struct phy_link_state *s
664664
PHY_LINK_IS_SPEED_1000M(state->speed) ? ETH_SPEED_1000M :)
665665
PHY_LINK_IS_SPEED_100M(state->speed) ? ETH_SPEED_100M : ETH_SPEED_10M;
666666

667+
/* The default configuration is ETH_SOURCEADDRESS_REPLACE_ADDR0,
668+
* which is bad for bridging.
669+
*/
670+
mac_config.SourceAddrControl = ETH_SOURCEADDRESS_DISABLE;
671+
667672
hal_ret = HAL_ETH_SetMACConfig(heth, &mac_config);
668673
if (hal_ret != HAL_OK) {
669674
LOG_ERR("HAL_ETH_SetMACConfig failed: %d", hal_ret);

0 commit comments

Comments
 (0)