STM32MP157C Odyssey - Ethernet Support in U-Boot

I have been working through some embedded Linux tutorials and am trying to build my own bootloaders, Linux kernel, and init system for this board as a learning exercise.

I successfully got TF-A and U-boot compiled and running on this board using the stm32mp157c-odyssey device tree file included in the U-boot repo. However, the onboard Ethernet hardware on this board does not appear to work from within U-boot. I would like to be able to upload files to the board via TFTP from within U-boot and not have to rewrite a flash card every time I make a software change.

The onboard Ethernet does work if I boot into the pre-compiled Debian distro that Seeed provides for this board, so I know there are functional drivers and device tree definitions somewhere; I’m just not knowledgeable enough at this point to know what to change in my setup to get it working in my build of U-boot.

Does anyone have any helpful hints to point me in the right direction?

Thanks!

Hi there,

So If Ethernet stopped working after an upgrade + U-Boot change on the STM32MP157C Odyssey running Debian Linux, the issue is likely related to device tree (DTB), U-Boot network initialization, or missing drivers.

:small_blue_diamond: 1. Check if the Ethernet Interface Still Exists

Run:

ip link show

or

ifconfig -a
  • If eth0 is missing, the kernel isn’t detecting the Ethernet hardware.
  • If eth0 is present but “DOWN”, try bringing it up:
sudo ip link set eth0 up
sudo dhclient eth0  # Request an IP address

:small_blue_diamond: 2. Check U-Boot Environment for Ethernet Config

Since you changed U-Boot, check if Ethernet initialization is disabled in the U-Boot environment.

In the U-Boot command line (Hit any key to stop autoboot):

printenv

Look for network-related variables, such as:

ethaddr=xx:xx:xx:xx:xx:xx  # MAC Address
ipaddr=192.168.x.x
serverip=192.168.x.x
ethact=stm32mp1-eth  # Network interface name

If missing, manually set them:

setenv ethact stm32mp1-eth
setenv ipaddr 192.168.1.100
setenv serverip 192.168.1.1
saveenv

Then reboot.


:small_blue_diamond: 3. Check Device Tree (DTB) Configuration

If the precompiled Debian Linux had working Ethernet, but the upgrade broke it, the new DTB might be missing Ethernet configurations.

Find your DTB:

ls /boot/dtb/ | grep stm32

or check the currently used DTB:

cat /proc/device-tree/model

Compare it with the previous working version. If the Ethernet node is missing, re-enable it:

Those are some suggestions…
HTH

GL :slight_smile: PJ :v:

Hi PJ, thank you for your advice.

To clarify, I have been booting my devboard from 2 different SD cards: one has the Seeed build of Debian on it, and the other card just has a U-boot environment that I compiled myself (no kernel yet).

  1. When I boot from the Debian card, Ethernet works fine once the Linux kernel loads. If I pause the boot process and try to use Ethernet from within the U-boot environment, it does not work. It appears that networking is not enabled in this build of U-boot. There are no MAC addresses or IP addresses set, and the “net” command is not present.

  2. When I boot from the SD card that has my build of U-boot on it, even if I set those environment variables, Ethernet does not work. I have U-boot configured to assign a random MAC address and I have the board’s IP address set to 192.168.2.2. I have it connected to my PC with IP address 192.168.2.1. If I try to ping my PC, it times out. I do see the activity LED blink on and off on the Ethernet jack on the board when I issue the ping command, but if I run Wireshark on my PC, it doesn’t see any packets originating from my board’s MAC address.

  3. I suspect the problem is with the device tree configuration that I am using when I build U-boot. If I take a look at the working configuration under Debian, here’s what I see:

debian@npi:~$ cat /proc/device-tree/model
Seeed NPi STM32MP157C Board

If I mount the boot partition and search for that string, here’s what I find:

debian@npi:/mnt$ grep -r "Seeed NPi STM32MP157C Board" 
Binary file dtbs/4.19.9-stm32-r1/stm32mp1-seeed-npi-base.dtb matches
Binary file dtbs/4.19.9-stm32-r1/stm32mp1-seeed-npi-full.dtb matches

I tried to copy the npi-full dtb file into my u-boot/arch/arm/dts directory and tried building U-boot with the command “make DEVICE_TREE=stm32mp157c-seeed-npi-full”, but I get an error message:

Device Tree Source (arch/arm/dts/stm32mp157c-seeed-npi-full.dtb) is not correctly specified.
Please define 'CONFIG_DEFAULT_DEVICE_TREE'
or build with 'DEVICE_TREE=<device_tree>' argument

I tried decompiling the dtb back to a dts file, and I still get that error message.

Does anyone have any idea how I could get U-boot to build with this device tree config?

Hi there,

Looks to be a good topic, not much ethernet here. :crossed_fingers:
looks like If the net command is missing in U-Boot, the build likely does not include networking support. Check the U-Boot build config:

grep CONFIG_CMD_NET u-boot/.config

It should output:

CONFIG_CMD_NET=y

If it is missing, enable it by adding the following to u-boot/configs/stm32mp157c_defconfig:

CONFIG_CMD_NET=y
CONFIG_CMD_PING=y
CONFIG_CMD_DHCP=y
CONFIG_CMD_MII=y
CONFIG_NET_RANDOM_ETHADDR=y

Then, rebuild U-Boot.

HTH

GL :slight_smile: PJ :v:

I see this on the DTB issue.
Device Tree Source is not correctly specified.
This means U-Boot is not recognizing this DTB name. The fix is:

Ensure the DTB is correctly named in U-Boot’s source tree

Copy the correct DTB source into U-Boot:

cp arch/arm/dts/stm32mp1-seeed-npi-full.dtb u-boot/arch/arm/dts/
If stm32mp1-seeed-npi-full.dts does not exist, try decompiling it:

dtc -I dtb -O dts -o stm32mp1-seeed-npi-full.dts stm32mp1-seeed-npi-full.dtb
cp stm32mp1-seeed-npi-full.dts u-boot/arch/arm/dts/
Manually set CONFIG_DEFAULT_DEVICE_TREE

Edit: u-boot/configs/stm32mp157c_defconfig and set:

CONFIG_DEFAULT_DEVICE_TREE=“stm32mp1-seeed-npi-full”
Ensure U-Boot builds with the correct DTB

Rebuild U-Boot:

make distclean
make stm32mp157c_defconfig
make DEVICE_TREE=stm32mp1-seeed-npi-full -j$(nproc)

YMMV :+1:
Even with the correct DTB, U-Boot might not have the Ethernet driver enabled.
Check if CONFIG_STM32MP1_ETH is enabled:

grep CONFIG_STM32MP1_ETH u-boot/.config

If missing, enable it in u-boot/configs/stm32mp157c_defconfig:

CONFIG_DM_ETH=y
CONFIG_PHYLIB=y
CONFIG_PHY_REALTEK=y
CONFIG_NETDEVICES=y
CONFIG_STM32MP1_ETH=y

Then rebuild U-Boot.

After flashing the new U-Boot build:

Test Ethernet in u-boot

setenv ethaddr 00:11:22:33:44:55
setenv ipaddr 192.168.2.2
setenv serverip 192.168.2.1
saveenv
dhcp
ping 192.168.2.1

If it still fails…try

mii info
mdio list
This will check if the Ethernet PHY is detected.

lmk if and where it gets stuck. :v:

Hi PJ,

The version of U-boot without the net command is the pre-compiled one supplied by Seeed. I don’t have access to the source or config files, so I can’t modify and recompile it.

The version of U-boot that I compiled from scratch does have the net command. I enabled the Micrel KSZ09x1 PHY driver because that’s the chip on the Odyssey board. There is no Realtek PHY on this Odyssey board. I also enabled RGMII drivers, since it appears that is the communication interface used between the PHY and STM MPU.

Here’s the info U-boot provides about mii and mdio devices:

STM32MP> mii info
PHY 0x07: OUI = 0x0885, Model = 0x22, Rev = 0x02, 1000baseT, FDX
STM32MP> mdio list
ethernet@5800a000:
7 - Micrel ksz9031 <--> ethernet@5800a000

I still haven’t been able to get that stm32mp1-seeed-npi device tree file to work. Whether I use the compiled dtb or the source dts, it’ll return errors.

I even tried modifying the working device tree file (stm32mp157c-odyssey.dts) by copying changing its Ethernet section to match what was in the seeed-npi device tree file, but it looks like there’s some low-level setup that’s different because I get warnings when compiling it and I get errors in U-boot.

DTB compiler warnings:

arch/arm/dts/stm32mp157c-odyssey.dtb: Warning (clocks_property): /soc/ethernet@5800a000: Missing property '#clock-cells' in node /soc/efuse@5c005000/part-number-otp@4 or bad phandle (referred from clocks[0])
arch/arm/dts/stm32mp157c-odyssey.dtb: Warning (interrupts_extended_property): /soc/ethernet@5800a000: Missing property '#interrupt-cells' in node /cpu0-opp-table or bad phandle (referred from interrupts-extended[0])
arch/arm/dts/stm32mp157c-odyssey.dtb: Warning (power_domains_property): /soc/ethernet@5800a000: Missing property '#power-domain-cells' in node /soc/pinctrl@50002000/i2c2-sleep-0 or bad phandle (referred from power-domains[0])

U-boot errors:

Net:   eth_eqos ethernet@5800a000: pinctrl_select_state_full: uclass_get_device_by_phandle_id: err=-19
No ethernet found.

Hi there,

Dam , Seeed :grin: I guess they thought anyone would want to update the thing, Jeeez…
So I ran tis in the AI and here is what It thinks.

What Works and What Doesn’t?

:white_check_mark: Precompiled U-Boot (from Seeed)Does NOT have the net command.
:white_check_mark: User-compiled U-BootHas net command but no working Ethernet
:white_check_mark: Correct PHY driver enabled (Micrel KSZ9031)
:white_check_mark: Using RGMII (Correct interface for STM32MP1)

:rotating_light: Issue: Device Tree (DTB) configuration is incorrect, causing:

  • U-Boot warnings in DTB compilation (clocks, interrupts, power domains)
  • U-Boot Ethernet fails to initialize (No ethernet found)

It’s fairly accurate on Errors in the compiler so I checked and verified the warnings are interpreted correctly.

  • The Ethernet node in the device tree is missing required clock definitions.
  • STM32MP1 requires a reference clock for EQOS Ethernet.

:small_blue_diamond: Fix: Modify the Ethernet node (ethernet@5800a000) to include the correct clock reference:

ethernet@5800a000 {
    compatible = "st,stm32mp1-dwmac";
    reg = <0x5800a000 0x2000>;
    interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>;
    interrupt-names = "macirq";
    clocks = <&rcc ETHMAC>;
    clock-names = "stmmaceth";
    status = "okay";
};
  • The Ethernet MAC is missing a proper interrupt configuration.

:small_blue_diamond: Fix: Modify the interrupts-extended property in the ethernet@5800a000 node:

interrupts-extended = <&exti 72 IRQ_TYPE_LEVEL_HIGH>;
  • The device tree is missing a power domain reference for Ethernet.

:small_blue_diamond: Fix: Ensure the Ethernet node includes:

power-domains = <&pd_core>;

Why Is No Ethernet Found in U-Boot?
Answer:

Possible Causes:

  1. Incorrect Pinmux (GPIOs not configured properly for Ethernet MAC & PHY)
  2. Clock, Interrupt, or Power Domain Issues in the DTB
  3. PHY Reset GPIO Not Configured
  4. MDIO Not Properly Linked to the PHY Driver
  5. U-Boot Environment Variables Not Configured for Ethernet

Update the stm32mp157c-odyssey.dts file:

&ethernet0 {
    status = "okay";
    pinctrl-names = "default", "sleep";
    pinctrl-0 = <&ethernet0_pins_a>;
    pinctrl-1 = <&ethernet0_pins_sleep_a>;
    phy-mode = "rgmii";
    phy-handle = <&eth_phy>;

    mdio {
        #address-cells = <1>;
        #size-cells = <0>;

        eth_phy: ethernet-phy@7 {
            compatible = "micrel,ksz9031";
            reg = <7>;
            interrupt-parent = <&gpioz>;
            interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
            reset-gpios = <&gpioz 5 GPIO_ACTIVE_LOW>;
        };
    };
};

:small_blue_diamond: What This Fixes:

  • Adds MDIO and PHY node (ethernet-phy@7).
  • Sets phy-handle correctly.
  • Configures PHY reset GPIO (reset-gpios = <&gpioz 5 GPIO_ACTIVE_LOW>;).

After fixing the DTB, rebuild U-Boot and flash
do the tests again…

mdio list
mii info

:white_check_mark: Expected Output:

ethernet@5800a000:
7 - Micrel ksz9031 ↔ ethernet@5800a000

if that is good try the Network interface.
setenv ethaddr xx:xx:xx:xx:xx:xx
setenv ipaddr 192.168.1.100
setenv serverip 192.168.1.1
ping 192.168.1.1

It’s quite the laundry list, maybe it will help. Can’t hurt to try.

GL :slight_smile: PJ :v: