Ubuntu Desktop freezing with Raspberry PI: how to fix
Last Updated on 2nd September 2023 by peppe8o
In this tutorial, I’m going to show you how to fix the screen freezing problem with some Ubuntu Desktop kernels on Raspberry PI 4 / 400. I’ve found these fixes while working on my tutorial Ubuntu Desktop and Raspberry PI 4: fast Home Computer Booting From SSD.
With the new Ubuntu Desktop becoming more and more a complete desktop client solution, I’ve found random freeze problems with my Raspberry PI 4 model B computer. After tests and googling the problems, I was able to solve them
The Freezing Issue
According to https://bugs.launchpad.net/ubuntu/+source/linux-raspi/+bug/1946368, this is a known bug on some Ubuntu kernel versions. Commonly, this issue happens when using high-resolution screens (higher than 1920×1080@60Hz). Some users report this issue also playing high-resolution videos and/or dragging applications to the sidebar. However, I found this problem happening in my Raspberry PI 4 model B even if simply browsing simple pages…
The issue comes from the default KMS, which appears to be unstable on Raspberry PI hardware. The workaround is enabling a “fake” KMS version, which limits the number of functions available for video output but avoids freezing.
Another problem that gets Ubuntu Desktop freezing on Raspberry PI comes with the USB power management module from recent kernels. It is a best practice to suspend devices (or part of them) when they are not used (idle mode). But with Raspberry PI and Ubuntu sometimes happens that, plugging multiple devices into USB ports, it starts not working or working not properly. The problem is more visible when you are running an OS booting from USB. This happens more frequently when both USB 3.0 ports are connected.
This wing procedure will deal with both issues, proving steps to solve them.
What is KMS (Kernel Mode-Setting)
As reported in Wikipedia, mode setting is a software operation that activates a display mode (screen resolution, colour depth, and refresh rate) for a computer’s display controller by using VESA BIOS Extensions or UEFI Graphics extensions (on more modern computers).
The display mode is set by the kernel.
In user-space mode-setting (UMS), a user-space process sets the display mode. Kernel mode-setting is more flexible and allows displaying of an error in the case of a fatal system error in the kernel, even when using a user-space display server. User-space mode setting would require superuser privileges for direct hardware access, so kernel-based mode setting shuns such requirement for the user-space graphics server.
Both Raspberry PI OS and Ubuntu use KMS.
Referring to a specific topic on Raspberry PI forum, the difference between “vc4-fkms-v3d” and “vc4-kms-v3d” is how it drives the video scaler (HVS), pixel valves, and output display blocks (HDMI/VEC/DSI/DPI).
- With vc4-fkms-v3d this remains with the firmware, and the firmware still allows DispmanX or MMAL to add extra layers.
- With vc4-kms-v3d, the Linux kernel is driving all that lot, and DRM prohibits multiple clients adding layers at the same time.
What is Usbcore Autosuspend
Kernel power management is described at kernel.org.
As described in the referred page, “Power Management (PM) is the practice of saving energy by suspending parts of a computer system when they aren’t being used. While a component is “suspended” it is in a nonfunctional low-power state; it might even be turned off completely. A suspended component can be “resumed” (returned to a functional full-power state) when the kernel needs to use it.”
Kernels include modules to control dynamic PM for each device. These modules allow managing power by the use of 4 main files which take names from their function: wakeup, control, and
autosuspend_delay_ms. The last file contains an integer value, which is the number of milliseconds the device should remain idle before the kernel will autosuspend it (the idle-delay time). Negative values mean never to autosuspend.
Step-by-Step Procedure
Fixing kms freezing
From a terminal session in your Raspberry PI, open the config.txt file to edit:
sudo nano /boot/firmware/config.txt
Identify the following line:
dtoverlay=vc4-kms-v3d
and change it to:
dtoverlay=vc4-fkms-v3d
Please note that the new string simply adds an “f” char before “kms”. Save and close.
Reboot your OS and the issue should be fixed now.
Fixing USB Auto Suspend
Open grub file from your terminal:
sudo nano /etc/default/grub
Identify the GRUB_CMDLINE_LINUX_DEFAULT. This should already include “quiet splash” values:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
append inside the brackets the “usbcore.autosuspend=-1” directive (remember to use a space to divide from “splash”). Your line should appear like the following:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash usbcore.autosuspend=-1"
Save and close. Still from terminal, update grub. From terminal:
sudo update-grub
Reboot your Raspberry PI.
What’s Next
If you are interested in more tutorials on how to use your Raspberry PI, you can take a look at Raspberry PI projects from peppe8o.com.
Enjoy!
Thanks a lot
I did the same and my problem was completely solved
👍👍👍👍👍👍
Thank you for your feedback, Ehsan
I am a Ubuntu noob coming from Windows (have some Cygwin and ancient Un*x experience), dabbling with a Raspberry Pi 400, hooking up to an old Dell FP2001 monitor, which is 1600×1200 @ 60Hz with a DVI-D input. I had screen freeze problems (seemingly triggered by mouse use) when running Ubuntu Desktop 21.10, and the solution above seemed to work great. Note that config.txt can be edited on Windows on the root of the RPi’s boot drive, which may be needed if the freezing happens before getting through the initial configuration of the RPi. I can’t be sure the USB suspend part mattered, but I did that part as well without incident. Also, I dabbled with Ubuntu Server 20.04.3 LTS 64-bit, and had display flakiness but not freezes, and the solution also seemed to work. Note that in that case its config.txt file suggests to add such user-configed lines to usrcfg.txt instead.
I have since moved on to trying the Raspberry Pi OS (having discovered that WSL on Windows gives me a workable playground for my Ubuntu needs) instead, so I have not tested this fix over much time, but it was very helpful to solve a frustrating problem.
Thank you for your feedback, Frank.
Sure, you can edit config.txt with whatever text editor, also externally from the Raspberry PI.
The kms should be influencing only Ubuntu Desktop distribution, so the Ubuntu server shouldn’t have this kind of issue. Also, Raspberry PI OS Desktop, which is a distribution maintained from Raspberry PI Foundation for Raspberry PI computer boards, doesn’t have this problem.
Enjoy your Raspberry PI! 🙂
Giuseppe
I just wanna join the other commenters in thanking you for these simple fixes.
The combination of a wired USB keyboard and a unifying Logitech receiver for a wireless mouse was seemingly so demanding that my Ubuntu installation literally froze on the setup screen while I was creating the password. The time when it would freeze wasn’t always that early but it was pretty random. It seems that it would usually happen after I opened an app or two. The device would also get unreasonably hot, which could be related.
Anyway, I was trying to use Vapor for server-side Swift, which I was unable to install on 32 or 64 bit Raspberry Pi OS.
Ubuntu was seemingly my only option.
Thanks for making it possible to install and use the OS 😆
Glad it helped you too Rob!
Trying to use Ubuntu as installed by the Raspberry Pi launcher, it would get to the first loading screen and freeze up before even letting me configure the OS. Switching to fake kms fixed it. Before the OS is configured, the config file is right on the root of the SD card. I was hoping they would have fixed this as i use the Pi for a remote windows client, but on the version of Rasp Pi OS I had originally used to make a Remote Thick Client, I also had to use fake-kms, so not an Ubuntu problem. Thank you!
I thought my freshly flashed Ubuntu was failing for bad cables, experiencing EBKAC, or pouting out of neglect, but NO! Getting it to be responsive to my touch and humming happily only required changing a single character in a config file.
THANK YOU! 💕
Happy this is helping so much people. Thank you for your feedbacks!
I was also strugling with using Ubuntu Desktop 64-bit – I gave it a try several times changing USB disks and using active USB …
I finally stumbled on your sollution, Thank You
Hmm.. Just installed Ubuntu 64-bit on my new Pi4.. Got the “freezing” issue, but when I open the config file (moved the SD to another Ubuntu machine) there is no “dtoverlay=vc4-fkms-v3d” line to edit?
Should I add it (with the “f”) ?
Hi Oskar,
I don’t know if something could have changed in a very last release. Anyway, you can certainly try adding it at the end (with the “f”)
All my thanks are belong to you!
Thanks, that fixed my issue with freezing!
You saved me. Thank you for that wonderful guide
Thank you so much! I waited several months for my pi to arrive and when it finally did it was freezing up. This fixed it.