Setting MAC address at boot? #stm32


Anders
 

Hi,

I'm new to Zephyr and is struggling with how to configure the MAC address for the ethernet interface on an STM32F767 based platform at boot.
I have searched the internet and the Zephyr documentation for guidance but have not found anything useful.

I have managed to set the MAC address at boot by modifying the function eth_initialize in eth_stm32_hal.c but there must be another way of doing this then modifying the driver or?

Regards,
Anders


Anders
 

Update! Problem solved. The function net_if_set_link_addr() sets the MAC address.

Why isn't the function named net_if_set_mac_addr()?


Jukka Rissanen
 

Hi Anders,

there is also some info about MAC address setting in
https://github.com/zephyrproject-rtos/zephyr/discussions/39252

Note that if you are setting the MAC address from application, then
calling the net_if_set_link_addr() from app is not a proper way.

The MAC address is Ethernet concept, so we used the "link address" here
in order to use the same function in other network technologies.


Jukka

On Thu, 2021-10-28 at 23:39 -0700, Anders wrote:
Update! Problem solved. The function net_if_set_link_addr() sets the
MAC address.

Why isn't the function named net_if_set_mac_addr()?





Anders
 

Thanks for helping me figure this out!

I have tried to use the proposed, proper way of doing this using:

net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface,
&params, sizeof(struct ethernet_req_params));

Unfortunately the build will fail due to: undefined reference to `net_mgmt_NET_REQUEST_ETHERNET_SET_MAC_ADDRESS' when trying to use it.

I have added CONFIG_NET_MGMT=y to prj.conf.

Do I have to add more or could it be that my platform (nucleo_f767zi) lacks support for this feature?

/Anders


Jukka Rissanen
 

Try to add also these two settings

CONFIG_NET_MGMT_EVENT=y
CONFIG_NET_L2_ETHERNET_MGMT=y


Jukka

On Thu, 2021-11-04 at 04:41 -0700, Anders wrote:
Thanks for helping me figure this out!

I have tried to use the proposed, proper way of doing this using:

net_mgmt(NET_REQUEST_ETHERNET_SET_MAC_ADDRESS, iface,
                       &params, sizeof(struct ethernet_req_params));

Unfortunately the build will fail due to: undefined reference to
`net_mgmt_NET_REQUEST_ETHERNET_SET_MAC_ADDRESS' when trying to use
it.

I have added CONFIG_NET_MGMT=y to prj.conf.

Do I have to add more or could it be that my platform (nucleo_f767zi)
lacks support for this feature?

/Anders





Anders
 

Hi again Jukka,

Thank you! Setting of MAC works fine now.

The CONFIG_NET_L2_ETHERNET_MGMT parameter did the trick!

/Anders