Skip to content

Instantly share code, notes, and snippets.

@bahamas10
Last active November 22, 2022 00:26
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bahamas10/aee4cc121c29e6657a91fc53418356c7 to your computer and use it in GitHub Desktop.
Save bahamas10/aee4cc121c29e6657a91fc53418356c7 to your computer and use it in GitHub Desktop.
Void Linux on Raspberry Pi 4

Summary

I'm able to get a Void Linux image (32bit, raspberry pi 2 image) to boot on the raspberry pi 4. Currently, I can get it to boot and even handle upgrading via xbps-install -Su (networked over ethernet), however I can't seem to get it to see the internal wlan (wifi) device.

huge shout out to kodifies on this reddit post for helping me to get this going.

Steps

grab the raspberry pi 2 (32bit) image

mkdir -p ~/temp
cd ~/temp
wget https://alpha.de.repo.voidlinux.org/live/current/void-rpi2-PLATFORMFS-20181111.tar.xz

grab the latest raspberry pi firmware (will take a while)

git clone git://github.com/raspberrypi/firmware.git

prepare the sdcard and install void. This is largely based on https://wiki.voidlinux.org/Raspberry_Pi

replace /dev/sda with your device (found in fdisk -l)

$ sudo parted /dev/sda
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable msdos
(parted) mkpart primary fat32 2048s 256MB
(parted) toggle 1 boot
(parted) mkpart primary ext4 256MB -1
(parted) quit

create the filesystems

$ sudo mkfs.vfat /dev/sda1
mkfs.fat 4.1 (2017-01-24)
$ sudo mkfs.ext4 -O '^has_journal' /dev/sda2
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 15579648 4k blocks and 3899392 inodes
Filesystem UUID: f07242a6-b029-4581-a24f-dd51f6bf5d3e
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

create the root filesystem

sudo mount /dev/sda2 /mnt
sudo mkdir /mnt/boot
sudo mount /dev/sda1 /mnt/boot

place the rpi2 image onto the SD card

sudo tar xvfJp ~/temp/void-rpi2-PLATFORMFS-20181111.tar.xz -C /mnt
sudo sync

--add the following lines to /mnt/etc/fstab--

/dev/mmcblk0p1  /boot  vfat  defaults  0  0

NOTE: I now skip this step. It appears that updating the installed packages (xbps-install -Su) caused files to be overwritten in /mnt/boot and this caused my raspberry pi not to boot. We can avoid this happening and manually manage the install firmware files by not mounting it at boot.


copy the latest firmware

cd ~/temp/firmware
sudo rm -rf /mnt/boot/*
sudo rsync -r ./boot/ /mnt/boot/
sudo sync

create config.txt and cmdline.txt files

/mnt/boot/config.txt

dtoverlay=vc4-fkms-v3d
max_framebuffers=2
max_usb_current=1
gpu_mem=256

/mnt/boot/cmdline.txt

root=/dev/mmcblk0p2 rw rootwait console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 loglevel=4 elevator=noop

unmount the partitions

sudo umount /mnt/boot /mnt

put the sd card into an rpi 4 and it should boot!

@frmoronari
Copy link

very fine solution.
i have a boot inmy rasp4 4gb.
lets go to configurations.
thanks for sharing this article.

@dreamcat4
Copy link

[UPDATE] ah, it seems rpi4 image is now officially available for download here:

https://voidlinux.org/download/

after clicking onto the 'arm platforms' tab

Screenshot from 2021-12-13 14-39-33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment