PC Engines

From ArchWiki

PC Engines is a Swiss hardware manufacturer for embedded x86 devices.

apu2c4

This document describes how to install Arch Linux to the SSD via an SD card or USB flash drive.

Hardware

CPU: AMD Embedded G series GX-412TC, 1 GHz quad Jaguar core with 64 bit

RAM: 4GB DRAM with ECC

Note: Remove the screws from the serial port first!

Assemble the device with care and read the guide for the cooling system!

Setup preperations

Boot the system

To see the BIOS use this command:

$ LANG=C picocom --baud 115200 /dev/ttyUSB0

If your device does not boot from the SD card or USB flash drive, press F10 during boot to bring up a boot menu. Then close picocom with Ctrl+a Ctrl+q

Reconnect to the Archiso GRUB:

$ LANG=C picocom --baud 38400 /dev/ttyUSB0

Enter CLI mode by pressing Tab, and append the following kernel parameter to the line:

console=ttyS0,115200

Press Enter.

Now exit picocom and reconnect with the first command again to switch to the higher baud rate of 115200. Finally wait for about 30 seconds and you will get a colorful boot prompt.

Install the system

The most comfortable way to install Arch now is to start the ssh server and use the installation guide.

You may need to get a new IP with dhclient and start sshd.service.

One possible layout of the SSD maybe looking like this:

 /dev/sda1           2048   264191   262144  128M 83 Linux
 /dev/sda2         264192 25430015 25165824   12G 83 Linux
 /dev/sda3       25430016 31277231  5847216  2.8G 82 Linux swap / Solaris

It is a good idea to use a MBR layout with GRUB:

# grub-install --target=i386-pc /dev/sda
# grub-mkconfig -o /boot/grub/grub.cfg

If using Syslinux, make sure to provide a console option in the boot menu:

/boot/syslinux/syslinux.cfg
LABEL arch
    MENU LABEL Arch Linux
    LINUX ../vmlinuz-linux
    APPEND root=UUID=1ef5a2eb-1908-4929-9b91-f6c4183695ac rw console=ttyS0,115200
    INITRD ../initramfs-linux.img

See also Working with the serial console#Configure console access on the target machine.

Remember to remove the SD card or USB flash drive after you finished your setup.

LED Control

While there are 2 mainline kernel drivers (leds-apu and pcengines-apuv2) that can control the LEDs on various APU models, if you are running mainline PC Engines firmware it is advised to let ACPI handle LED control. In conjunction with the ledtrig_netdev module, the APU LEDs can be controlled through the following sysfs entries:

/sys/class/leds/apu2:green:led1
/sys/class/leds/apu2:green:led2
/sys/class/leds/apu2:green:led3

Module Handling

You will have to manually load ledtrig_netdev. You also want to blacklist both leds_apu and pcengines-apuv2.

Example Configuration

A common use case is to use the APU as a wireless router. In this scenario, one wired NIC (wan0) is connected upstream to an ISP and the remaining wired & wireless NICs are bridged (br0) together as the LAN. A typical LED configuration using the netdev trigger might be:

LED1: power on / power off indicator
LED2: upstream network (wan0) traffic indicator
LED3: local network (br0) traffic indicator

To enable this setup:

echo "1" > /sys/class/leds/apu2:green:led1/brightness
echo "netdev" > /sys/class/leds/apu2:green:led2/trigger
echo "wan0" > /sys/class/leds/apu2:green:led2/device_name
echo "1" > /sys/class/leds/apu2:green:led2/tx
echo "1" > /sys/class/leds/apu2:green:led2/rx
echo "netdev" >  /sys/class/leds/apu2:green:led3/trigger
echo "br0" >  /sys/class/leds/apu2:green:led3/device_name
echo "1" >  /sys/class/leds/apu2:green:led3/tx
echo "1" >  /sys/class/leds/apu2:green:led3/rx
Note: Writing to the trigger sysfs entry must be done first as this is what enables the device_name, tx rx entries.
Tip:
  • View triggers supported by the currently loaded modules: cat /sys/class/leds/apu2:green:led1/trigger.
  • Additional trigger modules are available here: /lib/modules/$(uname -r)/kernel/drivers/leds/trigger.

Persist Configuration

Systemd automatic module loading and tmpfiles.d can be used to persist this configuration across restarts.

/etc/modules-load.d/ledtrig-netdev.conf
ledtrig_netdev
/etc/tmpfiles.d/leds.conf
#Power on/off
w /sys/class/leds/apu2:green:led1/brightness - - - - 1
#WAN activity
w /sys/class/leds/apu2:green:led2/trigger - - - - netdev
w /sys/class/leds/apu2:green:led2/device_name - - - - wan0
w /sys/class/leds/apu2:green:led2/tx - - - - 1
w /sys/class/leds/apu2:green:led2/rx - - - - 1
#LAN activity
w /sys/class/leds/apu2:green:led3/trigger - - - - netdev
w /sys/class/leds/apu2:green:led3/device_name - - - - br0
w /sys/class/leds/apu2:green:led3/tx - - - - 1
w /sys/class/leds/apu2:green:led3/rx - - - - 1

Firmware

The APUx devices use coreboot firmware, not UEFI. To update the firmware on APU2/3/4/5 devices, use flashrom:

# flashrom --programmer internal --read old.rom --output read-old.txt
# flashrom --programmer internal --write new.rom --output write-new.txt
# systemctl poweroff

Then unplug and replug. If a full reboot is impossible, e.g. because firmware is being updated remotely, workarounds are available. For details, see:

Troubleshooting

BIOS serial console interfering with GRUB serial console

If the GRUB boot screen shows most characters twice, check if the serial console in the BIOS menu is enabled and disable it. See [1] for details.