OpenWRT installation instructions for APU2/APU3/APU4 boards

Article updated on 2023-11-26

This tutorial is for OpenWRT 22.03. Instructions for older and newer versions are almost the same, but some packages (linked at the end) may be different. 

OpenWRT doesn't have a typical installation process like pfSense or IPFire. OpenWRT needs to be "flashed" on the disk.

If you have an APU2, APU3, APU4 or APU6 router and don't want to go through the manual installation procedure, you can use the automatic OpenWRT installer.

Easy, step by step instructions:

  1. Prepare Debian bootable USB
  2. Connect your Debian USB to APU board and boot
  3. download OpenWRT image onto the Debian USB
  4. Flash the SSD drive with the OpenWRT image
  5. Resize the OpenWRT partition to use entire disk space
  6. Boot OpenWRT from the SSD

 

Prepare a bootable linux USB 

To make things simpler, we made a live Debian ISO image preloaded with all the required software. 

Download the debapu-live-2023-11-26.iso image and flash it on a USB stick.

If you are using Windows, flash the image using Rufus: https://rufus.akeo.ie/; if you are using Linux, use dd. 

Connect the Serial cable to the APU and a LAN cable to the first NIC port (closest to the serial), insert the newly flashed USB, and boot the system.

Use putty to connect to the serial port. Putty instructions for Windows are available here, and for macOS here.

Connect power to APU to boot the system. Your APU Live USB should now boot and automatically present a root shell. You don't need to log in. 


Download OpenWRT image onto the Debian USB

Now you should be logged in either via ssh or through the serial cable as shown above. Make sure you have the WAN cable connected, so you have a connection to the internet.

You can now download the latest OpenWRT image from here http://archive.openwrt.org/releases/. Make sure to download x86 / 64 / generic-ext4-combined.img.gz file. We need an image called "generic-ext4-combined.img.gz". Make sure you get the ext4 image; otherwise, you won't be able to resize the partition and use the entire disk space.

At the time of writing, the latest image is 22.03.02, so my wget command looks like shown below.

root@debian:~# wget https://downloads.openwrt.org/releases/22.03.2/targets/x86/64/openwrt-22.03.2-x86-64-generic-ext4-combined.img.gz

This should go relatively quickly. Once it's downloaded, unpack it with 

root@debian:~# gunzip openwrt-22.03.2-x86-64-generic-ext4-combined.img.gz

This should produce a file named "openwrt-22.03.2-x86-64-generic-ext4-combined.img" (without the .gz extension).

Flash the SSD drive with the OpenWRT image

Once you have the image downloaded, you can flash it on the SSD with the following command:

root@debian:~# dd if=openwrt-22.03.2-x86-64-generic-ext4-combined.img of=/dev/sda bs=4M; sync;

This will take only a second or two because the SSD is relatively fast.

Output should look similar to this:

root@debian:/home/user# dd if=openwrt-22.03.2-x86-64-generic-ext4-combined.img of=/dev/sda bs=4M; sync;
68+1 records in
68+1 records out
285736960 bytes (286 MB, 272 MiB) copied, 1.50062 s, 190 MB/s

At this point, you have a bootable OpenWRT installation. You could power off, remove the USB and boot your APU, but should probably also complete the last step to gain access to the entire space on the SSD.

Resize the OpenWRT partition to use the entire disk space

This is an optional step, but you probably want to do this. When we flashed the OpenWRT image, the partition table was already set to about 270M partition for system. Since we have a 16G disk, we would like to use the entire space.

Make sure you have parted installed (apt-get install parted) . 

Boot your debian USB and issue the following command to see your patition table:

root@debian:~# parted /dev/sda print
Model: ATA SATA SSD (scsi)
Disk /dev/sda: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      262kB   17.0MB  16.8MB  primary  ext2         boot
 2      17.3MB  286MB   268MB   primary

There are 2 partitions, one for boot and the other one for the data/system. We want to resize the latter partition to use the entire space. 

Issue the following command to resize the partition:

root@debian:~# parted /dev/sda resizepart 2 16G
Information: You may need to update /etc/fstab.

One this completes, run the previous command again to verify that the entire space is now allocated to the partition

root@debian:~# parted /dev/sda print
Model: ATA SATA SSD (scsi)
Disk /dev/sda: 16.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      262kB   17.0MB  16.8MB  primary  ext2         boot
 2      17.3MB  16.0GB  16.0GB  primary

And now the last step is to extend the filesystem on this partition. Run:

root@debian:~# resize2fs /dev/sda2 
resize2fs 1.43.4 (31-Jan-2017)
Resizing the filesystem on /dev/sda2 to 3902026 (4k) blocks.
The filesystem on /dev/sda2 is now 3902026 (4k) blocks long.

Note, if you upgrade OpenWRT from the web interface to a new version, this step will need to be executed again.

OpenWRT web interface

Now you should be able to connect the second port on OpenWRT to your computer and have access to the web interface. From here you can reconfigure WAN and LAN settings as well as install all additional software you may want.

Recommended software packages

When we install OpenWRT on routers for customers, we typically install drivers and other software packages using terminal because it's a little faster.

Here are the packages we are installing by default. You can copy-paste these commands.

opkg update
opkg install kmod-pcengines-apuv2 beep kmod-leds-gpio kmod-crypto-hw-ccp kmod-usb-core kmod-usb-ohci kmod-usb2 kmod-usb3 kmod-sound-core kmod-pcspkr amd64-microcode flashrom irqbalance fstrim usbutils curl luci-app-advanced-reboot

If you have wle200nx, wle600vx or wle900vx WiFI adapters, you need these additional packages.

opkg install hostapd-openssl kmod-ath9k ath9k-htc-firmware ath10k-firmware-qca988x kmod-ath10k

If you have a Quectel 4G modem, you will need these additional packages

opkg install qmi-utils kmod-usb-net-qmi-wwan libqmi luci-proto-qmi uqmi

If you want to run Wireguard, we recommend these packages

opkg install luci-proto-wireguard luci-app-wireguard

And here are packages for OpenVPN (NordVPN etc)

opkg install openvpn-openssl ip-full luci-app-openvpn

If you want to upgrade all packages already installed on your system, you can do it with the following command.

opkg update
opkg list-upgradable | cut -f 1 -d ' ' | xargs opkg upgrade 

 

If you have WiFi in your router, you may also be insterested in our OpenWRT AccessPoint / WiFi configuration tutorial 

If you have a LTE/4G modem you may find OpenWRT 4G WAN configuration useful. 

You may also find some additional instructions about APU hardware in the official OpenWRT documentation.