Linux and rt3290

ven. 15 mai 2020

1. Situation

On a laptop "HP Pavilion", Ubuntu 20.04 is in offline mode. No way to turn it online.

The rfkill list command output shows the network card is hardware-blocked, and the command rfkill unblock ID does not work, the card remains hardware-blocked.

After various tests, it appears the laptop's wifi device has no driver (or no suitable driver). The device is RaLink rt3290.

2. Solution

2.1 Installing a v3 kernel on Ubuntu

First approach considered is, to use a 3.* kernel, since a quick search on Internet forums showed, rt3290 would work fine on a v3 kernel.

Details: https://askubuntu.com/questions/700214/how-do-i-install-an-old-kernel

2.1.1 What to do

Find the kernel you want here: https://kernel.ubuntu.com/~kernel-ppa/mainline

Then, download the headers and image you want (you typically want the three files that don't have 'lowlatency' in their names).

For example, to download 3.18.140 for amd64 architecture, the files are:

https://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.140/linux-headers-3.18.140-0318140_3.18.140-0318140.201905160849_all.deb

https://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.140/linux-headers-3.18.140-0318140-generic_3.18.140-0318140.201905160849_amd64.deb

https://kernel.ubuntu.com/~kernel-ppa/mainline/v3.18.140/linux-image-3.18.140-0318140-generic_3.18.140-0318140.201905160849_amd64.deb

Then, install it (in this order) with the command dpkg -i

2.1.2 Result

No way to make a Ubuntu 20.04 work fine with a v3 kernel. It might be possible though, but it failed in my case due to the kernel not seeing the SD card I was installing the system on (kernel panic soon after boot, due to the lack of root drive). Maybe the initramfs missed something?

2.2 Installing an old v4 kernel on Ubuntu

Ubuntu 20.04 runs correctly (at first sight ; no comprehensive tests done) with a 4.2 kernel.

I decided to have Ubuntu run on 4.2.8-wily kernel and compile rt3290 driver on it. I chose 4.2.8-wily arbitrarily.

2.2.1 v4.2.8 kernel

As is logical, you'll get the packages here:

https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2.8-wily

2.2.2 rt3290 sources

The below URL gives interesting information as to how to add rt3290 driver to Ubuntu.

https://askubuntu.com/questions/253632/how-do-i-get-a-ralink-rt3290-wireless-card-working

and:

https://forum.ubuntuusers.de/topic/nach-update-kein-wlan-mehr-433/2/#post-5561332

Driver sources:

https://github.com/the-dagger/RaLink-RT3290-Drivers-Ubuntu

https://drive.google.com/file/d/0Bw6He1mvtZ9GSHRMYjhSeVhUMWc/view

http://download853.mediafire.com/rla4e0xxxwfg/l3zoch2y1hbcali/RT3290.tar.gz

2.2.3 Result

Compilation does not work because the source is not PIC-friendly, whereas 4.2.8 kernel source is PIC enabled by default.

You can see it by updating linux source Makefile, tricking rt3290 source into believing the kernel is not PIC-enabled.

The patch is here: https://lists.ubuntu.com/archives/kernel-team/2016-May/077178.html

Compilation works fine and produces rt3290sta.ko, but of course there is no way to load it (it produces an error "bad format") as module is not fit for a PIC-enabled kernel. But this test is interesting, as it shows rt3290 compiles successfully with 4.2.8 headers.

2.3 Recompiling the Linux kernel

Following the result of paragraph 2.2, I then decided to recompile Linux kernel with PIC disabled, so that rt3290 driver could fit.

2.3.1 Downloading and preparing the source

As written on top of the page to download v4.2.8 given above, the source is available here:

git://git.launchpad.net/~ubuntu-kernel-test/ubuntu/+source/linux/+git/mainline-crack

The page gives you the commit ref to pull the kernel from, for 4.2.8-wily, it is 5f5c1db041b45cb74da1c842e13866afcb33975c. But you can instead pull the commit by its tag name, that is v4.2.8.

You also have patches to apply (there are 3 for 4.2.8-wily), that have to be applied to the kernel source as per usual process, using the patch command.

2.3.2 Compiling the source

Ideally, instead of compiling the source "as is", it is best to use some Ubuntu-specific commands, so that eventually the compiled kernel is available as a package.

Useful explanations to compile (and package) the kernel inside Ubuntu:

https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel

and:

https://ahelpme.com/linux/ubuntu/build-your-own-kernel-under-ubuntu-using-mainline-latest-kernel

and also:

https://ubuntuforums.org/showthread.php?t=2261375

To resume it very briefly, you have two commands to execute:

fakeroot debian/rules clean
fakeroot debian/rules binary-headers binary-generic binary-perarch

2.3.3 Result

Compiling the kernel 4.2.8 from a Ubuntu 20.04 produced "retpoline" errors. I could not resolve these.

2.4 Using an old Ubuntu with its default kernel

I finally decided to use a kernel as recent as possible, but old enough so that rt3290 would compile on it. Looking round, I found out that Ubuntu 16.04 (xenial) uses 4.15 kernel.

rt3290 driver, as downloaded from the URLs above, would NOT compile successfully on it.

But, there is an updated driver version that compiles successfully on 4.15 kernel, available here:

https://github.com/maurizak/RaLink-RT3290-Drivers-Ubuntu

Some explanations here:

https://github.com/the-dagger/RaLink-RT3290-Drivers-Ubuntu/issues/1

And, here we go! Driver compiles well, it produces a .ko file.

2.5 Simple solution inside Fedora

Under Fedora, this URL, https://bugzilla.redhat.com/show_bug.cgi?id=1190467#c7, says that solving the issue is as simple as blacklisting some kernel modules.

That is, add the following lines to /etc/modprobe.d/blacklist:

blacklist rt2800pci
blacklist rt2800usb
blacklist rt2800lib

and then execute the following commands:

modprobe rt2x00usb
modprobe rt2x00lib
modprobe rt2x00pci

Mentionned in 2015 with rhe 7.1.

Not tested though.

3. Creating a custom Ubuntu ISO file

Explanations:

https://help.ubuntu.com/community/LiveCDCustomization

The below one documents in the end the use of xorriso, that seems the best to build a bootable USB for UEFI. It'll indeed create an ISO containing a partition table and two volumes, one main volume for the main content, the other one of type EFI that contains a .efi file to make UEFI startable.

https://help.ubuntu.com/community/InstallCDCustomization

In french:

https://doc.ubuntu-fr.org/personnaliser_livecd

Documentation about isohybrid:

https://wiki.syslinux.org/wiki/index.php?title=Isohybrid

3.2 Script to launch xorriso

#!/usr/bin/bash

# From the below URL:
#   https://wiki.syslinux.org/wiki/index.php?title=Isohybrid

set -euo pipefail

xorriso -as mkisofs \
  -o output.iso \
  -isohybrid-mbr /usr/lib/syslinux/bios/isohdpfx.bin \
  -c isolinux/boot.cat \
  -b isolinux/isolinux.bin \
  -no-emul-boot \
  -boot-load-size 4 \
  -boot-info-table \
  -eltorito-alt-boot \
  -e boot/grub/efi.img \
  -no-emul-boot \
  -isohybrid-gpt-basdat \
  extract-cd

Category: TI Tagged: sysadmin ubuntu kernel

Page 1 of 1