librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

enable kernel patch for Ubuntu 22.04

Open mengyui opened this issue 3 years ago • 8 comments
trafficstars

build kernel patch for Ubuntu 22.04

move to new kernel repo URL remove some “sudo” command

BTW, there should be some issue in the kernel source repo for 5.15.0-39. In my environment, I can't insert the kernel module the system.

mengyui avatar Jun 25 '22 08:06 mengyui

Please see attached log output for ubuntu 2022 jammy patching jammy.zip @mengyui ubuntu22@ubuntu22:~/test/librealsense/scripts$ ./patch-realsense-ubuntu-lts.sh ./patch-realsense-ubuntu-lts.sh: line 61: ./scripts/patch-utils.sh: No such file or directory

dmipx avatar Jul 10 '22 07:07 dmipx

https://github.com/IntelRealSense/librealsense/blame/master/doc/installation.md#L70 Hi @dmipx , according to this document. the script "patch-realsense-ubuntu-lts.sh" should be called from the root directory of

mengyui avatar Jul 15 '22 07:07 mengyui

@mengyui I tried on clean ubuntu22, patch finished with following message, looks like module was not signed during build

dima@ubuntu22:~/git/librealsense$ ./scripts/patch-realsense-ubuntu-lts.sh 
....
Patched kernels modules were created successfully

[sudo] password for dima: 
Replacing videodev  -
	Applying the patched module ... modprobe: ERROR: could not insert 'videodev': Exec format error
Failed to insert the patched module. Operation is aborted, the original module is restored
Verify that the current kernel version is aligned to the patched module version
The original  videodev  module was reloaded

root@ubuntu22:/home/dima/git/librealsense# rmmod videodev

root@ubuntu22:/home/dima/git/librealsense# insmod /home/dima/git/librealsense/ubuntu-jammy/drivers/media/v4l2-core/videodev.ko

insmod: ERROR: could not insert module /home/dima/git/librealsense/ubuntu-jammy/drivers/media/v4l2-core/videodev.ko: Invalid module format
root@ubuntu22:/home/dima/git/librealsense# modinfo /home/dima/git/librealsense/ubuntu-jammy/drivers/media/v4l2-core/videodev.ko
filename:       /home/dima/git/librealsense/ubuntu-jammy/drivers/media/v4l2-core/videodev.ko
alias:          char-major-81-*
license:        GPL
description:    Video4Linux2 core driver
author:         Alan Cox, Mauro Carvalho Chehab <[email protected]>, Bill Dirks, Justin Schoeman, Gerd Knorr
srcversion:     FC2616F9D93D6F49B92C6F7
depends:        mc
retpoline:      Y
name:           videodev
vermagic:       5.15.0-41-generic SMP mod_unload modversions 


root@ubuntu22:/home/dima/git/librealsense# modinfo videodev
filename:       /lib/modules/5.15.0-41-generic/kernel/drivers/media/v4l2-core/videodev.ko
alias:          char-major-81-*
license:        GPL
description:    Video4Linux2 core driver
author:         Alan Cox, Mauro Carvalho Chehab <[email protected]>, Bill Dirks, Justin Schoeman, Gerd Knorr
srcversion:     5DEC66E6CBCC717A674CEFB
depends:        mc
retpoline:      Y
intree:         Y
name:           videodev
vermagic:       5.15.0-41-generic SMP mod_unload modversions 
sig_id:         PKCS#7
signer:         Build time autogenerated kernel key
sig_key:        1F:4E:23:82:4E:7F:DB:01:30:C1:63:2D:9B:09:11:2C:89:6D:22:1F
sig_hashalgo:   sha512
signature:      81:87:35:47:BE:9A:9D:A4:55:C9:73:BE:9B:30:4A:59:50:35:9D:99:
		49:B8:14:0D:9D:5B:74:43:9F:BF:62:D4:6A:47:78:E8:07:5C:19:79:
		00:45:9B:81:84:FB:76:0D:FF:3F:F9:FC:28:CB:4E:DC:E2:C3:1D:96:
		C2:2F:5C:CF:97:E5:EA:4F:E0:D0:A2:58:97:D1:A5:1F:38:AF:1D:19:
		05:DF:02:65:82:60:FC:67:95:73:78:CC:3C:DB:E6:BD:0D:07:5F:D5:
		75:37:2C:1F:F9:51:F6:78:4D:F0:23:AC:9A:B7:E3:82:D7:20:84:D3:
		93:AA:DF:2A:D6:96:06:57:1B:9B:37:9B:5A:FB:A0:58:96:29:FC:D6:
		DA:D8:1D:FF:9D:D3:6E:D3:F8:B8:08:A7:0D:16:75:78:D5:41:C3:50:
		C5:55:33:B3:9C:03:11:27:9C:5B:E2:50:40:C8:0C:45:1C:FF:62:9A:
		C4:94:F9:FA:85:C1:01:30:15:B9:E7:2D:09:97:01:80:3F:00:B7:05:
		10:28:76:A3:84:E8:7F:3C:DC:EF:A0:D1:75:D8:37:28:2B:1D:67:37:
		EE:A5:4B:41:41:96:EF:A9:B0:0B:8A:6E:9F:37:A2:76:2D:52:49:9E:
		80:A2:7E:76:DA:63:F3:FC:4C:B3:1B:E5:B5:E3:18:AC:6B:18:E2:69:
		8D:9B:FD:9A:CA:46:47:C8:F9:CB:E6:98:8B:01:3F:A2:AA:F8:29:A5:
		C1:7A:ED:E7:E6:1B:C4:FD:D1:E9:AD:57:60:38:65:92:7D:98:AC:DB:
		03:AE:66:39:B2:FC:C8:CB:69:73:D4:97:CD:66:DD:18:7B:85:22:40:
		9F:6B:88:ED:1F:2E:E9:80:46:4F:EA:D4:4F:AF:7D:23:84:E2:03:34:
		57:27:51:9D:13:35:2D:96:E7:DB:DC:A1:8E:2B:9F:9F:2A:E0:01:9B:
		AF:90:98:3A:AD:4E:CB:EC:03:91:F5:DC:8A:A9:61:12:78:22:17:1F:
		05:36:60:8E:0E:EC:9E:51:AB:71:04:7E:3A:51:C8:79:36:2B:7C:87:
		6F:8A:36:E6:39:57:F7:A4:44:26:85:F5:DF:3E:8A:68:93:8A:61:25:
		0B:B5:AF:8F:F8:9E:6E:60:B5:4A:A0:4D:39:92:55:96:D8:CF:C0:FC:
		D0:58:36:C2:78:66:31:08:7D:B5:52:11:23:F7:17:D0:2E:39:C2:E1:
		03:2A:E7:36:E2:5A:23:7A:3C:E7:66:B3:C7:DD:1F:F1:29:09:B0:C2:
		2B:B8:4F:83:7C:6F:6E:D5:64:C5:5C:7F:1C:AC:4A:CD:2A:48:13:BB:
		96:D1:5B:A5:BB:A6:BA:F0:6C:1F:74:65

dmesg:

[ 4629.401706] videodev: loading out-of-tree module taints kernel.
[ 4629.401823] videodev: module verification failed: signature and/or required key missing - tainting kernel
[ 4629.402107] module: x86/modules: Skipping invalid relocation target, existing value is nonzero for type 1, loc 00000000ed79e6d1, val ffffffffc090f055
[ 4629.456168] videodev: Linux video capture interface: v2.00

dmipx avatar Jul 25 '22 09:07 dmipx

@ev-mp @Nir-Az In order to implement Y16I for LRS-463 can we consider merging this PR to development branch?

dmipx avatar Aug 03 '22 09:08 dmipx

@mengyui , since the changes are in the main script file, this PR needs to be verified for regressions for Ubuntu 16/18 and 20 at least with the latests LTS kernel for each distribution.

ev-mp avatar Aug 03 '22 09:08 ev-mp

Hi @dmipx, the outputs of this script are not signed modules, even the origin version.

if the signed modules are required, they should be signed by another script. https://wiki.ubuntu.com/UEFI/SecureBoot/Signing

so, please turn off "Secure Boot" in BIOS.

Thanks, @ev-mp

mengyui avatar Aug 03 '22 12:08 mengyui

@ev-mp - Please note the authur comment

BTW, there should be some issue in the kernel source repo for 5.15.0-39. In my environment, I can't insert the kernel module the system.

This means it will not work for Ubuntu 22 default kernel right?

Nir-Az avatar Aug 04 '22 06:08 Nir-Az

@mengyui , you need to verify the script againt the older distros (16,18 and 20) as mentioned above. Please run the tests and share the results internally - this is a prerequisite for merge.

ev-mp avatar Aug 09 '22 04:08 ev-mp

Hi @ev-mp @Nir-Az @dmipx the script works well for Ubuntu 18 (kernel 4.15) and report error "mobprobe: ERROR: could not insert 'videodev': Exec format error" on Ubuntu 20 (kernel 5.13/5.15) or Ubuntu 22 (kernel 5.15).

It is a very odd issue. I remember there is a version of the kernel source that works with this script when I create this PR. and the dkms package works well (https://github.com/mengyui/librealsense2-dkms) the building steps are not changed in this PR.

mengyui avatar Aug 16 '22 12:08 mengyui

Hi @mengyui! We discussed with @ev-mp and best scenario is that we can merge all new patches but change scripts to be another ones, for example:

scripts/patch-realsense-ubuntu-lts.sh -> scripts/patch-realsense-ubuntu-lts-hwe.sh scripts/patch-utils.sh -> scripts/patch-utils-hwe.sh

so this will not require regression tests for legacy versions. Please rework and we will merge it, we need to add Y16I format for 5.13/5.15 kernels and we are blocked by this PR. Thanks!

dmipx avatar Aug 22 '22 13:08 dmipx

Hi @ev-mp @Nir-Az @dmipx the script works well for Ubuntu 18 (kernel 4.15) and report error "mobprobe: ERROR: could not insert 'videodev': Exec format error" on Ubuntu 20 (kernel 5.13/5.15) or Ubuntu 22 (kernel 5.15).

It is a very odd issue. I remember there is a version of the kernel source that works with this script when I create this PR. and the dkms package works well (https://github.com/mengyui/librealsense2-dkms) the building steps are not changed in this PR.

on older kernels - Makefile changed and set "CONFIG_MODULE_SIG=n" look for example: realsense-camera-formats-xenial-Ubuntu-hwe-4.8.0-58.63_16.04.1.patch That is not good idea but thus we can understand why it was working on older kernels. The DKMS is working well indeed, the DKMS package performs module signing with x509 certificates bundled with kernel package. BTW, can you PR librealsense2-dkms to dkms4librealsense?

dmipx avatar Aug 28 '22 06:08 dmipx