APU4 and GPIO control

I am running an apu4, just a newer version of the apu2 boards folks have been using with VyOS, and was wondering if VyOS has a way to control GPIO in order to do LED assignments. Would like to set the 3 front LED’s to show up/down for 2 of the NIC’s and, if possible, the status of a wireguard tunnel.

Any thoughts?

Wireguard has no status, like in terms of an established network connection, you probably could send icmp echos and if you get a reply, take that as a ‘tunnel up’.

What about mapping of physical interfaces and/or led control in general for other things?

I have a pair of apu2c4 and wasn’t even able to get pc-engines own documentation working on Fedora/CentOS and I’ve tried the FreeBSD apuled without success. You might have better luck.

So the first issue I have found after finding an apu led package for debian is that the led package requires dkms which is not used on VyOS.

More research needed to see if there are any other options.

So I was able to get this working…

The LED driver is loading under VyOS and indicated here:

ls -l /sys/class/leds/
total 0
lrwxrwxrwx 1 root root 0 Jan 15 14:30 apu4:green:led1 -> …/…/devices/pci0000:00/PRP0001:02/leds/apu4:green:led1
lrwxrwxrwx 1 root root 0 Jan 15 14:30 apu4:green:led2 -> …/…/devices/pci0000:00/PRP0001:02/leds/apu4:green:led2
lrwxrwxrwx 1 root root 0 Jan 15 14:30 apu4:green:led3 -> …/…/devices/pci0000:00/PRP0001:02/leds/apu4:green:led3

Once I found the above, I tried setting up triggering for eth0 and eth1 but the trigger file did not contain the netdev option.

cat /sys/class/leds/apu4:green:led1/trigger
[none] disk-activity disk-read disk-write ide-disk cpu cpu0 cpu1 cpu2 cpu3 panic mmc0

Doing some more searching I came across the LED info on the Arch Linux Wiki:


It led me to the section which talked about there being additional LED kernel modules which are not loaded by default and the netdev was one of them. After doing a “modprobe ledtrig-netdev”, the netdev showed up in the trigger file and I was able to follow sample setup in the wiki by updating the LED directory names and get the LED’s to show eth0 and eth1 traffic.

I added the ledtrig-netdev module to /etc/modules/modules.conf file, but have yet to test to see if it persists after updates or if there is somewhere else I need to add it.

For the Wierguard tracking, I will probably end up running a ping script or something to trigger the LED where if ping is successful, turn the LED on and if it fails, then turn it off.

Hopefully this will help some others on getting the LED’s working under VyOS.

1 Like

That’s awesome you got it working; thanks for sharing your findings.

So it looks like the extra led kernel module is not loading after reboot.

So need two questions answered:

  1. How do I get persistent load of additional kernel module after reboot?

  2. Where can I put a script which will run echo commands at boot time in the underlying OS for setting the led configurations?

@ropeguru you can use it, also migrated after updates

Got it… I looked at other docs on scripts but they all talked about configuration commands while in the VyOS cli. I completely missed this one.

Will give it a shot today.

Thanks for the help.

Closing this out.

Using the file that Viacheslav mentioned works perfectly.

For anyone else that may want to get working, here is what I have showing interface activity for eth0 (WAN), eth1 (LAN Trunk), and my Wireguard itnterface.

modprobe ledtrig-netdev

echo 0 > /sys/class/leds/apu4:green:led1/brightness
echo netdev > /sys/class/leds/apu4:green:led1/trigger
echo eth0 > /sys/class/leds/apu4:green:led1/device_name
echo 1 > /sys/class/leds/apu4:green:led1/tx
echo 1 > /sys/class/leds/apu4:green:led1/rx

echo 0 > /sys/class/leds/apu4:green:led2/brightness
echo netdev > /sys/class/leds/apu4:green:led2/trigger
echo eth1 > /sys/class/leds/apu4:green:led2/device_name
echo 1 > /sys/class/leds/apu4:green:led2/tx
echo 1 > /sys/class/leds/apu4:green:led2/rx

echo 0 > /sys/class/leds/apu4:green:led3/brightness
echo netdev > /sys/class/leds/apu4:green:led3/trigger
echo wg0 > /sys/class/leds/apu4:green:led3/device_name
echo 1 > /sys/class/leds/apu4:green:led3/tx
echo 1 > /sys/class/leds/apu4:green:led3/rx

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.