Self-building an LE image with RTL8852CU support

  • My Raspberry Pi 4 was getting terrible wifi reception and the cheapest way I could figure to improve it was to buy a cheap wifi adapter off of amazon.

    I bought an "AX5400M" wifi 6e usb adapter with external antennas, hooked it up and... nothing.

    lsusb showed the device with an ID of 0bda:c832 and dmesg showed it was being recognized as a wifi adapter, but it wasn't actually accessible.

    Some googling indicated this chipset is _very_ new and there is practically no support for it anywhere, but someone emailed realtek and got a linux driver for it.

    Re: Realtek RTL8832CU compatibility (Linux Wireless)

    GitHub - lwfinger/rtw8852cu
    Contribute to lwfinger/rtw8852cu development by creating an account on GitHub.
    github.com

    Well, you can't just build a kernel module on your libreelec box because the build toolchain isn't installed and there's no way to install it, so here's what I did to build a new libreelec image with the new kernel module pre-installed.

    Prerequisites are some disk space and docker. I did this on my linux desktop. These were the primary docs I used :

    https://wiki.libreelec.tv/development/build-basics

    LibreELEC.tv/tools/docker at master · LibreELEC/LibreELEC.tv
    Just enough OS for KODI. Contribute to LibreELEC/LibreELEC.tv development by creating an account on GitHub.
    github.com

    First, pull down the libreelec repository.

    Code
    cd ~
    git clone https://github.com/LibreELEC/LibreELEC.tv.git
    cd LibreELEC.tv

    Then you will need to create a build package for the driver I found above. I placed this file into my repo at the location http://LibreELEC.tv/packages/linux-drivers/rtw8852cu/package.mk

    PKG_VERSION is the short hash from the commit you want to use.

    Even though this repo had no releases, I found you can still download a tar.gz of the contents using the format https://github.com/lwfinger/rtw8852cu/archive/0d4e209.tar.gz (again, the short sha of the commit for the filename). I got the PKG_SHA256 by downloading that file with curl and running 'sha256 0d4e209.tar.gz'. If you want to build this exact module, you probably want to check to see if there's a newer commit on the driver. When I made this file the most recent commit was only an hour prior so it may still be under development.

    Okay, now that I have my build package, I also had to edit my additional_drivers directives in two places to get the module to be automatically loaded.

    I learned this from this thread : Assistance required recompiling LibreELEC with rtl88x2bu driver

    The two files to edit are distributions/LibreELEC/options and since I'm running a Raspberry Pi, projects/RPi/options.

    At the end of each of these files, add the following line :

    Code
    ADDITIONAL_DRIVERS+=" rtw8852cu"

    That's a +=, so it will append your module to whatever that string presently holds.

    My build configuration is now complete, so it's time to actually build the image. From the LibreELEC.tv directory, run the following command :

    Code
    docker run --rm --log-driver none -v `pwd`:/build -w /build -it -e PROJECT=RPi -e DEVICE=RPi4 -e ARCH=arm libreelec make image

    This will run for a while and then place a .img.gz image into the http://LibreELEC.tv/target directory that you can burn in your normal way.

    I'm surprised since it was my first time building LibreELEC but it worked first time and now my wifi reception is great.

    Hope this helps someone!