This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

How to get Net-boot Working with U-Boot in am57xx-evm SDK 3.0



In SDK 2.00.01 net-booting worked perfectly. Upon migrating to SDK 3.0, we have lost this functionality. Is there additional configuration of the Ethernet hardware required to get networking support in the new u-boot?

Abbreviated U-Boot failing trace:

Net:   Could not get PHY for ethernet@48484000: addr 0

Warning: ethernet@48484000 using MAC address from ROM
eth0: ethernet@48484000
...
reading uEnv.txt
1184 bytes read in 4 ms (289.1 KiB/s)
Loaded env from uEnv.txt
Importing environment from mmc0 ...
Running uenvcmd ...
Booting from network ...
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
...

Retry time exceeded; starting again
*** ERROR: `ipaddr' not set
*** ERROR: `ipaddr' not set
Bad Linux ARM zImage magic!
switch to partitions #0, OK
mmc0 is current device
SD/MMC found on device 0
3432672 bytes read in 196 ms (16.7 MiB/s)
89665 bytes read in 65 ms (1.3 MiB/s)
Booting from mmc0 ...
...

(Once the kernel starts it finds the hardware and initializes it)
[    1.586930] cpsw 48484000.ethernet: Detected MACID = b4:99:4c:3f:87:55
[    1.594116] cpsw 48484000.ethernet: cpsw: Detected MACID = b4:99:4c:64:6b:56

We are using uEnv.txt to setup our MAC addresses for eth0 and 1.


Abbreviated trace from U-Boot from 2.00.01.11 SDK:

Net:   cpsw
Hit any key to stop autoboot:  0
switch to partitions #0, OK
mmc0 is current device
reading uEnv.txt
626 bytes read in 5 ms (122.1 KiB/s)
Importing environment from mmc0 ...
cpsw Waiting for PHY auto negotiation to complete......... done
link up on port 0, speed 1000, full duplex
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address <address> (266 ms)
link up on port 0, speed 1000, full duplex
Using cpsw device

We are using devicetree in u-boot now to describe our hardware. The ethernet nodes are the same as our kernel devicetree, and our kernel is able to initialize the hardware. Once the system is fully started, the networking hardware is functional. Only in u-boot does it seem to be non-functional.


Relevant flattened device tree sections:

aliases {
    ethernet0 = "/ocp/ethernet@48484000/slave@48480200";
    ethernet1 = "/ocp/ethernet@48484000/slave@48480300";
    ...
    
ethernet@48484000 {
    compatible = "ti,cpsw";
    ti,hwmods = "gmac";
    clocks = <0x00000022 0x000005ac>;
    clock-names = "fck", "cpts";
    cpdma_channels = <0x00000008>;
    ale_entries = <0x00000400>;
    bd_ram_size = <0x00002000>;
    no_bd_ram = <0x00000000>;
    rx_descs = <0x00000040>;
    mac_control = <0x00000020>;
    slaves = <0x00000002>;
    active_slave = <0x00000000>;
    cpts_clock_mult = <0x80000000>;
    cpts_clock_shift = <0x0000001d>;
    syscon = <0x00000004>;
    reg = <0x48484000 0x00000003 0x00000003 0x00000003>;
    #address-cells = <0x00000001>;
    #size-cells = <0x00000001>;
    interrupts = <0x00000000 0x0000014f 0x00000004 0x00000003 0x00000005 0x00000003 0x6d64696f 0x00000003 0x6176696e 0x00000004 0x00000004 0x0000000d>;
    ranges;
    status = "okay";
    dual_emac;
    mdio@48485000 {
        compatible = "ti,davinci_mdio";
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        ti,hwmods = "davinci_mdio";
        bus_freq = <0x000f4240>;
        reg = <0x48485000 0x00000124>;
        linux,phandle = <0x000000c5>;
        phandle = <0x000000c5>;
    };
    slave@48480200 {
        mac-address = [00 00 00 00 00 00];
        phy_id = <0x000000c5 0x000007b2>;
        phy-mode = "rgmii";
        dual_emac_res_vlan = <0x00000001>;
    };
    slave@48480300 {
        mac-address = [00 00 00 00 00 00];
        phy_id = <0x000000c5 0x000007b2>;
        phy-mode = "rgmii";
        dual_emac_res_vlan = <0x00000002>;
    };
    cpsw-phy-sel@4a002554 {
        compatible = "ti,dra7xx-cpsw-phy-sel";
        reg = <0x4a002554 0x000002b2>;
        reg-names = "gmii-sel";
    };
};

From what I can tell, we are not able to find our Ethernet phy based on the address we are passing to phy_connect, should we be passing an address other than zero? If so how may I determine the correct address, and where would I add that address (devicetree?) so that it would be used by u-boot?


Relevant code from: drivers/net/phy/phy.c:

#ifdef CONFIG_DM_ETH
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
                struct udevice *dev, phy_interface_t interface)
#else
struct phy_device *phy_connect(struct mii_dev *bus, int addr,
                struct eth_device *dev, phy_interface_t interface)
#endif
{
        struct phy_device *phydev;

        phydev = phy_find_by_mask(bus, 1 << addr, interface);
        if (phydev)
                phy_connect_dev(phydev, dev);
        else
                printf("Could not get PHY for %s: addr %d\n", bus->name, addr);
        return phydev;
}

struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask,
                phy_interface_t interface)
{
        /* Reset the bus */
        if (bus->reset) {
                bus->reset(bus);

                /* Wait 15ms to make sure the PHY has come out of hard reset */
                udelay(15000);
        }

        return get_phy_device_by_mask(bus, phy_mask, interface);
}

static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus,
                unsigned phy_mask, phy_interface_t interface)
{
        int i;
        struct phy_device *phydev;

        phydev = search_for_existing_phy(bus, phy_mask, interface);
        if (phydev)
                return phydev;
        /* Try Standard (ie Clause 22) access */
        /* Otherwise we have to try Clause 45 */
        for (i = 0; i < 5; i++) {
                phydev = create_phy_by_mask(bus, phy_mask,
                                i ? i : MDIO_DEVAD_NONE, interface);
                if (IS_ERR(phydev))
                        return NULL;
                if (phydev)
                        return phydev;
        }

        debug("\n%s PHY: ", bus->name);
        while (phy_mask) {
                int addr = ffs(phy_mask) - 1;
                debug("%d ", addr);
                phy_mask &= ~(1 << addr);
        }
        debug("not found\n");

        return NULL;
}

static struct phy_device *create_phy_by_mask(struct mii_dev *bus,
                unsigned phy_mask, int devad, phy_interface_t interface)
{
        u32 phy_id = 0xffffffff;
        while (phy_mask) {
                int addr = ffs(phy_mask) - 1;
                int r = get_phy_id(bus, addr, devad, &phy_id);
                /* If the PHY ID is mostly f's, we didn't find anything */
                if (r == 0 && (phy_id & 0x1fffffff) != 0x1fffffff)
                        return phy_device_create(bus, addr, phy_id, interface);
                phy_mask &= ~(1 << addr);
        }
        return NULL;
}

Thanks for any help on this,

Weston

  • Hi,

    could we have an update on the above question about network boot with u-boot from SDK3.xx for the AM57xx platform?

    Thanks,

    --Gunter

  • Hi Gunter,

    Sorry for the delayed response.

    I've asked the factory team to help on this.

    Best Regards,
    Yordan
  • For the PHY id there are two requirements, phy driver node phandle and the physical address of the PHY on the board. Assuming that you have two PHYs on the board the physical address should be unique. Please look at the arch/arm/am57xx-idk-common.dtsi as an example. The AM572 IDK has two phys addressed as 0 and 1.

    What were the numbers in the current DTS for your board intended to represent? The reason I ask is 0x7b2 the manufacturer id?

    slave@48480200 {
    mac-address = [00 00 00 00 00 00];
    phy_id = <0x000000c5 0x000007b2>; <--- this should look like this phy_id = <&davinci_mdio>, <physical address of phy>;
    phy-mode = "rgmii";
    dual_emac_res_vlan = <0x00000001>;
    };
  • Hi,


    The device tree code above is output from fdtdump, so it is what is in our DTB after compilation. We are including the am57xx-idk-common.dtsi in our board's DTS file, so that is where it should get the values for phy_id. We are not overriding them in any way (similar treatment as the am571x-idk.dts).


    I do see the part of the idk-common.dtsi file pertaining to the networking phy:

    &cpsw_emac0 {
        phy_id = <&davinci_mdio>, <0>;
        phy-mode = "rgmii";
        dual_emac_res_vlan = <1>;
    };

    &cpsw_emac1 {
        phy_id = <&davinci_mdio>, <1>;
        phy-mode = "rgmii";
        dual_emac_res_vlan = <2>;
    };


    With respect to your question regarding the phy_id numbers in our flattened device tree file, I do not know exactly what they mean, they were created by the device tree compiler, and are the same values that are created by the device tree compiler  when compiling the am571x-idk.dts file.

    Thanks for your help.

    - Weston

  • Hi Schuyler,

    it seems that the customer is including the expected dtsi and dts files, and I don't think any changes are made. Are there any other reasons why at the u-boot prompt a dhcp command should not discover an IP address?

    Hi Weston,

    can you confirm that when you are at the u-boot prompt, that a dhcp command does not discover an IP address?

    Regards,

    --Gunter

  • Gunter,

    I am able to get an ip address on the AM572x-idk from u-boot using the dhcp command. I did perform a "setenv autoload n"  command first so u-boot would not try to download the kernel.

    One thing to be aware of in u-boot is that only one port is used, port 0.

    Are there any messages on the console asking about waiting for the PHY to complete auto negotiation?

  • Hi Gunter, thanks for the replies,

    Yes, I can confirm that running the dhcp command from the u-boot prompt does not result in IP address discovery.

    Our board's u-boot trace corresponding to this is below:

    Net:   Could not get PHY for ethernet@48484000: addr 0
    Warning: ethernet@48484000 using MAC address from ROM
    eth0: ethernet@48484000
    Hit any key to stop autoboot:  0 
    => setenv autoload n
    => dhcp 
    BOOTP broadcast 1
    BOOTP broadcast 2
    BOOTP broadcast 3
    ...
    [bootp fails]

    The EVM's trace from the 2.00.02 SDK u-boot appears as follows (and the 3.0 SDK is similar):

    Net:   <ethaddr> not set. Validating first E-fuse MAC
    cpsw
    Hit any key to stop autoboot:  0 
    U-Boot# 
    U-Boot# 
    U-Boot# setenv autoload n
    U-Boot# dhcp 
    link up on port 0, speed 1000, full duplex
    BOOTP broadcast 1
    DHCP client bound to address <address> (14 ms)

    Our board running older u-boot (SDK 2.00.01):

    Net:   cpsw
    Hit any key to stop autoboot:  0 
    switch to partitions #0, OK
    mmc0 is current device
    reading uEnv.txt
    626 bytes read in 5 ms (122.1 KiB/s)
    Importing environment from mmc0 ...
    cpsw Waiting for PHY auto negotiation to complete......... done
    link up on port 0, speed 1000, full duplex
    BOOTP broadcast 1
    BOOTP broadcast 2
    DHCP client bound to address <address> (266 ms)
    link up on port 0, speed 1000, full duplex
    Using cpsw device

    Our board running newer u-boot (SDK 3.0):

    Net:   Could not get PHY for ethernet@48484000: addr 0
    Warning: ethernet@48484000 using MAC address from ROM
    eth0: ethernet@48484000
    Hit any key to stop autoboot:  0 
    switch to partitions #0, OK
    mmc0 is current device
    SD/MMC found on device 0
    reading boot.scr
    ** Unable to read file boot.scr **
    reading uEnv.txt
    1220 bytes read in 3 ms (396.5 KiB/s)
    Loaded env from uEnv.txt
    Importing environment from mmc0 ...
    Running uenvcmd ...
    Booting from network ...
    BOOTP broadcast 1
    BOOTP broadcast 2
    BOOTP broadcast 3
    ...
    [network boot failure]

    EVM newer u-boot (SDK 3.0):

    Net:   
    Warning: ethernet@48484000 using MAC address from ROM
    eth0: ethernet@48484000
    Hit any key to stop autoboot:  0 
    switch to partitions #0, OK
    mmc0 is current device
    SD/MMC found on device 0
    reading boot.scr
    ** Unable to read file boot.scr **
    reading uEnv.txt
    769 bytes read in 6 ms (125 KiB/s)
    Loaded env from uEnv.txt
    Importing environment from mmc0 ...
    Running uenvcmd ...
    Booting from network ...
    ethernet@48484000 Waiting for PHY auto negotiation to complete........ done
    link up on port 0, speed 1000, full duplex
    BOOTP broadcast 1
    BOOTP broadcast 2
    DHCP client bound to address <address> (268 ms)
    link up on port 0, speed 1000, full duplex
    Using ethernet@48484000 device

    Thanks,

    Weston