2014年10月12日 星期日

{Banana Pi][U-Boot][Sunxi] Error: Can't overwrite "ethaddr" in Every Boot


===murmur begin===

If Banana Pi wants to compete with Raspberry Pi, it definetely needs more harder work to improve quality of DVK.
===murmur end===

You may found that there is an annoyed problem after you "save env" to store environment variables to u-boot, instead of using defaults. Everytime you boot Banana pi, you will find error message of error of overwrittng ethaddr.

U-Boot 2014.04-10694-g2ae8b32-dirty (Oct 01 2014 - 16:23:27) Allwinner Technology

CPU:   Allwinner A20 (SUN7I)
Board: Bananapi
I2C:   ready
DRAM:  1 GiB
MMC:   SUNXI SD/MMC: 0
In:    serial
Out:   serial
Err:   serial
## Error: Can't overwrite "ethaddr"
## Error inserting "ethaddr" variable, errno=1
Net:   dwmac.1c50000
Hit any key to stop autoboot:  0
This is caused by the last commit of board/sunxi/board.c to "Fix the problem that the mac address under u-boot can not change on d…", enclosed by "CONFIG_BANANAPI". With this patch, ethaddr will be set during every system boot up, regardless ethaddr exist or not.

To fix it, you may either comment out the block of this change, or simply adding a if-statement to ensure the ethaddr setting is only performed if it cannot be found in nvram. (though I think it would be always true since it is checked in the beginning of this function)

else {
    unsigned char *p;
    p = getenv("ethaddr");
    uint32_t reg_val = readl(SUNXI_SID_BASE);

    if ((p == NULL) && reg_val) {
        uint8_t mac_addr[6];
        int i;

        mac_addr[0] = 0x02; /* Non OUI / registered MAC address */
        mac_addr[1] = (reg_val >> 0) & 0xff;
        reg_val = readl(SUNXI_SID_BASE + 0x0c);
        mac_addr[2] = (reg_val >> 24) & 0xff;
        mac_addr[3] = (reg_val >> 16) & 0xff;
        mac_addr[4] = (reg_val >> 8) & 0xff;
        mac_addr[5] = (reg_val >> 0) & 0xff;

        for(i = 0; i < 6; i ++)
        {
                if(mac_addr[i] != *(p + i)){
                eth_setenv_enetaddr("ethaddr", mac_addr);
                break;
        }
    }

}










沒有留言:

張貼留言