User Tools

Site Tools


doc:appunti:hardware:rtl8852be_on_debian_12

RTL8852BE WiFi adapter on Debian 12 Bookworm

The Realtek WiFi Network Controller RTL8852BE is not supported by the 6.1.0 Linux kernel shipped with Debian 12 Bookworm. In this page you can find the steps required to compile and install the required kernel module and firmware.

  • Disable the Secure Boot in BIOS.
  • Compile the rtw89-dkms Debian package into a chroot environment.
  • Install the rtw89-dkms package into the target host, it will compile and install the kernel modules,
  • Download and install the rtw8852b_fw-1.bin firmware.

Secure Boot in BIOS A self compiled kernel module is strictly tied to the running kernel, so it must be re-compiled whenever the kernel package is upgraded. The official Debian kernel is properly signed, so it runs even if the Secure Boot option is enabled into the BIOS. But the self compiled kernel module is a non-trusted software running at kernel level, so it requires that the Secure Boot into the BIOS to be disabled.

Debian provides the Dynamic Kernel Module Support, which automatically recompiles all DKMS modules if a new kernel version is installed. This allows drivers and devices outside of the mainline kernel to continue working after a Linux kernel upgrade

Creating the chroot environment

It is possible to create a DKMS source package for the rtw_8852be kernel module starting from the recent Realtek driver sources. This operation requires the installation of several packages; if you don't want to clutter the target host, you can do this task on a different host or into a chroot environment.

Using the debootstrap command (from the Debian package of the same name) it is possibile to initialize a separate (chroot) environment for this task. The target host will not be cluttered by the packages installed into the chroot environment and the resulting DKMS package can be used on several target hosts. The drawback is that you will consume about 1.2 Gb of disk space.

mkdir -p /usr/local/src/chroot/dkms
debootstrap bookworm /usr/local/src/chroot/dkms http://deb.debian.org/debian/

Creating the dkms source package into the chroot

To enter the chroot environment is as simple as issuing the command:

chroot /usr/local/src/chroot/dkms

You exit the chroot using the exit command.

Into the chroot install the required packages:

apt install locales
dpkg-reconfigure locales
apt install dh-dkms debhelper build-essential devscripts git-build-recipe

Then download the source code of the kernel module and compile the DKMS Debian package:

cd /usr/local/src
git clone https://github.com/lwfinger/rtw89.git
cd /usr/local/src/rtw89
git clean -xfd
git deborig HEAD
dpkg-buildpackage -us -uc

The git clean -xfd does a complete cleanup of the source tree. The git-deborig(1) script (provided by the devscripts Debian packages), creates the ../rtw89_1.0.2.orig.tar.xz archive from the GIT main branch. The .orig.tar.xz archive is required to build a complete Debian package.

At the end of the process you will find the ../rtw89-dkms_1.0.2-3_all.deb packages, which is the one you have to install into the target system.

Installing the DKMS package into the target system

Into the target host you need some packages that are required to build the kernel module from the DKMS sources. You need also to install the Linux headers of the same version of your running kernel:

apt install dkms linux-headers-6.1.0-25-amd64

Now you are ready to install the DKMS package, this will automatically compile the binaries of the kernel modules and install them into /usr/lib/firmware/rtw89/:

dpkg -i /usr/local/src/chroot/dkms/usr/local/src/rtw89-dkms_1.0.2-3_all.deb

If you want to load the kernel module without a reboot, just run the commands:

depmod -a
modprobe rtw_8852be

You may encounter a problem if Secure Boot is disabled:

modprobe: ERROR: could not insert 'rtw_8852be': Key was rejected by service 

You can inspect the status of Secure Boot with the mokutil utility (from the same name Debian package):

mokutil --sb-state
SecureBoot enabled

Providing the firmware

If you have installed the non-free Debian package firmware-realtek, the kernel module will automatically load the /lib/firmware/rtw89/rtw8852b_fw.bin, as logged by the kernel:

rtw89_8852be 0000:02:00.0: firmware: failed to load rtw89/rtw8852b_fw-1.bin (-2)
rtw89_8852be 0000:02:00.0: firmware: failed to load rtw89/rtw8852b_fw-1.bin (-2)
rtw89_8852be 0000:02:00.0: Direct firmware load for rtw89/rtw8852b_fw-1.bin failed with error -2
rtw89_8852be 0000:02:00.0: firmware: direct-loading firmware rtw89/rtw8852b_fw.bin
rtw89_8852be 0000:02:00.0: loaded firmware rtw89/rtw8852b_fw.bin

But this is a non working fall-back, you can confirm that the WiFi adapter is not working:

ifconfig wlan0 up
iwlist wlan0 scan
wlan0     Interface doesn't support scanning : Network is down

You can download the required firmware from the kernel Git repository and save it into /usr/lib/firmware/rtw89/; there are no directories for locally installed firmwares.

Signal level not reported

If everything is working, you can check for available WiFi networks using iwlist:

ifconfig wlan0 up
iwlist wlan0 scan

The current module (rtw89 1.0.2) does not support the signal level reporting, for every ESSID you see the following:

Quality=70/70  Signal level=0 dBm

Web References

doc/appunti/hardware/rtl8852be_on_debian_12.txt · Last modified: 2024/10/04 15:04 by niccolo