Tailscale on the DevTerm R-01

2023-01-25 | #tailscale #linux #riscv #devterm

Intro

Recently I assembled a ClockworkPi DevTerm R-01[1], a cyberdeck-like terminal with a RISC-V[2] compute module. While the retro-future design of the DevTerm really appealed to me, and I've also been wanting to work with RISC-V for a while to learn a new architecture making the R-01 a perfect esoteric project platform.

1: https://www.clockworkpi.com/product-page/devterm-kit-r01

2: https://en.wikipedia.org/wiki/RISC-V

DevTermR01 [IMG]

After trying out a few things like DOSBox[3], Surf[4], and ScummVM[5], I found the Allwinner D1[6] RISC-V chip wasn't powerful enough to do much other than some basic window management, Interactive Fiction[7], and browsing `gopher://` with Bombadillo[8]. However I still wanted to use it as a terminal to access other systems, which lead me to attempting to install Tailscale[9] to leverage the mesh VPN and other features.

3: https://www.dosbox.com/

4: https://git.suckless.org/surf/

5: https://www.scummvm.org/

6: https://linux-sunxi.org/D1

7: http://www.infocom-if.org/downloads/downloads.html

8: https://bombadillo.colorfield.space/

9: https://tailscale.com

Installing `tailscale` was un-eventful, as it's had RISC-V support[10] for a while, and following the install guide did what was expected. The problem is `tailscaled` fails due to the required `tun` kernel module missing in the 5.4.61 kernel running on the DevTerm.

10: https://github.com/tailscale/tailscale/issues/2119

Building a TUN/TAP Kernel Module

The first step was finding if the R-01 kernel source was available so re-build the exact kernel version and include the `tun` module by setting `CONFIG_TUN=m`. Looking around the ClockworkPi website, Discord, and Github I eventually found the How to Compile Kernel[11] documentation. This had links to the original source and the toolchain.

11: https://github.com/clockworkpi/DevTerm/wiki/Create-DevTerm-R01-OS-image-from-scratch#how-to-compile-kernel

Since the R-01 isn't exactly fast, cross-building this on a x86 system was required. My personal Debian server is a bit of mess when it comes to package pinning, so I created a new 8 CPU, 8GiB memory virtual machine in qemu and install Ubuntu 22.04 "Jammy Jellyfish"[12] since that's what the R-01 is running and what ClockworkPi has in it's documentation.

12: https://www.releases.ubuntu.com/jammy/

Installing Required Packages

After setting up the VM, install required packages for cross-building the kernel,

Cloning ClockworkPi Kernel Source

Clone the kernel source[13] into `~/git`,

13: https://github.com/cuu/last_linux-5.4

Setting Up Build Toolchain

Download the ClockworkPi toolchain from https://github.com/cuu/toolchain-thead-glibc[14], which is a README pointing to a Mega link. While it's a bit concerning coming from Mega, since it's a tarball and running in a VM it's not that risky. There's also a section on installing the official RISC-V toolchain which is another option, but requires additional building.

14: https://github.com/cuu/toolchain-thead-glibc

Untar in home directory,

Existing Kernel Config from DevTerm

Copy the running kernel config in `/proc/config.gz` on the DevTerm to the VM. The `config.gz` contains the configuration for how the running `5.4.61` kernel was configured and is loaded to set everything the exact same way when building the new kernel.

Enabling CONFIG_TUN

There are two ways to enable the TUN/TAP module,

or

Building the Kernel

Build the kernel using the provided `m.sh` script, but first edit it to include the `PATH` for the toolchain and `LOCALVERSION=`. If `LOCALVERSION=` isn't set then the kernel version will include a `+` at the end and modules will not load due to a version mis-match,

Run `./m.sh` and wait a few minutes while it builds.

When successful, the new kernel and modules are in `test/boot/`

Setting up New Modules on DevTerm

Create a tarball of the new modules and copy them to the DevTerm,

On the DevTerm, backup original modules directory,

and untar the new modules directory,

Loading the TUN/TAP Module

Load the new TUN/TAP Module,

If successfull `dmesg` will show,

Setting up Tailscale

Now that the TUN/TAP module is loaded, start `tailscaled` and finish setting up Tailscale,

Tags

devterm

riscv

linux

tailscale

____________________________________________________________________

Home