10

https://github.com/clearlinux-pkgs/linux

https://aur.archlinux.org/packages/linux-clear/

How to use clearlinux kernel for ubuntu?

Hoping for a step-by-step copy/paste guide to replace ubuntu kernel with clearlinux kernel. still incomplete copy/paste code. I wish it will be completed someday.

**DONE**
android@nazar:~/patched_source/linux-5.6.10$ cd ../
android@nazar:~/patched_source$ ls
linux-5.6.10                             linux-headers-5.6.10+_5.6.10+-1_amd64.deb
linux-5.6.10+_5.6.10+-1_amd64.buildinfo  linux-image-5.6.10+_5.6.10+-1_amd64.deb
linux-5.6.10+_5.6.10+-1_amd64.changes    linux-libc-dev_5.6.10+-1_amd64.deb
android@nazar:~/patched_source$ uname -a
Linux nazar 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
android@nazar:~/patched_source$ sudo dpkg -i ../*.deb 
[sudo] password for android: 
dpkg: error: cannot access archive '../*.deb': No such file or directory
android@nazar:~/patched_source$ sudo dpkg -i *.deb 
Selecting previously unselected package linux-headers-5.6.10+.
(Reading database ... 152012 files and directories currently installed.)
Preparing to unpack linux-headers-5.6.10+_5.6.10+-1_amd64.deb ...
Unpacking linux-headers-5.6.10+ (5.6.10+-1) ...
Selecting previously unselected package linux-image-5.6.10+.
Preparing to unpack linux-image-5.6.10+_5.6.10+-1_amd64.deb ...
Unpacking linux-image-5.6.10+ (5.6.10+-1) ...
Preparing to unpack linux-libc-dev_5.6.10+-1_amd64.deb ...
Unpacking linux-libc-dev:amd64 (5.6.10+-1) over (5.4.0-26.30) ...
Setting up linux-headers-5.6.10+ (5.6.10+-1) ...
Setting up linux-image-5.6.10+ (5.6.10+-1) ...
 * dkms: running auto installation service for kernel 5.6.10+                                           
Kernel preparation unnecessary for this kernel.  Skipping...
applying patch 0002-Makefile.patch...patching file Makefile
Hunk #1 succeeded at 113 with fuzz 1.
Hunk #2 succeeded at 132 with fuzz 2 (offset 1 line).

applying patch 0003-Make-up-for-missing-init_MUTEX.patch...patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 111 with fuzz 2 (offset 12 lines).

applying patch 0010-change-the-network-interface-name-from-eth-to-wlan.patch...patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 221 (offset -14 lines).

applying patch 0013-gcc.patch...patching file Makefile

applying patch 0019-broadcom-sta-6.30.223.248-3.18-null-pointer-fix.patch...patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 2169 (offset 12 lines).

applying patch 0020-add-support-for-linux-4.3.patch...patching file src/shared/linux_osl.c

applying patch 0021-add-support-for-Linux-4.7.patch...patching file src/wl/sys/wl_cfg80211_hybrid.c

applying patch 0022-add-support-for-Linux-4.8.patch...patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #1 succeeded at 2391 (offset 3 lines).
Hunk #2 succeeded at 2501 (offset 3 lines).
Hunk #3 succeeded at 2933 (offset 9 lines).

applying patch 0023-add-support-for-Linux-4.11.patch...patching file src/include/linuxver.h
patching file src/wl/sys/wl_linux.c
Hunk #1 succeeded at 2919 (offset 4 lines).

applying patch 0024-add-support-for-Linux-4.12.patch...patching file src/wl/sys/wl_cfg80211_hybrid.c
Hunk #1 succeeded at 55 (offset 5 lines).
Hunk #2 succeeded at 472 (offset 5 lines).
Hunk #3 succeeded at 2371 (offset 5 lines).
Hunk #4 succeeded at 2388 (offset 5 lines).

applying patch 0025-add-support-for-Linux-4.14.patch...patching file src/shared/linux_osl.c
Hunk #1 succeeded at 1080 (offset 4 lines).

applying patch 0026-add-support-for-Linux-4.15.patch...patching file src/wl/sys/wl_linux.c
Hunk #2 succeeded at 2306 (offset 4 lines).
Hunk #3 succeeded at 2368 (offset 4 lines).

applying patch 0027-add-support-for-linux-5.1.patch...patching file src/include/linuxver.h
Hunk #1 succeeded at 595 (offset 4 lines).


Building module:
cleaning build area...
make -j4 KERNELRELEASE=5.6.10+ -C /lib/modules/5.6.10+/build M=/var/lib/dkms/bcmwl/6.30.223.271+bdcom/build....(bad exit status: 2)
ERROR (dkms apport): kernel package linux-headers-5.6.10+ is not supported
Error! Bad return status for module build on kernel: 5.6.10+ (x86_64)
Consult /var/lib/dkms/bcmwl/6.30.223.271+bdcom/build/make.log for more information.
                                                                                                 [ OK ]
update-initramfs: Generating /boot/initrd.img-5.6.10+
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.6.10+
Found initrd image: /boot/initrd.img-5.6.10+
Found linux image: /boot/vmlinuz-5.4.0-26-generic
Found initrd image: /boot/initrd.img-5.4.0-26-generic
Adding boot menu entry for UEFI Firmware Settings
done
Setting up linux-libc-dev:amd64 (5.6.10+-1) ...

BEFORE REBOOT android@nazar:~/patched_source$ uname -a Linux nazar 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

nazar2sfive
  • 1,335

2 Answers2

3

I don't have specific experience with ClearLinux, but it looks like you can:

# It's best to first compile their gcc (https://github.com/clearlinux-pkgs/gcc)
mkdir ~/patched_source
git clone https://github.com/clearlinux-pkgs/linux ~/clearlinux_patches
cd ~/clearlinux_patches
./scripts/develop.sh linux.spec ~/patched_source

That should download the upstream kernel to a folder below ~/patched_source (it will tell you the exact name) and apply ClearLinux's own patches and default config.

You can then proceed to compile the kernel as usual, for instance:

cd that_folder
CC=/the/clearlinux/gcc make -j4 bindeb-pkg
# This will take a while and create a few linux-xxx.deb files in the parent directory
sudo dpkg -i ../*.deb   # Or just the latest

Disabling the CONFIG_RETPOLINE mitigation makes it possible to compile with Ubuntu's gcc (at a cost, obviously).

The usual warnings apply: try in a VM first, secure boot can be tricky, there might be some Ubuntu-specific patches missing, ...

If you feel adventurous you can also add some of their own cmdline options to /etc/default/grub (like the ones in lines 8-15)

Jacopo
  • 746
  • android@clr:~/clearlinux_patches/scripts (master) $ ./develop.sh ~/patched_source grep: /home/android/patched_source: Is a directory – nazar2sfive Apr 28 '20 at 03:40
  • *stuck at above - going no further – nazar2sfive Apr 28 '20 at 03:40
  • Corrected the first arg. But, I will add, be careful. – Jacopo Apr 28 '20 at 20:22
  • stuck still......... – nazar2sfive Apr 29 '20 at 02:52
  • Note that I changed a line: ./scripts/develop.sh linux.spec ~/patched_source – Jacopo Apr 29 '20 at 03:22
  • Also, it looks like you need a new gcc option -- use their own gcc (which I think is https://github.com/clearlinux-pkgs/gcc) – Jacopo Apr 29 '20 at 03:23
  • how to compile clearlinux gcc? – nazar2sfive May 01 '20 at 14:15
  • That would be another question :) If you want to try it with Ubuntu's gcc, disable CONFIG_RETPOLINE. I tried it in a VM and it boots, but be warned that some of Ubuntu's userland might miss functionality. – Jacopo May 02 '20 at 17:38
  • and a final question. how to disable CONFIG_RETPOLINE? – nazar2sfive May 03 '20 at 14:36
  • https://askubuntu.com/questions/1234827/how-to-build-kernel-without-config-retpoline @Jacopo – nazar2sfive May 03 '20 at 16:25
  • still the step by step copy / paste code is not complete. but i have awarded the +500 to above help. i wish others to help how to disable CONFIG_RETPOLINE. Btw i know nothing about kernel of this level . All i know is how to copy some code from here and paste to my terminal in my pc. – nazar2sfive May 04 '20 at 12:56
  • It's enabled and disabled like any other kernel config options. However, I think you should really read up on Spectre / Meltdown before you take this step, as there are security consequences. At the risk of being a bit blunt: I think your question is useful in general, but I also think that you should keep Ubuntu's kernel for now and go back to this once you are more prepared on how things work, how to debug possible issues, have a rough understanding of the consequences, etc. I fear you might put your system in a very confusing state and it might be very hard to help you out of it. – Jacopo May 04 '20 at 19:44
  • i run this in my old laptop. So even if my "hardware gets damaged by this software tinkering"- it doesnot matter to me. I will simply throw this laptop to the garbage. – nazar2sfive May 05 '20 at 01:43
  • https://askubuntu.com/questions/1234778/how-to-compile-clearlinux-gcc-in-ubuntu Help with this. – nazar2sfive May 05 '20 at 01:46
  • Is there anything that can i do while building my module for broadcom 43142. – nazar2sfive May 10 '20 at 15:15
3

Thanks to @Jacopo I am reposting this for my future refrence.

How to install clearlinux gcc in ubuntu?

https://cdn.download.clearlinux.org/releases/33040/clear/x86_64/os/Packages/

android@nazar:~/
wget https://cdn.download.clearlinux.org/releases/33030/clear/x86_64/os/Packages/gcc7-7.5.0-440.x86_64.rpm
sudo apt install alien git curl flex bison libssl-dev
sudo alien gcc7-7.5.0-440.x86_64.rpm
sudo dpkg -i gcc7_7.5.0-441_amd64.deb
gcc7 -v
mkdir ~/patched_source
git clone https://github.com/clearlinux-pkgs/linux ~/clearlinux_patches
cd ~/clearlinux_patches
git clone https://github.com/clearlinux-pkgs/linux ~/clearlinux_patches
cd ~/clearlinux_patches
./scripts/develop.sh linux.spec ~/patched_source
git config --global user.email "you@example.com"
./scripts/develop.sh linux.spec ~/patched_source
cd /home/android/patched_source/linux*
CC=/the/clearlinux/gcc make -j4 bindeb-pkg
sudo dpkg -i ../*.deb 

post install freezing kernel

sudo apt-mark hold linux-generic linux-image-generic linux-headers-generic
nazar2sfive
  • 1,335