Raspberry Pi

From Void Linux Wiki
Jump to: navigation, search


Choosing the right file

As of 2017-11-30, Void Linux provides prebuild images as well as rootfs-tarballs. Compatible images and tarballs exist each for rpi1, rpi2 and rpi3, both in glibc and musl variant.

You can

  • either write the prebuild image directly to your sdcard (ex: dd if=<void-rpi.img> of=/dev/sdX bs=4M ; sync ), but that might give you a limited partition layout that has to be expanded manually afterwards
  • or prepare the partition layout of your sdcard manually and extract the tarball to your sdcard (ex: guide below)

After downloading the chosen file, make sure to check that sha256 is correct. The sha256 hash is stored in the sha256sums.txt file.

RaspberryPi3: 32bit or 64bit ?

It is possible ( and to some extent advised ) to run the rpi2 image on you rpi3, as the rpi2 images contain the official raspberry foundation's kernel image (https://github.com/raspberrypi/linux) and are therefore the most feature complete in regard to blobs, firmware and overall functionality. You just get a 32bit armv7 system. That is totally fine in general and is what the popular raspbian does too.

While you see images and tarballs labelled as "rpi3", you should be aware that those images contain the aarch64 (as in arm64) mainline linux kernel, which does not include the foundation's specific patches and blobs. Depending on your needs that may be ok for you, but some functionality is known to not work by now:

  • onboard wiFi
  • probably more...

Rpi3 aarch64 support has landed

(This information will be obsolete once new official images are created by the voidlinux project) As of 2018-05, the rpi-kernel package gained aarch64 support for rpi3 (see here). Since there no new images on the official repositories yet, you would need to build the image on your own and flash it to your sd card as usual (see below).

Here are the rough step to go through. If you wish for a glibc based image, just skip the -musl part on both commands, and fill in the date of today accordingly.

$ git clone https://github.com/void-linux/void-mklive
$ cd void-mklive
$ make
$ sudo make void-aarch64-musl-ROOTFS-<YYYYMMDD>.tar.xz
$ sudo make void-rpi3-musl-PLATFORMFS-<YYYYMMDD>.tar.xz

Proceed as usual with the fresh image.

Enjoy your rpi3 with an aarch64 kernel on a slick musl based void installation, with working wifi etc.

rootfs-install

Grab the latest platformfs tarball (containing the rootfs as well as architecture specific files) for your device from http://repo.voidlinux.eu/live/current/ ex: void-rpi2-musl-PLATFORMFS-<date>.tar.xz)

Preparing the SD card

The SD card must have at least 2 partitions, one as FAT (with partition type 0c!) for /boot and another one as ext4/f2fs for /; let's begin preparing the partitions and mounting them in a directory:

$ parted /dev/mmcblk0 <- change this to match your SD card

# Create the FAT partition of 256MB and make it bootable
(parted) mktable msdos
(parted) mkpart primary fat32 2048s 256MB
(parted) toggle 1 boot

# Create the rootfs partition until end of device
(parted) mkpart primary ext4 256MB -1
(parted) quit

Now let's create the filesystems in the SD card:

 $ mkfs.vfat /dev/mmcblk0p1 <- change this to match your SD card and FAT32 partition
 $ mkfs.ext4 -O '^has_journal' /dev/mmcblk0p2 <- change this to match your SD card and ext4 partition

The -O ^has_journal option disables journaling on ext4 partition. It'll extend the life of your drive (usually Flash drives).

Preparing target rootfs directory

 $ mkdir rootfs
 # mount /dev/mmcblk0p2 rootfs/
 # mkdir rootfs/boot
 # mount /dev/mmcblk0p1 rootfs/boot

Unpack the previously grabbed tarball into the target rootfs directory and sync to make sure files are written to storage:

 # tar xvfJp void-rpi*-PLATFORMFS-%DATE.tar.xz -C rootfs

 # sync
Do not forget to unpack the rootfs as root and with the -p flag to set appropiate permissions.

The /boot partition must also be added to /etc/fstab:

 # echo '/dev/mmcblk0p1 /boot vfat defaults 0 0' >> rootfs/etc/fstab

Umount the SD card filesystems from target rootfs directory.

You can tweak kernel boot cmdline arguments in the rootfs/boot/cmdline.txt file.

Insert the SD card and test the Raspberry PI boots correctly, the root password is voidlinux.

First Boot

Set the system time

Before it is possible to install or upgrade packages (ex: xbps-install -Su), it is necessary to set the clock. The Raspberry Pi does not have a battery backed clock so you must set the time manually or you will see HTTPS certificate errors.

Enable a NTP server and wait for the date to be set:

# ln -s /etc/sv/ntpd /var/service
# date
Sun Oct 29 09:21:49 CET 2017

X11

At the very least this is the list of required packages:

# xbps-install -Sy xorg-minimal xf86-video-fbturbo

To install all X client applications:

# xbps-install -Sy xorg-apps

To install all X font packages:

# xbps-install -Sy xorg-fonts

As final step make sure the user running X is part of the groups audio and video.

ioquake3

Install the package via xbps-install(8):

# xbps-install -Sy ioquake-rpi

Copy .pk3 data files from original quake3 game or demo:

# For the system:
cp /path/quake3/*.pk3 /opt/ioquake3-rpi/baseq3/

# For just a normal user:
cp /path/quake3/*.pk3 ~/.q3a/baseq3/

If you do not have X installed just run SDL with the framebuffer video driver:

 $ SDL_VIDEODRIVER=fbcon SDL_NOMOUSE=1 quake3

Audio

To get the soundchip to work, add dtparam=audio=on to /boot/config.txt

Serial

Enable serial console logins

 # mkdir ~/rootfs
 # mount /dev/sdX2 ~/rootfs
 # ln -s /etc/sv/agetty-ttyAMA0 ~/rootfs/etc/runit/runsvdir/default
 # umount ~/rootfs

Notes:

  • See /boot/cmdline.txt for start-up configuration of serial port (device and baud)
  • See /etc/securetty for interfaces that allow root login, ttyAMA0 should already be listed.

I2C

To enable I2C, add "device_tree_param=i2c_arm=on to /boot/config.txt. Add bcm2708.vc_i2c_override=1 at the end of /boot/cmdline.txt.

If it doesn't exist, create the directory /etc/modules-load.d/ and in there, create the file i2c.conf with a line i2c-dev. Reboot.

Also, install i2c-tools package and try i2cdetect -l, it should show i2c-1i2c bcm2835 I2C adapter I2C adapter

Useful resources