cancel
Showing results for 
Search instead for 
Did you mean: 

Ethernet MAC address Not set stm32mp255 custom board

asadullah4571
Senior

Dear ST Team,

We have recently completed production on our custom STM32MP255-based hardware. During validation, we encountered an issue with the Ethernet MAC address handling.

We have successfully programmed the MAC addresses into OTP (via the NVMEM interface), and confirmed the values are correctly stored in the fuses (words 247–249). However, both U-Boot and Linux are not retrieving the MAC addresses from OTP automatically. Instead, we observe errors such as:

Loading Environment from MMC... OK
In: serial
Out: serial
Err: serial
Net:
Error: eth2@482d0000 address not set.

Error: eth1@482c0000 address not set.

Error: eth2@482d0000 address not set.
No ethernet found.

Card did not respond to voltage select! : -110
No EFI system partition
No EFI system partition
Failed to persist EFI variables

Error: eth2@482d0000 address not set.

Error: eth1@482c0000 address not set.
Hit any key to stop autoboot: 0
STM32MP> fuse read 0 247
Reading bank 0:

Word 0x000000f7: cd641f8c
STM32MP> fuse read 0 248
Reading bank 0:

Word 0x000000f8: 1f8c0270
STM32MP> fuse read 0 249
Reading bank 0:

Word 0x000000f9: 0370cd64
STM32MP>

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @asadullah4571 ,
This first point concerning the swith case is indeed really strange, certainly a miss. Can you try to patch and add your own case for CPU_STM32MP255Xxx (I do not know your exact revision). I think this is a miss on our side.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

5 REPLIES 5
Erwan SZYMANSKI
ST Employee

Hello @asadullah4571 ,
Could you please add a log trace in the following U-Boot file: arch/arm/mach-stm32mp/soc.c in function setup_mac_address(..)
The idea would just be to ensure that you are passing through it, and check what are the results got from this function.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Erwan SZYMANSKI 
I made the changes on the function setup_mac_address(..), then i got the log trace. if any changes required for logs please let me know , will do changes. and there is more thing that inside the int get_eth_nb(void)" there is no information about the SOC "stm32mp255 series " here is content 

int get_eth_nb(void)
{
int nb_eth;
 
switch (get_cpu_type()) {
case CPU_STM32MP257Fxx:
fallthrough;
case CPU_STM32MP257Dxx:
fallthrough;
case CPU_STM32MP257Cxx:
fallthrough;
case CPU_STM32MP257Axx:
nb_eth = 5; /* dual ETH with TSN support */
break;
case CPU_STM32MP253Fxx:
fallthrough;
case CPU_STM32MP253Dxx:
fallthrough;
case CPU_STM32MP253Cxx:
fallthrough;
case CPU_STM32MP253Axx:
nb_eth = 2; /* dual ETH */
break;
case CPU_STM32MP251Fxx:
fallthrough;
case CPU_STM32MP251Dxx:
fallthrough;
case CPU_STM32MP251Cxx:
fallthrough;
case CPU_STM32MP251Axx:
nb_eth = 1; /* single ETH */
break;
default:
nb_eth = 0;
break;
}
 
return nb_eth;
}

 

here is the logs and changes 

setup_mac_address: entering setup_mac_address()
setup_mac_address: detected 0 ethernet interfaces
Net:
Error: eth2@482d0000 address not set.

Error: eth1@482c0000 address not set.

Error: eth2@482d0000 address not set.
No ethernet found.

Card did not respond to voltage select! : -110
No EFI system partition
No EFI system partition
Failed to persist EFI variables

Error: eth2@482d0000 address not set.

Error: eth1@482c0000 address not set.
Hit any key to stop autoboot: 0
Boot over usb0!
DFU alt info setting: done


 

__weak int setup_mac_address(void)
{
int ret;
int i;
u32 otp[MAX_NB_OTP];
uchar enetaddr[ARP_HLEN];
struct udevice *dev;
int nb_eth, nb_otp, index;

/* --- TRACE START --- */
printf("%s: entering setup_mac_address()\n", __func__);
/* --- TRACE END --- */

if (!IS_ENABLED(CONFIG_NET))
return 0;

nb_eth = get_eth_nb();
printf("%s: detected %d ethernet interfaces\n", __func__, nb_eth);
if (!nb_eth)
return 0;

/* 6 bytes for each MAC addr and 4 bytes for each OTP */
nb_otp = DIV_ROUND_UP(ARP_HLEN * nb_eth, 4);
printf("%s: nb_otp=%d (max=%d)\n", __func__, nb_otp, MAX_NB_OTP);

if (nb_otp > MAX_NB_OTP) {
log_err("invalid number of OTP = %d, max = %d\n", nb_otp, MAX_NB_OTP);
return -EINVAL;
}

ret = uclass_get_device_by_driver(UCLASS_MISC,
DM_DRIVER_GET(stm32mp_bsec),
&dev);
if (ret) {
printf("%s: uclass_get_device_by_driver() failed ret=%d\n", __func__, ret);
return ret;
}

ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_MAC), otp, 4 * nb_otp);
if (ret < 0) {
printf("%s: misc_read() failed ret=%d\n", __func__, ret);
return ret;
}

printf("%s: misc_read() success, dumping raw otp values:\n", __func__);
for (i = 0; i < nb_otp; i++)
printf(" otp[%d] = 0x%08x\n", i, otp[i]);

for (index = 0; index < nb_eth; index++) {
/* MAC already in environment */
if (eth_env_get_enetaddr_by_index("eth", index, enetaddr)) {
printf("%s: MAC already set for eth%d, skipping\n", __func__, index);
continue;
}

for (i = 0; i < ARP_HLEN; i++)
enetaddr[i] = ((uint8_t *)&otp)[i + ARP_HLEN * index];

printf("%s: candidate MAC for eth%d = %pM\n", __func__, index, enetaddr);

/* skip FF:FF:FF:FF:FF:FF */
if (is_broadcast_ethaddr(enetaddr)) {
printf("%s: MAC for eth%d is broadcast, skipping\n", __func__, index);
continue;
}

if (!is_valid_ethaddr(enetaddr)) {
log_err("invalid MAC address %d in OTP %pM\n", index, enetaddr);
return -EINVAL;
}

log_debug("OTP MAC address %d = %pM\n", index, enetaddr);
ret = eth_env_set_enetaddr_by_index("eth", index, enetaddr);
if (ret) {
log_err("Failed to set mac address %pM from OTP: %d\n",
enetaddr, ret);
return ret;
}

printf("%s: successfully set eth%d MAC to %pM\n",
__func__, index, enetaddr);
}

printf("%s: finished successfully\n", __func__);
return 0;
}
 
 
 

Hello @asadullah4571 ,
This first point concerning the swith case is indeed really strange, certainly a miss. Can you try to patch and add your own case for CPU_STM32MP255Xxx (I do not know your exact revision). I think this is a miss on our side.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Hi @Erwan SZYMANSKI 
Thanks for the quick reply,
I already did from my side. and i got the Proper result.

Here i attached the Patch file, and it is works well.
setup_mac_address: entering setup_mac_address()
setup_mac_address: detected 2 ethernet interfaces
setup_mac_address: nb_otp=3 (max=8)
setup_mac_address: misc_read() success, dumping raw otp values:
otp[0] = 0xXXXX
otp[1] = 0xXXXX
otp[2] = 0xXXXX
setup_mac_address: candidate MAC for eth0 = XX:XX:XX:XX:XX:XX
setup_mac_address: successfully set eth0 MAC to XX:XX:XX:XX:XX:XX
setup_mac_address: candidate MAC for eth1 = XX:XX:XX:XX:XX:XX
setup_mac_address: successfully set eth1 MAC to XX:XX:XX:XX:XX:XX
setup_mac_address: finished successfully
Net: eth1: eth1@482c0000, eth0: eth2@482d0000
Card did not respond to voltage select! : -110
No EFI system partition
No EFI system partition
Failed to persist EFI variables
Hit any key to stop autoboot: 0
STM32MP>


Thanks again @Erwan SZYMANSKI .

Hi @asadullah4571 ,
Thanks a lot for this quick test. We will correct this on our side for the upstream version.

Kind regards,
Erwan.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.