Ubuntu Desktop freezing with Raspberry PI: how to fix

4.7
(21)

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

Raspberry PI 4 model B image

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!

How useful was this post?

Click on a star to rate it anonymously!

Average rating 4.7 / 5. Vote count: 21

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?