Enable kernel module for rtw_8821

I’m trying to use a RealTek WiFi chip that doesn’t seem to be supported in the UC20 amd64 at least. it is working just fine on Classic, but not showing up on UC.

Here are the details:

$ lspci -v
01:00.0 Network controller: Realtek Semiconductor Co., Ltd. RTL8821CE 802.11ac PCIe Wireless Network Adapter
        Subsystem: AzureWave RTL8821CE 802.11ac PCIe Wireless Network Adapter
        Flags: bus master, fast devsel, latency 0, IRQ 130
        I/O ports at 4000 [size=256]
        Memory at 90100000 (64-bit, non-prefetchable) [size=64K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint, MSI 00
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [148] Device Serial Number [redacted]
        Capabilities: [158] Latency Tolerance Reporting
        Capabilities: [160] L1 PM Substates
        Capabilities: [170] Precision Time Measurement
        Capabilities: [17c] Vendor Specific Information: ID=0003 Rev=1 Len=054 <?>
        Kernel driver in use: rtw_8821ce
        Kernel modules: rtw88_8821ce

Is there any way to easily enable this in your own disk image while still using Secure Boot?

1 Like

Do you know if the module is in the 20/stable track of the pc-kernel snap? If not, that would be the first step is getting it included there. If it’s already there you can load it from an unconfined shell via modprobe. If you need to load the kernel module from a strictly confined snap, you can do so very soon with the very new and very shiny kernel-module-load interface (as opposed to the existing and deprecated kernel-module-observe interface). Docs for that interface should appear soon, but in the meantime you can take a look at the PR here: https://github.com/snapcore/snapd/pull/10977

My impression is that it is not included:

$ sudo modprobe rtw88_8821ce
modprobe: FATAL: Module rtw88_8821ce not found in directory /lib/modules/5.4.0-91-generic

I’m struggling to find the actual code base for the pc-kernel snap. The Snapcraft listing is lacking a link to the respective GitHub or LP project

The source for the kernel snap is actually just a Makefile which pulls in kernel debs. If you can figure out which debian package the module comes from on classic that may help in identifying what additional kernel debs might need to be added to the snapcraft.yaml Makefile to enable this.

The driver appears to be provided by ‘linux-modules-extra’.

$ dpkg-query -S 'rtw88_8821ce'
linux-modules-extra-5.11.0-27-generic: /lib/modules/5.11.0-27-generic/kernel/drivers/net/wireless/realtek/rtw88/rtw88_8821ce.ko

Can you file a bug against the kernel at https://bugs.launchpad.net/ubuntu/+source/linux/+filebug with this information? (that the kernel module is not included in the 20/ track kernel snap but is available in linux-modules-extra). If the bot says you need to attach logs, just ignore it and set the bug back to New

Thanks – done:

1 Like

Hi, are there any instructions on how to actually build it - the same version UC 20 uses?

I cloned the kernel for focal from launchpad. Snapcraft.yaml seems incomplete - it’s missing build-base, version comes from CI I guess, I am not sure what branch is used for stable releases.

After I added build-base I can’t build it with the following error anyhow:

❯ ❯ snapcraft --destructive-mode
Failed to load plugin: unknown plugin: 'kernel'

try using @ondra’s local kernel plugin for core20 kernel snaps:


@ogra I had a chat with @ondra about this earlier this week. His concern with side-loading a module like this is that it could a situation where the kernel updates, but the module hasn’t been updated (since it’s part of the snap) thus causing the device to lose connectivity.

oh, i understood above you are building a complete kernel snap … was that wrong ?

Ok, I cloned it and put it to focal/snap/plugins. Am I doing something completely wrong?

❯ snapcraft snap --destructive-mode Loaded local plugin for kernel The plugin used by part ‘kernel’ does not support snaps using base ‘core20’.

Just for test, I set the base to core18:

❯ snapcraft snap --destructive-mode Loaded local plugin for kernel Err linux-firmware_1.190.6_all.deb
404 Not Found [IP: 80]
Fetched 0 B in 0s (0 B/s)
Package fetch error: The item ‘/home/sergey/.cache/snapcraft/download/linux-firmware_1.190.6_all.deb’ could not be fetched: 404 Not Found [IP: 80]

Am I doing something completely wrong here?

try using build-base: core20 instead of base

Oh my bad. Then please ignore :slight_smile:

That’s exactly what I did. Steps here:

  1. Cloned kernel from launchpad - https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal
  2. Modified snapcraft.yaml: changed version, name of the snap and added build-base:
name: screenly-pc-kernel
version: '1.0'
version-script: |
    . debian/debian.env
    dpkg-parsechangelog -l $DEBIAN/changelog -S version
summary: The Ubuntu generic Linux kernel
description: This Ubuntu generic Linux kernel
grade: stable
confinement: strict
type: kernel
build-base: core20

    plugin: kernel
    source: .
    source-type: git
    kconfigflavour: generic
      - CONFIG_RTW88_CORE=m
      - CONFIG_RTW88_8821CE=m
      - CONFIG_RTW88_PCI=m
    override-build: |
      cp debian/scripts/retpoline-extract-one \
      snapcraftctl build
    kernel-with-firmware: false
    plugin: nil
      - linux-firmware
      lib/firmware: firmware
      - -usr
      - -lib
      - cpio
      - libssl-dev
  1. Cloned the kernel plugin you linked and put it to the focal/snap/plugins
  2. Ran snapcraft --destructive-mode
  3. Got an immediate error:
❯ snapcraft snap --destructive-mode
Loaded local plugin for kernel
The plugin used by part 'kernel' does not support snaps using base 'core20'.

@ondra any hints ?

Just a followup, kernel-module-load will be available starting in snapd 2.54, you can see docs published here: The kernel-module-load interface (eventually that will be published on snapcraft.io/docs soon too)

Yeah, I figured that part out. https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal - this was the wrong repo - I guess it’s supposed to be used to build it from scratch.

This one has the snap that’s just installing packages.

I was able to make a snap just few days ago out of that.

Now it also fails after a new commit was pushed updating kernel version.

apt-get download linux-firmware wireless-regdb linux-image-uc20-efi-generic linux-image-5.4.0-97-generic linux-modules-5.4.0-97-generic
E: Unable to locate package linux-image-5.4.0-97-generic
E: Couldn't find any package by glob 'linux-image-5.4.0-97-generic'
E: Couldn't find any package by regex 'linux-image-5.4.0-97-generic'
E: Can't select candidate version from package linux-modules-5.4.0-97-generic as it has no candidate
make: *** [Makefile.efi:33: prepare-kernel] Error 100

Running with --debug I do see that indeed this package does not exist. I guess it comes from here: http://ftpmaster.internal/ubuntu.

So I tried downgrading. Also does not work.

KIMGVER=$(apt-cache show linux-image-uc20-efi-generic | sed -n -e 's/^Version: \([^+]*\)\(+.*\)\?/\1/p'|sort -V|tail -1); \
test -n "$KIMGVER" || ( echo "Unable to extract KIMGVER, exit"; false; ); \
if [ "$KIMGVER" != "5.4.0-96.109.1" ]; then \
  echo "Version mismatch:\nInstalled: $KIMGVER Requested: 5.4.0-96.109.1"; \
  false; \
KIMGVER: 5.4.0-97.110.1
Version mismatch:
Installed: 5.4.0-97.110.1 Requested: 5.4.0-96.109.1
make: *** [Makefile.efi:53: version-check] Error 1
Failed to build 'kernel'.

Anyone I can ping for help here? Very not obvious how to fix this.

Hi guys.

I was able to build a custom kernel with this module included.

I used the rtl8821ce-dkms package. But the module refuses to load because it’s not signed.

Is there any chance to include that module in focal kernel modules, so I don’t need to build it?

Currently, I’m a bit lost because it seems that only hirsute includes the module I need.