Kernel building for Ubuntu Touch

The current kernel on the UT is 2 years old-5.15.148. Maybe present day Sim cards would work with a kernel upgrsde?

Brave AI gives instructions on cross compiling and flashing:

Build Ubuntu Kernel Cross Compile

Cross-compiling the Linux kernel for Ubuntu Touch involves setting up a cross-compilation environment on an Ubuntu host to build a kernel compatible with ARM-based devices running Ubuntu Touch, such as the Nexus 4 or BQ Aquaris E4.5.

Prerequisites and Setup

  • Install required build tools and dependencies:
    sudo apt-get install git gnupg flex bison gperf build-essential zip bzr curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386 schedtool g++-4.8-multilib
    
  • Install the phablet-tools PPA for Ubuntu Touch kernel building:
    sudo add-apt-repository ppa:phablet-team/tools
    sudo apt-get update
    sudo apt-get install phablet-tools
    

Build Process

  1. Clone the kernel source from the Ubuntu Touch repository:

    git clone -b ubp-5.1-caf https://github.com/ubports/android_kernel_oneplus_msm8974.git
    cd android_kernel_oneplus_msm8974
    
  2. Configure the kernel using the device-specific defconfig:

    make ARCH=arm bacon_defconfig
    
  3. Cross-compile the kernel using the ARM cross-compiler:

    make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -j$(nproc)
    

    Note: The CROSS_COMPILE prefix must match the installed cross-compiler toolchain (e.g., arm-linux-gnueabihf-).

  4. Build modules (if needed):

    make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- modules
    
  5. Install modules to a target root filesystem:

    sudo make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- modules_install INSTALL_MOD_PATH=/path/to/target/rootfs
    

Deployment

  • Copy the generated kernel image (arch/arm/boot/zImage) and device tree blob (arch/arm/boot/dts/*.dtb) to the target device.
  • Flash or update the boot partition using fastboot or adb if applicable.

Important: The official documentation at https://www.raspberrypi.org/documentation/linux/kernel/building.md and the Ubports Wiki provide updated and reliable guidance. Always verify the correct kernel branch and toolchain for your specific device.

It’s a Long Term Support kernel, https://kernel.org/

You have to get the dmesg because the system talks to the binary drivers of the modem through the HAL, something isn’t tuned correctly in this process.

When you notice messages related to modem/SIM errors/warnings then you’ll know which direction to go and where to look. It could also be something very minor that could be fixed easily. Comparing the messages between a boot that recognises the SIM and one that it doesn’t would give you much information, maybe it fails to activate the modem altogether due to some condition that is fulfilled randomly like when you are reading freshly allocated memory without deleting it first.

The kernel compilation is very advanced and you probably need many tricks to install it but I don’t think it’s correlated to the modem which is configured very abstractly by Linux.

It has directed you to compile an OnePlus Snapdragon kernel, you would need a Brax3 Mediatek one but I can’t see anything in the repositories. You need both the right kernel source and the configuration file already present inside your device.

You could follow the changelogs, Index of /pub/linux/kernel/v5.x/ of the kernel at least for staying on 5.15.x, moving to another kernel like 6.x introduces many complications. One of them is that the configuration options change continuously and since they do not exist in the previous configuration file you’ll have to decide on your own how to configure it.

Even if something related to the modem has been introduced it would be an Ubuntu Touch specific patch regarding the mobile SoCs. The age of the kernel is not important, UBports has shipped an LTS kernel on which they have been working for a long time and they do not expect to encounter bugs of future versions.

1 Like

I’ll look at dmesg and put that into files. Any idea where UBPorts has the kernel defconfig file?

It should be at least at /proc/config.gz and can be extracted to a file with

zcat /proc/config.gz > config

this is a cat command for compressed files.

/proc is a virtual filesystem that points to most of the information of a running system in the kernel, it contains one directory for every process named with the PID of the process.

For example /proc/cpuinfo contains all the information for the CPU cores.

1 Like

Thanks for that! I thought it must be on my system somewhere! :+1:

As you can see in this diagram at halium.org, the hardware abstraction is complicated and demands an Android kernel and various Android services that talk to Mediatek’s binary blobs, somewhere in this stack the communication with the modem is not stable, everything else happens internally inside the modem which is a 2nd computer running Linux and Android trusted environment, the modem will automatically recognize the SIM.

1 Like