Vim3 Wake-on-LAN unicast mode?

I’ve flashed Ubuntu onto the eMMC, followed the instructions at https://docs.khadas.com/vim2/HowtoUseWol.html / https://docs.khadas.com/vim2/KbiGuidance.html to enable WOL in uboot, and used ethtool to set WOL mode to u (unicast):

sudo ethtool -s eth0 wol u

Then I test by suspending the VIM3:

sudo systemctl suspend

And try to ping the VIM3, or to ssh to it. This doesn’t wake it up. Only sending a magic packet with e.g. the wakeonlan tool wakes the VIM3.

It appears that ethtool’s settings don’t make any difference – even if I set mode d (disable), a magic packet will wake the VIM3.

This is despite the ethernet card claiming to support WOL mode u:

$ sudo ethtool eth0
...
        Supports Wake-on: ug

On another small computer (Atomic Pi), mode u works as desired – as soon as I try to connect to it, or send traffic over an existing connection, it wakes up. However, that board is very power hungry, even when suspended, which is why I want to use the VIM3.

Is there a way to get unicast WOL mode working on the VIM3?

Ok, I may have found a lead. The datasheet for the RTL8211F references a “WOL Application Note”. I couldn’t find that for the RTL8211F, but I did find it for the related RTL8201F. It looks like these might have the same configuration interface.

From the application note, I think I just have to change the number written here to 0x0400 to get unicast mode. Possibly I may also need to write the MAC to some other registers.

I’ll have to play around with recompiling the kernel to try this out.

Ideally ethtool would be able to set the different modes.

Ok, it worked. In my comment above I was looking at the wrong branch of the khadas/linux repo, so the patch goes into a different place (enable_wol instead of rtl8211f_config_wol), but it’s the same basic idea: use 0x0400 for unicast mode instead of 0x1000 for magic packet.

Patch:

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index d42bdbef..03f70990 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -85,8 +85,8 @@ static void enable_wol(int enable, bool is_shutdown)
                        }

                        phy_write(g_phydev, RTL8211F_PAGE_SELECT, 0xd8a);
-                       /*set magic packet for wol*/
-                       phy_write(g_phydev, 0x10, 0x1000);
+                       /*set unicast mode for wol*/
+                       phy_write(g_phydev, 0x10, 0x0400);
                        phy_write(g_phydev, 0x11, 0x9fff);
                        /*pad isolation*/
                        value = phy_read(g_phydev, 0x13);

Maybe at some point I’ll try to make ethtool actually work, but that’s a whole other thread of investigation. For now, I think I’m okay being stuck with unicast mode. (It may also be possible to set 0x1400 for both? I have not tried yet.)

For reference, it seems to take about 5 seconds to wake up. As one might expect, packets sent to the VIM3 in the mean time are dropped.

I’ve confirmed that with setting 0x1400, it will wake for either a Magic Packet or unicast packets.