Score:1

Correct way to build kernel with hardware support fix patches - Ubuntu 22.04 LTS - 5.15.0-50

sl flag

Main Question:

Need a solution to apply a hardware support patch to my current working kernel in Ubuntu 22.04, so that it will fix the exact issue (here keyboard not working) without affecting other settings.

Background

Tried dual booting Ubuntu on my laptop(Asus vivobook s14-K3402ZA), the installation succeeded but keyboard was not working from boot, later found that only external keyboard is supporting and internal keyboard not working with Ubuntu 22.04 LTS - kernel 5.15.0-50-generic

The issue was identified at “Try before install” and do proceed because I found a patch online that solved the issue for similar models - from the information got from comments It will be added in a future 6.1 kernel release.

But in order to get it working on current mainline kernel, Tried the steps mentioned in this answer.

Downloaded latest longterm 5.15 release 5.15.74, Successfully complied the .deb package and installed - the keyboard issue fixed but there are several other issues regarding display brightness, scaling, refresh rate etc.

Score:2
sl flag

I think the issue is because the Ubuntu / Debian release kernel comes with some extra patches or may be due to the configuration difference in installed kernel version and the one from kernel.org.

Note that 5.15.74 is a mainline Linux version and mentioned 5.15.0-50 is an Ubuntu version, both are not same.

As all other functionalities are working in source kernel, it is better to build a custom patched kernel from source kernel to correct the issue.

Steps to follow,

  1. Enable source code repositories, this will add needed deb-src lines in /etc/apt/sources.list.

    enable-source-repo

  2. Install the tools require to compile the packages from source code,also ensure around 20+ GB disc space before building.

    # To install build tools
    sudo apt update
    sudo apt build-dep linux linux-image-$(uname -r)
    
    sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm build-essential libncurses5-dev gcc bc dwarves
    
  3. Obtaining the source for Ubuntu release: The source code which generated a specific binary package may be obtained using the apt source <package> command, to get other versions check this - official documentation, [ ref-2 ]

    # switch to root
    sudo su
    
    # get the current kernel source downloaded and extracted (ignore the end user warning)
    apt source linux-image-unsigned-$(uname -r)
    
    cd /path/to/linux-<version>/
    
    # Give all user execution permissions to scripts (Important, otherwise error will be thrown even if you are running them as root)
    chmod a+x debian/scripts/*
    chmod a+x -R ./scripts
    
  4. Download and apply the patch,

    patch -p1 < ~/Downloads/<patch-name>.patch
    
  5. Copy the existing configurations,

    cp /boot/config-$(uname -r) ./.config
    
    # update config for new kernel
    make oldconfig
    
  6. Compile the kernel, [ref]

    make -j16 deb-pkg LOCALVERSION=-custom
    

    You want to replace -j16 with however many threads your processor has (use getconf _NPROCESSORS_ONLN to get the number). the “LOCALVERSION” option can be anything you want. It’s only there for documentation purposes. Now your kernel should be compiling. This could take a while, depending on your hardware (1-2 hours)

  7. Install the new patched kernel, update grub and reboot to new kernel

    # change to parent dir
    cd ..
    
    dpkg -i *.deb
    
    update-grub
    reboot
    

    Use the mainline tool to remove old kernel,

Score:-1
my flag

Tried using the mainline tool to install the latest (already fixed and patched) kernel?

sudo add-apt-repository ppa:cappelikan/ppa
sudo apt update
sudo apt install mainline


And then use the tool.
David avatar
cn flag
Not only a bad answer an extremely bad idea. Using an untested test kernel will interfere with upgrades.
Christian Pulgar Cofre avatar
my flag
Coul,d you not install only LTS or stable kernels with that? Am I wrong?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.