§2023-10-31
How to get linux kernel source
?
- 機器: odroid-n2, running Ubuntu Jammy 22.04
nano /etc/apt/sources.list
- uncomment
# deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
newer versions of the distribution.
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy main restricted
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy main restricted <-- uncomment this line
Major bug fix updates produced after the final release of the
distribution.
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates main restricted
N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
team. Also, please note that software in universe WILL NOT receive any
review or updates from the Ubuntu security team.
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy universe
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy universe
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates universe
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates universe
N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
team, and may not be under a free licence. Please satisfy yourself as to
your rights to use the software. Also, please note that software in
multiverse WILL NOT receive any review or updates from the Ubuntu
security team.
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy multiverse
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy multiverse
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates multiverse
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy-updates multiverse
N.B. software from this repository may not have been tested as
extensively as that contained in the main release, although it includes
newer versions of some applications which may provide useful features.
Also, please note that software in backports WILL NOT receive any review
or updates from the Ubuntu security team.
deb http://us.ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
deb-src http://us.ports.ubuntu.com/ubuntu-ports/ jammy-backports main restricted universe multiverse
Uncomment the following two lines to add software from Canonical's
'partner' repository.
This software is not part of Ubuntu, but is offered by Canonical and the
respective vendors as a service to Ubuntu users.
deb http://archive.canonical.com/ubuntu jammy partner
deb-src http://archive.canonical.com/ubuntu jammy partner
deb http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security main restricted
deb http://ports.ubuntu.com/ubuntu-ports jammy-security universe
deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security universe
deb http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
deb-src http://ports.ubuntu.com/ubuntu-ports jammy-security multiverse
2) ` sudo apt update `
- `apt-cache search linux-source `
root@hc4JamGen:/home/alexlai# apt-cache search linux-source linux-source - Linux kernel source with Ubuntu patches linux-source-5.15.0 - Linux kernel source for version 5.15.0 with Ubuntu patches linux-source-5.19.0 - Linux kernel source for version 5.19.0 with Ubuntu patches linux-source-6.2.0 - Linux kernel source for version 6.2.0 with Ubuntu patches
3) ` alexlai@hc4JamGen:~/build/src$ apt source linux-source-6.2.0 `
alexlai@hc4JamGen:/build/src$ apt source linux-source-6.2.0
Reading package lists... Done
Picking 'linux-hwe-6.2' as source package instead of 'linux-source-6.2.0'
NOTICE: 'linux-hwe-6.2' packaging is maintained in the 'Git' version control system at:
git://git.launchpad.net/22.04.1.diff.gz linux-hwe-6.2_6.2.0-36.37~22.04.1.dsc linux-hwe-6.2_6.2.0.orig.tar.gzubuntu-kernel/ubuntu/+source/linux/+git/jammy
...
alexlai@hc4JamGen:/build/src$ ls
linux-hwe-6.2-6.2.0 linux-hwe-6.2_6.2.0-36.37
4) copy config
alexlai@hc4JamGen:~/build/src$ cd linux-hwe-6.2-6.2.0/
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ cp /boot/config-5.15.0-odroid-arm64 .config
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ make oldconfig
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ sudo apt install libncurses-dev
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ make menuconfig
4) ` time make -j6`
real 61m17.24s user 323m0.727s syd 35m12.484s
5) make modules_install
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ ls /lib/modules
5.15.0-odroid-arm64
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ sudo make modules_install
..
INSTALL /lib/modules/6.2.16/kernel/net/nsh/nsh.ko
INSTALL /lib/modules/6.2.16/kernel/net/hsr/hsr.ko
DEPMOD /lib/modules/6.2.16
alexlai@hc4JamGen:~/build/src/linux-hwe-6.2-6.2.0$ ls -l /lib/modules
total 8
drwxr-xr-x 3 root root 4096 Nov 11 17:42 5.15.0-odroid-arm64
drwxr-xr-x 3 root root 4096 Nov 11 19:46 6.2.16
5) make install
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ ls -l /boot/
total 28356
-rw-r--r-- 1 root root 4511 Nov 11 18:08 boot.scr
-rw-r--r-- 1 root root 4490 Nov 11 18:01 boot.scr.bak
-rw-r--r-- 1 root root 4439 Nov 11 18:08 boot.script
-rw-r--r-- 1 root root 4490 Nov 11 18:07 boot.scr.ori
-rw-r--r-- 1 root root 220943 Jun 23 17:13 config-5.15.0-odroid-arm64
-rw-r--r-- 1 root root 237 Nov 11 17:41 config.ini
lrwxrwxrwx 1 root root 58 Nov 11 18:02 dtb -> dtbs/5.15.0-odroid-arm64/amlogic/meson64_odroidn2_plus.dtb
lrwxrwxrwx 1 root root 58 Nov 11 18:02 dtb-5.15.0-odroid-arm64 -> dtbs/5.15.0-odroid-arm64/amlogic/meson64_odroidn2_plus.dtb
drwxr-xr-x 3 root root 4096 Nov 11 17:42 dtbs
lrwxrwxrwx 1 root root 30 Nov 11 17:41 initrd.img -> initrd.img-5.15.0-odroid-arm64
-rw-r--r-- 1 root root 11759477 Nov 11 18:02 initrd.img-5.15.0-odroid-arm64
lrwxrwxrwx 1 root root 30 Nov 11 17:41 initrd.img.old -> initrd.img-5.15.0-odroid-arm64
drwx------ 2 root root 16384 Nov 11 17:22 lost+found
lrwxrwxrwx 1 root root 41 Nov 11 18:02 overlays -> dtbs/5.15.0-odroid-arm64/amlogic/overlays
-rw-r--r-- 1 root root 5487786 Jun 23 17:13 System.map-5.15.0-odroid-arm64
lrwxrwxrwx 1 root root 27 Nov 11 17:41 vmlinuz -> vmlinuz-5.15.0-odroid-arm64
-rw-r--r-- 1 root root 11508233 Jun 23 17:13 vmlinuz-5.15.0-odroid-arm64
lrwxrwxrwx 1 root root 27 Nov 11 17:41 vmlinuz.old -> vmlinuz-5.15.0-odroid-arm64
alexlai@hc4JamGen:/build/src/linux-hwe-6.2-6.2.0$ sudo make install
INSTALL /boot
run-parts: executing /etc/kernel/postinst.d/dkms 6.2.16 /boot/vmlinuz-6.2.16
- dkms: running auto installation service for kernel 6.2.16 [ OK ] run-parts: executing /etc/kernel/postinst.d/initramfs-tools 6.2.16 /boot/vmlinuz-6.2.16 update-initramfs: Generating /boot/initrd.img-6.2.16 Using DTB: amlogic/meson64_odroidn2_plus.dtb Couldn't find DTB meson64_odroidn2_plus.dtb in /usr/lib/linux-image-6.2.16 or /etc/flash-kernel/dtbs Couldn't find DTB files in /usr/lib/linux-image-6.2.16/amlogic run-parts: /etc/initramfs/post-update.d//flash-kernel exited with return code 1 run-parts: /etc/kernel/alexlai@hc4JamGen:~/build/src/linux-hwe-6.2-6.2.0$ ls -l /boot total 72156 -rw-r--r-- 1 root root 4511 Nov 11 18:08 boot.scr -rw-r--r-- 1 root root 4490 Nov 11 18:01 boot.scr.bak -rw-r--r-- 1 root root 4439 Nov 11 18:08 boot.script -rw-r--r-- 1 root root 4490 Nov 11 18:07 boot.scr.ori -rw-r--r-- 1 root root 220943 Jun 23 17:13 config-5.15.0-odroid-arm64 -rw-r--r-- 1 root root 234272 Nov 11 19:47 config-6.2.16 -rw-r--r-- 1 root root 237 Nov 11 17:41 config.ini lrwxrwxrwx 1 root root 58 Nov 11 18:02 dtb -> dtbs/5.15.0-odroid-arm64/amlogic/meson64_odroidn2_plus.dtb lrwxrwxrwx 1 root root 58 Nov 11 18:02 dtb-5.15.0-odroid-arm64 -> dtbs/5.15.0-odroid-arm64/amlogic/meson64_odroidn2_plus.dtb drwxr-xr-x 3 root root 4096 Nov 11 17:42 dtbs lrwxrwxrwx 1 root root 30 Nov 11 17:41 initrd.img -> initrd.img-5.15.0-odroid-arm64 -rw-r--r-- 1 root root 11759477 Nov 11 18:02 initrd.img-5.15.0-odroid-arm64 -rw-r--r-- 1 root root 11693531 Nov 11 19:47 initrd.img-6.2.16 lrwxrwxrwx 1 root root 30 Nov 11 17:41 initrd.img.old -> initrd.img-5.15.0-odroid-arm64 drwx------ 2 root root 16384 Nov 11 17:22 lost+found lrwxrwxrwx 1 root root 41 Nov 11 18:02 overlays -> dtbs/5.15.0-odroid-arm64/amlogic/overlays -rw-r--r-- 1 root root 5487786 Jun 23 17:13 System.map-5.15.0-odroid-arm64 -rw-r--r-- 1 root root 4398175 Nov 11 19:47 System.map-6.2.16 lrwxrwxrwx 1 root root 14 Nov 11 19:47 vmlinuz -> vmlinuz-6.2.16 -rw-r--r-- 1 root root 11508233 Jun 23 17:13 vmlinuz-5.15.0-odroid-arm64 -rw-r--r-- 1 root root 28518408 Nov 11 19:47 vmlinuz-6.2.16 lrwxrwxrwx 1 root root 27 Nov 11 17:41 vmlinuz.old -> vmlinuz-5.15.0-odroid-arm64 postinst.d/initramfs-tools exited with return code 1
make: *** [arch/arm64/Makefile:180: install] Error 1
6) nano /boot/boot.scripts
f test -z "${fk_kvers}"; then
setenv fk_kvers "5.15.0-odroid-arm64"
setenv fk_kvers "6.2.16" fi
alexlai@hc4JamGen:/boot$ sudo mkimage -A arm -T script -C none -n "Ubuntu boot script" -d boot.script boot.scr Image Name: Ubuntu boot script Created: Sat Nov 11 19:51:43 2023 Image Type: ARM Linux Script (uncompressed) Data Size: 4477 Bytes = 4.37 KiB = 0.00 MiB Load Address: 00000000 Entry Point: 00000000 Contents: Image 0: 4469 Bytes = 4.36 KiB = 0.00 MiB
---
- [ubuntu Kernel](https://kernel.ubuntu.com/)
-
1) using git
```bash
$ git clone https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/jammy
$ cd jammy
alexlai@n2JamGen:~/build/src/jammy$ ls
arch certs CREDITS debian Documentation fs init Kbuild kernel LICENSES Makefile net samples security sound ubuntu update-dkms-versions usr
block COPYING crypto debian.master drivers include ipc Kconfig lib MAINTAINERS mm README scripts snapcraft.yaml tools Ubuntu.md update-version-dkms virt
$ chmod a+x debian/rules
$ chmod a+x debian/scripts/*
$ chmod a+x debian/scripts/misc/*
$ LANG=C fakeroot debian/rules clean
...
---> failed
dh_testdir
/bin/bash: line 1: dh_testdir: command not found
make: *** [debian/rules:127: clean] Error 127