Installing and configuring Fedora on the CM4
Fedora compared to Raspberry Pi OS
Fedora added support for the Raspberry Pi 4 (including the CM4) with release 37. At the time of writing (January 2025) the current version is release 41. It’s less mature on the CM4 than Raspberry Pi OS, which is the offical OS for the Raspberry Pi.
Fedora has some advantages, which I think give it the potential in the long-term to be a better platform than Raspberry Pi OS.
- Fedora has a strong upstream focus, particularly for the kernel.
- RedHat has strong expertise PTP and NTP. In particular, the maintainer of chrony (an NTP implementation) works for RedHat.
- Fedora includes Cockpit, which is a very nice web interface for server administration.
- Fedora has an IoT variant; this provides a non-traditional immutable approach to an OS, which could be a more robust approach when a CM4 is being used as a PTP or NTP appliance (although I haven’t tried this yet).
Fedora currently has some disadvantages compared to Raspberry Pi OS
- the documentation specific to the Raspberry Pi and particularly the CM4 is not as good (this page is trying to help with that)
- it relies on u-boot, which assumes that primary UART (
dev/ttyAMA0
) will be used as a serial console; this is a big problem if you are using a GPS hat that is designed also to use the primary UART - it boots a lot slower
Fedora always has the latest version of chrony and chrony can make use of the CM4’s PTP hardware support for NTP, without needing SatPulse. Fedora is a good basis for experimenting with that. There is a separate page for configuring chrony without SatPulse. Unfortunately, chrony’s PTP hardware support is not yet fully working on the CM4.
Note that Fedora includes linuxptp version 4. This requires using the option ptp_minor_version 0
, which can be specified in /etc/ptp4l.conf
.
RAM and storage requirements
CM4 RAM sizes range from 1Gb to 8Gb; eMMC sizes range from 8Gb to 32Gb.
8Gb eMMC is enough for just running a NTP/PTP server, but can get tight during upgrades.
From a cursory look at /proc/meminfo
: 8Gb RAM is more than is useful: 4Gb should be plenty; 2Gb should be OK; 1Gb would be tight.
I would recommend using a CM4 Lite with Fedora Server. This allows using an SD card, which can be as big as you want. It is also a bit easier and quicker to install.
Installation and configuration overview
The installation process needs a separate desktop computer, which can be Windows, Linux or Mac.
We can split the installation process into the following stages:
- on the desktop system, select and download an appropriate image
- make the CM4 storage available as a disk on the desktop system
- on the desktop system, write the image to this disk
- boot the CM4 for the first time from eMMC and perform initial setup
- perform CM4-specific configuration
Fedora has good documentation for installing on a SBC, but it doesn’t address stage 2 for the CM4, which has internal eMMC storage (except in the CM4 Lite version).
The normal Fedora approach for step 4 requires using an HDMI monitor and keyboard connected to the CM4 to do the initial setup, most importantly to setup a user account. You cannot just skip this, since the image does not allow ssh login without some configuration for security reasons. However, it is possible to avoid this requirement if you really want to (in my case, I wanted to install a Fedora 39 nightly image, but HDMI output wasn’t working properly). This requires that step 3 be done using the arm-image-installer program
, which has options that can configure the image to allow you to ssh in as root. But arm-image-installer
is available only on Fedora, which implies that you need to use a desktop computer that is running Fedora.
Select and download the image
Fedora has three editions that could potentially be used with the CM4: Workstation, Server and IoT. This guide focuses the Server edition.
To download, visit getfedora.org on the desktop. Then
- Follow the link to download Fedora Server
- Go to the section for
For ARM® aarch64 systems
- Download the raw
raw.xz
image
There is also a alternative version (Fedora calls it a spin) called Fedora Minimal, which is comparable to Raspberry Pi OS Lite. This is not as much tested as Fedora Server, but is worth considering if you have a CM4 with an eMMC. This guide should mostly work with the Minimal spin also.
Making CM4 storage accessible from desktop
In this stage, we need to make the storage used by the CM4 available as a disk on the desktop system.
The CM4 is available with or without an eMMC. A CM4 without an eMMC is sometimes called a CM4 Lite. Most of the CM4s that I have seen available for sale have an eMMC. But if you have a choice, I would recommend using a CM4 Lite with Fedora.
A CM4 without an eMMC uses an SD card for storage. In this case, all you have to do for this stage is to plug the SD card into your desktop.
If you have a CM4 with an eMMC, things are more complicated. (Note that you cannot use an SD card to boot a CM4 that has an eMMC.) We need to connect the CM4 using USB to the desktop and then boot it in a way that makes the eMMC appear as a disk on the desktop. This requires running the rpiboot program on the desktop.
The steps are:
- Install rpiboot on the desktop
- Power on the CM4 so it will boot from USB rather than from eMMC
- Run rpiboot on the desktop
- Identify the disk on your desktop corresponding to the CM4
The steps other than step 2 depend on which desktop OS you are using. The details of Step 2 depend on the carrier board you are using. For the official IO board, the procedure is:
- Disconnect all cables from the CM4 IO board.
- Locate the J2 jumpers on the CM4 IO board. This is the 14-pin, 2 row set of pins located in the rear, center of the board. Connect the leftmost two pins, which are labelled
Fit jumper to disable eMMC Boot
. I use a female-female Dupont cable for this. - Connect a USB port on your desktop to the Micro USB port on the CM4 IO board (to the right of the 2 USB A ports, labeled
SLAVE
on the Waveshare cases). - Connect power to the CM4.
Note that after writing the image and before booting from eMMC, you will need to remove the jumper disabling eMMC boot, as well as disconnecting the Micro USB cable.
rpiboot on Fedora desktop
There’s a Copr repository with rpiboot
. Install from this:
sudo dnf copr enable lsevcik/usbboot
sudo dnf install -y usbboot
After powering on the CM4 so it boots from USB as described above, check that your desktop is recognizing the CM4 by doing
sudo dmesg | grep BCM2711
Then, in the usbboot directory, do
sudo rpiboot
The output should look something like this:
RPIBOOT: build-date Aug 31 2023 version 20221215~105525 c4b12f85
Waiting for BCM2835/6/7/2711...
Loading embedded: bootcode4.bin
Sending bootcode.bin
Successful read 4 bytes
Waiting for BCM2835/6/7/2711...
Loading embedded: bootcode4.bin
Second stage boot server
Cannot open file config.txt
Cannot open file pieeprom.sig
Loading embedded: start4.elf
File read: start4.elf
Cannot open file fixup4.dat
Second stage boot server done
After rpiboot
` exits, the CM4 should show up as a disk. You can run
udisksctl status
to find out which disk. The output should include a line starting with RPi
like this:
RPi-MSD- 0001 0001 d9e799b6 sdc
The last column says which disk it is, in this case, /dev/sdc
.
rpiboot on non-Fedora desktop
You can follow the offical Raspberry Pi instructions. Jeff Geerling also has a useful blog post and video on this.
Note that Ubuntu packages rpiboot, so you can install it with
sudo apt install rpiboot
rather than building from source.
Writing the image
Fedora desktop
If you are using Fedora on your desktop, you can use arm-image-installer
to write the image.
First, install it:
sudo dnf install arm-image-installer
Now, run it. The command looks something like this:
sudo arm-image-installer --target=rpi4 --image=Fedora-Server-41-1.4.aarch64.raw.xz --media=/dev/sdX --addkey=/home/jjc/.ssh/id_ecdsa.pub --resizefs
You will need to adjust the command:
- you will always need
--target=rpi4
for the CM4 - the
--image
option specifies the image to write; it expects a compressed.xz
image - the
--media
option specifies the device name where you made the CM4 storage available in the previous stage - the
--addkey
option is only necessary if you want to be able to do initial setup using SSH rather than using a monitor and keyboard connected to the CM4; the argument for the--addkey
option needs to point to your public SSH key (I generated mine withssh-keygen -t ecdsa -b 521
) - the
--resizefs
argument resizes the image to match the actual size of the disk
It takes about 25 minutes for arm-image-installer to write the Fedora Server image to internal eMMC. Writing to an SD card is much quicker.
Windows desktop
On Windows, balenaEtcher is convenient, because it can automatically decompress .xz
files.
First boot and initial setup
Before booting from eMMC for the first time, you obviously need to do either
- remove the jumper that disabled eMMC boot (for a CM4 with internal eMMC), or
- insert the SD card (for a CM4 without an internal eMMC)
The offical Fedora documentation has a good description of the normal setup process, which requires connecting an HDMI monitor or mouse. Note that the boot process will take a few minutes, and that during the process the screen will go blank for a while; be patient, and wait for the initial setup prompt to appear.
If you have decided not to use the normal processs, then you need to have used the appropriate options with arm-image-installer when writing the image. You will need to figure out what IP address it got from DHCP; one method is to look at your DHCP server’s log or lease file. You can then ssh in as root, and perform initial setup on the command-line as follows:
# Set the time zone. I use this.
timedatectl set-timezone Asia/Bangkok
# Set the hostname. I name my computers after cheeses.
hostnamectl set-hostname pecorino
# We don't need to use the normal initial setup process.
systemctl disable initial-setup
# Add a user account. Here jjc is the user name.
groupadd jjc
useradd -g jjc -c "James Clark" -G wheel -m jjc
# This will prompt to enter a password
passwd jjc
Note that you shouldn’t do the manual setup over ssh while the normal setup process is working.
CM4-specific setup
Fedora has some documentation on Raspberri Pi HATs that is also applicable to the CM4 with an IO board (even without additional HATs).
TODO: The serial port explanation didn’t seem consistent with what I had understood about the serial ports from the official Raspberry Pi documentation.
After making the changes in this section, I recommend shutting down (with shutdown -h now
) and power cycling.
TODO: Not sure if this is strictly necessary, but I had problems when I just rebooted without power cycling.
Enable use of config.txt
To enable use of config.txt
, in a similar way to Raspberry Pi OS, we have to make Fedora use the firmware device tree rather than the kernel device tree.
First, remove the /boot/dtb
symbolic link:
sudo rm /boot/dtb
Next, create /etc/u-boot.conf
with the line
FirmwareDT=True
TODO: I had problems switching back to use the kernel device tree. Should be just a matter of
restoring the /boot/dtb
link and removing /etc/u-boot.conf
, but that didn’t appear to work for me.
Realtime clock
Add the following to the bottom of /boot/efi/config.txt
:
dtoverlay=i2c-rtc,pcf85063a,i2c_csi_dsi
After rebooting, check the RTC
sudo hwclock --show
Also check that the current date is correct:
date
Fan controller
Add the following to the bottom of /boot/efi/config.txt
:
dtoverlay=i2c-fan,emc2301,i2c_csi_dsi
The fan controller needs the emc2305
module. To load the module right away use
sudo modprobe emc2305
To ensure the module is loaded on boot, create a file /etc/modules-load.d/fan.conf
containing the line
emc2305
When the fan controller is recognized, you should see a file ` /sys/class/thermal/cooling_device0`. If you have a fan, the difference will be immediately audible.
TODO: The emc2305 module is not autoloading because the emc2305 driver is missing an of_device_id table. Need to test a patch.
UART
See separate page for UART configuration.
Post installation
Update packages
sudo dnf update
You can make use of the Cockpit web administration interface by connecting to port 9090 on the CM4.