[A20-SOM204] In new A20-SOM204-1G-M module emac does not recognize MAC address

Started by dpierleo, June 08, 2020, 12:53:58 PM

Previous topic - Next topic

dpierleo

Hi,
we are using a A20-SOM204-1G-M module, the new version without Gigabit PHY and with only the Megabit PHY mounted.
We boot the SOM with the official Olimex mainline image Armbian_5.92.4_Olinuxino-a20_Ubuntu_bionic_next_5.2.21_desktop and we apply the overlay sun7i-a20-som204-emac.dts for enabling emac and disabling gmac.

The wrong behaviour that we obtain is that the emac driver does not recognize the MAC address during the kernel startup. The message:

[    2.968281] sun4i-emac 1c0b000.ethernet: using random MAC address f2:e1:6d:91:3f:5d

appears in the screen during kernel startup (we can see that using command dmesg).

Every time I reboot the system, the MAC address is reassigned differently and it is never the same. In this way also IP address is always different because dhcp does not work correctly.

I verified that in the eeprom is written the right MAC address: using command

olinuxino config info

in bootloader shell, I obtain the text:

MAC:   30:1F:9A:D0:8D:38

that is copied in boot environment variable mac_addr.

How can I solve the problem? How can I make emac driver able to recognize the right MAC address during startup?

Thank you in advance for your help.


LubOlimex

olinuxino config write XXX c 11112222 aa:bb:cc:dd:ee:ff
Reset the board with command:

reset
and inspect whether the MAC .

There are two important things to consider if there is still a problem:

1) You need to enter a IEEE-valid MAC address with MULTICAST bit set to 0. For example, MAC addresses that start with 11 are not valid (if you tested with 11:22:33:44:55:66 this is a problem) but those that start with 12 or 22 are valid. If the MAC address is not valid a random valid MAC address would be generated and there would be a discrepancy between what you typed (what is printed in the beginning of the boot) and what is seen with ifconfig once logged.

2) You might need to explore the SD card with the image and delete uboot.env in folder /boot - try this if the address that you set is valid but doesn't appear once you are logged.

3) If the issue remains try the following in u-boot:

env del -f ethaddr
and then:

saveenv
4) If the issue persists maybe try using the latest Olimage from here:

https://olimex.wordpress.com/2020/04/21/olimage-mainline-linux-images-building-script-for-all-of-our-olinuxino-and-som-boards/
Technical support and documentation manager at Olimex

dpierleo

Hi LubOlimex,

thank you for your answer.

I tried to do everything you suggested me but unfortunately nothing is changed and the problem remains.

Anyway the problem is not that MAC address is missing in the eeprom: MAC address is already present in the eeprom and it is valid too (in the eeprom there is the original MAC address given by Olimex 30:1F:9A:D0:8D:38 togheter with the som).

I understood that your first suggestions to solve the problem are useful to write MAC address in the eeprom but, in our case, the MAC address is already present and valid and I do not need to write it with olinuxino config write.

I also deleted file uboot.env but that file is re-created at the next startup and the new file is perfectly the same that the old one.

I also removed the environment variable ethaddr but without any improvement: the problem remains and, at the kernel startup, the emac driver generate a new random MAC address. Moreover if I run command printenv ethaddr in bootloader, I receive ethaddr=30:1F:9A:D0:8D:38 that is the right value present in eeprom.

So all seems to be right until the kernel... the problem seems to be an emac driver issue.

We are at the end of our job and I would not like to change our image (Armbian based) to avoid additional issues.

Is there any other solution?

Thank you in advance

LubOlimex

There are many ways to force MAC address after boot. If you don't want to touch the EEPROM, you can overwrite the MAC manually upon boot. After the board boots edit /etc/network/interfaces with the MAC that you want to force. Like

hwaddress ether xx:xx:xx:xx

You can add it in the bashrc to check if it is properly set or to load upon each boot.

Also you should check for similar questions in Armbian forums, maybe some other solution can be found, for example here:

https://forum.armbian.com/topic/4239-opi-zero-mac-address-issue-on-mainline-kernel/
Technical support and documentation manager at Olimex

dpierleo

Is it possible to read from Linux after startup (using some shell command), the MAC address written in eeprom or in ethaddr (boot environment variable)?

LubOlimex

Technical support and documentation manager at Olimex