bgsmith
Posts: 4
Joined: Mon Nov 23, 2020 4:28 pm

F33 Headless and RPI 4 - Brief How To (Revised)

Fri Nov 27, 2020 11:07 pm

Below are brief notes on how I install Fedora 33 to run on a Raspberry PI 4 8 Gb. I have completed this process twice on 2 separate microSD cards so it appears to be repeatable. Important caveat - this is only working (so far) for microSD cards and not for a USB attached SSD. ** Note ** - booting from USB is solved. Please see update appended at end of post.; Revision also appended at the end with a few recommended changes to the config.txt file. **

I am using Samsung EVOPlus 32 microSD cards. My workstation is running Fedora 33 Workstation. The RPI4 is attached via network cable to nework. I have not tried wireless.

Important note: for RPi4 with either 4GB or 8GB you will need to attach a monitor and keyboard at least once to turn off the 3GB ram limit the UEFI boot manager imposes by default. So this is not completely headless at this time (Feb 2021). My understanding is that the 3 GB limit is imposed to deal with older linux kernels (e.g Fedora 31 and early 32) and is not needed for more current kernels. At somepoint I would expect the UEFI maintainers to remove this constraint. Please note that if you have multiple RPi4s then if you remove the 3GB limit via the boot manager user interface on one RPi4 and then copy the UEFI files to other RPi4s and they will not have the 3GB limit. I *think* the specific file is RPI_EFI.fd.

This process installs Fedora 33 Minimal. I have used this on Fedora-Minimal-33-1.2 and Fedora-Minimal-33-1.3 (this is the current release as I write this note).

Three sources provided essential steps:
1. https://opensource.com/article/20/5/dis ... spberry-pi and
2. https://www.reddit.com/r/Fedora/comment ... &context=3
3. https://wiki.debian.org/RaspberryPi/qemu-user-static

Highlevel Steps
If using a USB mass storage device (e.g. USB attached SSD), the substitute that device for the microSD below. See the tip at the end of the email for successful boot from the USB device.
  1. Download image and UEFI firmware
  2. Write image to microSD and update firmware files in the EFI partition.
  3. Chroot to the root partition and make a few changes.
  4. Place microSD card in RPI4 and boot to Fedora 33.
Steps
  1. Download current Fedora Minimal (e.g.Fedora-Minimal-33-1.3.aarch64.raw.xz) from https://alt.fedoraproject.org/alt/.
  2. Download the current UEFI firmware for raspberry 4 from https://github.com/pftf/RPi4/releases. I used v 1.21 which was the most current. Unzip this file in a temporary location (e.g. ~/Downloads/rpi4efi).
  3. Verify with checksum following the usual steps.
  4. Insert the microSD card into your workstation or laptop.
  5. I typically use the Gnome disks GUI utility to find out what device the microSD card is assigned, e.g. /dev/sdf.
  6. Verify the name of your public ssh key (e.g.
  7. Write Fedora minimal to the microSD card using arm-image-installer. In the example below, the microSD card is at /dev/sdg, my public ssh key is id_ed25519.pub, I target an RPI 4.

    Code: Select all

    sudo arm-image-installer --image=Fedora-Minimal-33-1.3.aarch64.raw.xz --media=/dev/sdg --target=rpi4 --addkey=/home/bgsmith/.ssh/id_ed25519.pub --norootpass --relabel --resizefs
  8. The arm-image-installer will create 3 partitions on the microSD: a FAT16 parition for EFI, the boot parition (ext4), and a root partition (ext4). The --resizefs option above will result in the root partition taking all available space on the microSD card. This will take a few minutes to complete.
  9. I eject and reinsert the microSD card (this is probably not needed). This will mount all 3 partitions on your local computer. A Fedora workstation will mount these partitions at /run/media/username (e.g. /run/media/bgsmith on my machine). Again the disks utility can be used to match the UUIDs to specific partitions. The UUID is used by default to name each mounted partition. In the image below the microSD card is highlighted in disks. The partitions are also displayed on the command line above.
    partitions1.jpg
    partitions1.jpg (115.77 KiB) Viewed 5929 times
  10. CD into the EFI partition. This is subdirectory 3C1-8F5F in the picture above. Rename config.txt to config.txt.save.
  11. In the EFI partition, copy the updated firmware files downloaded in step 2 above. This will replace several files and add a new config.txt file..

    Code: Select all

    cp -r ~/Downloads/rpi4efi/* .
    .
  12. In the EFI partition edit config.txt. It should have the following contents:

    Code: Select all

    arm_64bit=1
    enable_uart=1
    uart_2ndstage=1
    enable_gic=1
    armstub=RPI_EFI.fd
    disable_commandline_tags=1
    disable_overscan=1
    device_tree_address=0x1f0000
    device_tree_end=0x200000
    dtoverlay=miniuart-bt
    
    Change the contents to look like the contents below. The two changes are an addition of the kernel line a the top and comment out the armstub line. Save and exit the file. See update at end of this post with corrections.

    Code: Select all

    kernel=rpi4-u-boot.bin
    arm_64bit=1
    enable_uart=1
    uart_2ndstage=1
    enable_gic=1
    # armstub=RPI_EFI.fd
    disable_commandline_tags=1
    disable_overscan=1
    device_tree_address=0x1f0000
    device_tree_end=0x200000
    dtoverlay=miniuart-bt
    
  13. Back out of the EFI partition (ie to the /run/media/your-user-name subdirectory holding the 3 partition mount points).
  14. Chroot into the root partition (37ed1bb9-b4c7-4a9b-b9bd-597238088988 in the example above) using systemd-nspawn. systemd-nspawn will launch a container hosting the aarch64 root. QEMU will also need to be installed to support this (qemu-user-static).

    Code: Select all

    sudo systemd-nspawn -D ./37ed1bb9-b4c7-4a9b-b9bd-597238088988/ bin/bas
    The result should look like:

    Code: Select all

    [bgsmith@pico bgsmith]$ sudo systemd-nspawn -D ./37ed1bb9-b4c7-4a9b-b9bd-597238088988/ bin/bash
    Spawning container 37ed1bb9-b4c7-4a9b-b9bd-597238088988 on /run/media/bgsmith/37ed1bb9-b4c7-4a9b-b9bd-597238088988.
    Press ^] three times within 1s to kill container.
    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]# 
    
  15. Verify that aarch64 is the container runtime:

    Code: Select all

    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]# uname -a
    Linux 37ed1bb9-b4c7-4a9b-b9bd-597238088988 5.9.10-200.fc33.x86_64 #1 SMP Mon Nov 23 18:12:50 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]# 
    
  16. Run the following unlink commands. This will disable the first boot setup process. The setup process will block the headless session unless disabled.

    Code: Select all

    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]# unlink /etc/systemd/system/graphical.target.wants/initial-setup.service
    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]# unlink /etc/systemd/system/multi-user.target.wants/initial-setup.service
    [root@37ed1bb9-b4c7-4a9b-b9bd-597238088988 /]
    
  17. Exit the container: Press ^] three times within 1s to kill container.
  18. Safely eject the microsSD card, remove and insert in the RI 4.
  19. Power on the RPi4. The red and green led lights on one end will variously blink, or stay steady, or go out. The network leds will stay steady for several minutes and go out at least twice. This whole process can take several minutes. At the end, the red and green leds will go out and the network lights will start to blink. Fedora is booted at this point and requesting an IP from your network dhcp service.
  20. You should be able to ssh in as root once you determine the IP. No password is needed as your public ssh key was installed into the root .ssh directory. Free at the command line returns 8 gb on my system.

    Subsequent boots are much faster.

    I hope this helps. Please keep in mind the caveats noted above: I have not tested wireless, and the notes above are a bit sketchy.

    Addendums
    2 December 2020 - Since booting headless the first time requires disabling the initialization process, check to make sure the time zone is set correctly and consider setting a hostname, adding a normal user account (e.g. pi), and so on.

    13 December 2020 - The current workaround to booting headless from a USB attached device using the UEFI boot process is to leave a blank microsSD card in the RPI4. See https://github.com/pftf/RPi4/issues/37 and https://github.com/pftf/RPi4/issues/37 for more information. This workaround is current as of December 2020 but I would expect a fix in the UEFI code base at any time.

    14 February 2021 - Two changes to this How To are made here in this update. (1) The updates to config.txt noted above work but are unneeded. The config.txt file from the UEFI release does not need to be edited and should be as listed below. If you also append the additional config.txt lines as created by the Fedora aarch64 installer then be sure to comment out or delete the start_x=1 line.

    Code: Select all

    arm_64bit=1
    enable_uart=1
    uart_2ndstage=1
    enable_gic=1
    armstub=RPI_EFI.fd
    disable_commandline_tags=1
    disable_overscan=1
    device_tree_address=0x1f0000
    device_tree_end=0x200000
    dtoverlay=miniuart-bt
    
    (2) the blank microSD card is not needed if you make sure that the start_x=1 line in config.txt is commented out or deleted. The UEFI project does not include the fixup4x.dat or start4x.efi files but fedora does (at this time). The start_x=1 will guide the boot process to the older versions of start4x.efi included by fedora by passing the start4.efi file from the upstream UEFI release.
thanks
Last edited by bgsmith on Sun Feb 14, 2021 11:08 pm, edited 8 times in total.

tijuco2
Posts: 1
Joined: Wed Dec 02, 2020 5:25 am

Re: F33 Headless and RPI 4 - Brief How To

Wed Dec 02, 2020 5:30 am

Hey man, I just created this account to say thanks to you.
I bought my pi 4 today and I couldn't make it run F33.
Although the chroot thing didn't work for me, I went straight to the directories and deleted the symbolic links.

Again, thank you for taking the time and help us :!:

Return to “Pidora / Fedora”