This is an old revision of the document!


Wake on LAN (WoL)

The Wake-on-LAN (WoL) feature was implemented in Batocera v33. After enabling it, it is possible to turn on/off your Batocera machine by sending a “magic packet” (or something else, more info later) via a network cable. This could be used to turn on the machine by using a network protocol call, a network-connected IR remote receiver, a packet sent over a virtual network, and many other things!

On the Batocera machine, the functionality of WoL is dependent on two components supporting it:

  • BIOS: The system's BIOS must support WoL (you may have to enable WoL within your system's BIOS settings).
  • NIC: The system's network adapter must support WoL to stay “awake” while the system is powered off.

If you are dual-booting with Windows on the same machine, you may need to also tell Windows to not disable the WoL shutdown procedure in its drivers.

After checking for the above, boot Batocera and run ifconfig. Identify the network interface name of your connection, and then run the appropriate ethtool eth0 command, where eth0 is the name of your network interface. It should give you an output similar to this:

Typical example output here.

Property Notes
Supports Wake-on: Shows which hardware WoL capabilities the NIC supports (these values cannot be changed by the user)
Wake-on: Shows which software WoL capabilities are currently enabled (these can be turned on/off by the user)

The value g means that your NIC supports receiving magic packets and therefore is WoL capable. Note that your NIC could also support multiple WoL functions and therefore you would get multiple output values, e.g. Supports Wake-on: pumbg.

Here is a full list of output possibilities (more info at https://linux.die.net/man/8/ethtool or the man ethtool command):

  • p ⇒ Wake on PHY activity
  • u ⇒ Wake on unicast messages
  • m ⇒ Wake on multicast messages
  • b ⇒ Wake on broadcast messages
  • a ⇒ Wake on ARP
  • g ⇒ Wake on MagicPacket™
  • s ⇒ Enable SecureOn™ password for MagicPacket™
  • d ⇒ Disable (wake on nothing). This option clears all previous options.

The most important value is g. Without it being shown, the NIC does not support WoL at all.

USB-LAN adapter

USB-LAN adapters are typically capable of supporting WoL, but have the feature turned off by default. Running the above would output the following:

Supports Wake-on: g
Wake-on:

This means the machine's NIC is indeed WoL capable but not yet enabled. To enable the according option persistently a udev rule can be utilized. Read the section below on how to do that.

First, if it doesn't already exist create the folder(s) at /userdata/system/udev/rules.d/. Then, save the following file into the rules.d/ folder:

99-wol.rules
ACTION!="add|change", GOTO="end"
SUBSYSTEM!="net", GOTO="end"
ENV{INTERFACE}!="eth*", GOTO="end"

TEST=="/sys/class/net/$env{INTERFACE}/device/power/wakeup", RUN+="/bin/sh -c 'echo enabled >/sys/class/net/$env{INTERFACE}/device/power/wakeup'"

ACTION=="add|change", SUBSYSTEM=="net", ENV{INTERFACE}=="eth*", RUN+="/usr/sbin/ethtool -s $env{INTERFACE} wol g"

LABEL="end"

The code below will enable WoL for all of your system's WoL capable NICs. If for some reason you want to enable WoL only for a specific NIC (e.g. eth0), replace eth* with the according specific NIC name on the ACTION code line .

Reboot the machine.

Note: It is important to have your WoL client and your Batocera system within the same Layer 2 subnet of your network, otherwise WoL will not work as WoL packages cannot be routed over different subnets.

To find out the unique MAC address of your Batocera system's NIC, run ip link show.

MAC address

The MAC address for this NIC (eth0) is f0:1f:af:25:dc:8b.

You can now use the given MAC address to wake the Batocera machine up remotely from another device (e.g. PC, Smartphone, …) which is within the same Layer 2 subnet and has a WoL client (GUI based or command line based WoL client) installed.

Example of a WoL client for Windows (Depicus Wake on Lan for Windows GUI):

WoL client settings

Most utilities require the following information (or similar enough to it):

  • Mac Address ⇒ MAC address of your NIC on the Batocera machine.
  • Internet Address ⇒ The IP of the NIC on the Batocera machine (if only one NIC is present on the WoL client, you can leave this empty).
  • Subnet MaskNetmask of the network's subnet.
  • Send optionsFIXME (what is this for? Why would I want to change it?) Choose Local Subnet.
  • Remote Port Number ⇒ The port to send the traffic on. Acceptable values are generally 9 (default) or 7.

Click on Wake Up to wake the Batocera machine up.

Try changing the port number from 9 to 7. If the machine uses an esoteric port this will usually be noted in its documentation.

If that did not work, try sending the packet via Internet instead of Local Subnet.

  • wake_on_lan.1642126171.txt.gz
  • Last modified: 4 years ago
  • by atari