[R3mini] uboot getting ethernet/nvme to work

I’ve changed it to these names after the rfc-patch comment from Andrew Lunn.

It uses almost the same name as:

mediatek,pnswap

i had understood that :wink: but this is not the problem…i wonder why ofnode_read_bool return 0 for rx…property is set and there is no typo…just try to debug drivers/core/ofnode.c now (seems not printing the debug-message when adding “#define DEBUG 1” before includes)

screenshot from @nezar_taima here confirms that the value written for serdes polarity is different

Symbol: OF_REAL [=y]

debug by adding #define DEBUG 1 before includes brings no additional debug-messages

can i print the current dts in uboot somehow? just to be sure the property still exists? but phy node is probed, so it should also find the property

it looks like the property is searched in the wrong node

PHY = 3a2 - a411                                                                                                                  
EN8811H PHY ready!                                                                                                                
EN8811H Mode 1 !                                                                                                                  
ofnode_has_property airoha,rx-pol-reverse (is_np? 1)                                                                              
of_find_property np:00000000bfaa25e0 airoha,rx-pol-reverse                                                                        
of_find_property compatible == airoha,rx-pol-reverse?                                                                             
of_find_property reg == airoha,rx-pol-reverse?                                                                                    
of_find_property resets == airoha,rx-pol-reverse?                                                                                 
of_find_property reset-names == airoha,rx-pol-reverse?                                                                            
of_find_property mediatek,ethsys == airoha,rx-pol-reverse?                                                                        
of_find_property mediatek,sgmiisys == airoha,rx-pol-reverse?                                                                      
of_find_property #address-cells == airoha,rx-pol-reverse?                                                                         
of_find_property #size-cells == airoha,rx-pol-reverse?                                                                            
of_find_property status == airoha,rx-pol-reverse?                                                                                 
of_find_property pinctrl-names == airoha,rx-pol-reverse?                                                                          
of_find_property pinctrl-0 == airoha,rx-pol-reverse?                                                                              
of_find_property mediatek,gmac-id == airoha,rx-pol-reverse?                                                                       
of_find_property phy-mode == airoha,rx-pol-reverse?                                                                               
of_find_property phy-handle == airoha,rx-pol-reverse?                                                                             
of_find_property phandle == airoha,rx-pol-reverse?                                                                                
readbool: airoha,rx-pol-reverse false                                                                                             
Rx Polarity set in dts: 0

it searches in the eth node not the phy node…

so possibly this is wrong:

static int en8811h_config(struct phy_device *phydev)
{
    ofnode node = phy_get_ofnode(phydev);

or this conversion in ofnode_has_property:

of_find_property(ofnode_to_np(node),…

@1715173329 have you an idea whats going on here or how i can debug this? I wonder why it is working in your build…which uboot version do you use (maybe new bug in 2024.01) maybe additional patches for of-functions or different parser (external fdt)?

if i skip the dt-property and set rx-reverse manually, and then it works once

BPI-R3M> setenv ipaddr 192.168.90.2
BPI-R3M> ping 192.168.90.1         
Using ethernet@15100000 device
host 192.168.90.1 is alive
BPI-R3M> ping 192.168.90.1
Using ethernet@15100000 device

Abort
ping failed; host 192.168.90.1 is not alive
BPI-R3M>

so same as in your tests…after first usage it is stalled…and the of-handling is strange

@hackpascal have you an idea about the hang (and maybe the wrong node)?

@ericwoud: i think the function you pointed should not be used as phydev have already an ofnode

And so this should be used:

But need to check it

i tried to print the related information, but it is crashing

if (phydev->dev)
    printf("%s devname: %s\n", __func__,phydev->dev->name);
if (node.np)
    printf("%s nodename: %s\n", __func__, node.np->name);

seems crash is caused by node.np->name

but it turnes out that phy-device is already the ethernet-node

en8811h_config devname: ethernet@15100000

basicly i can use phy-handle to go to the linked phy, but wonder why config gets the parent node and it works with the ethernet-node (yes i know that the phy is connected over the mdio-bus of ethernet-controller)

did this and it seems to work:

struct ofnode_phandle_args node_args;
if (ret) {
	printf("can't parse phy-handle (%d)\n",
		ret);
} else node = node_args.node;

int rx_reverse=ofnode_read_bool(node, "airoha,rx-pol-reverse");
printf("Rx Polarity set in dts: %d\n", rx_reverse);

results in:

en8811h_config devname: ethernet@15100000
PHY = 3a2 - a411
EN8811H PHY ready!
EN8811H Mode 1 !
readbool: airoha,rx-pol-reverse true
Rx Polarity set in dts: 1
readbool: airoha,tx-pol-reverse false
Tx, Rx Polarity(0xca0f8) to be written: 01a01503
Tx, Rx Polarity(0xca0f8): 01a01503
MD32 FW Version(0x3b3c) : 23051209
LED initialize OK !
EN8811H initialize OK ! (v1.0.4)

How do you handle the enable signals? Do the pio 16 and 17 pins stay low?

You mean the regulators for powering the phy?

I took this 1:1 from immortalwrt

But maybe it is better to define them as regulators…done this, but same problem


BPI-R3M> setenv ipaddr 192.168.90.2
BPI-R3M> ping 192.168.90.1         
Using ethernet@15100000 device
host 192.168.90.1 is alive
BPI-R3M> ping 192.168.90.1
Using ethernet@15100000 device

ARP Retry count exceeded; starting again
ping failed; host 192.168.90.1 is not alive
BPI-R3M>

So which functions get called here again

oh, hawk eye…have not noticed this…but this seems right

net/ping.c:73:	printf("Using %s device\n", eth_get_name());

same message also exists in tftp.c and others.

Btw, where did you select which gmac to use? Is a second mac supported in uboot? Did you try other port?

Imho this is done by this property in the eth node:

mediatek,gmac-id = <0>;

Does not look like i can use both gmacs together. I can only try to set it to 1,but then imho i will need to use the other phy.

Would this have anything to do with env_get("ethrotate") ?

Is it set to 'no' ?

It’s just really strange, first attempt it works…

Where have you seen this? I do not see it in driver

https://github.com/u-boot/u-boot/blob/master/net/eth-uclass.c#L286
		/*
		 * If ethrotate is enabled, this will change "current",
		 * otherwise we will drop out of this while loop immediately
		 */

both times ethrotate is null (but called both times)

@dangowrt i tried to use your version of phy driver and added the old way with builtin firmware

looks like one option is using boot1 from emmc…how have you written it for testing?

i guess something like this:

cat files/bpi-r3mini/{EthMD32.dm.bin,EthMD32.DSP.bin} > en8811h.bin

tried to flash this file to emmc boot1, but failed

BPI-R3M> fatload usb 0:1 $loadaddr r3mini/en8811h.bin
147456 bytes read in 16 ms (8.8 MiB/s)
BPI-R3M> mmc partconf 0 1 1 2
BPI-R3M> mmc write $loadaddr 0x0 $filesize

MMC write: dev # 0, block # 0, count 147456 ... mmc write failed
0 blocks written: ERROR
BPI-R3M>

edit: got first problem (loading firmware from header) solved…missed CONFIG_PHY_ETHERNET_ID=y

edit: @ericwoud tried adding your host_restart way…but it does not solve the issue ;(

any idea?

Maybe this should only be done when firmware_version not set

Maybe i should move resets and firmware-load to probe,which is only called once. Edit: this results in crash :(, tried moving phy-reset in the condition (firmware not loaded yet), but same issue…only working once

made also some cleanup like replacing magic numbers for firmware-load with constants like in erics code and fixed indentation.

Nvme seems my fault,had to put missing constant in different block (with higher value).

I would not put too much effort into this driver. Once Eric’s driver got merged in upstream Linux, the best would be to port that to U-Boot (and just keep the firmware loading from {MMC,UBI/SNAND,MTD/NOR} options added, so firmware can always be loaded even if runtime firmware or filesystems are damaged).

I tried to write firmware to mmc (the easiest way i think to do manually because ubi needs to create ubifs first and nor is not available on r3mini),but got write error…any idea on this?

written firmware successful to boot1…also found a nice guide from daniel here just used usb to transfer the files and used original files without concatenating before

usb start
mmc partconf 0 1 2 2
mmc erase 0x0 0x120
load usb 0:1 $loadaddr EthMD32.dm.bin
mmc write $loadaddr 0x0 0x20
load usb 0:1 $loadaddr EthMD32.DSP.bin
mmc write $loadaddr 0x20 0x100
mmc partconf 0 1 1 0

but have not tested it as i need to patch out my builtin-firmware before

1 Like

Any news regarding the nvme support?

My uboot has nvme support for r3(mini) and r4 and sent patch to uboot mailinglist…no comment yet

Only got info that mt7981 was not yet working