Trying to add an unset kernel module

Test and fix the Kernel 4.14 features

Moderators: odroid, mdrjr

Trying to add an unset kernel module

Unread postby stefann » Mon Jun 11, 2018 3:08 pm

Hi everyone,

I would like to add a kernel module that is currently not set in the official Odroid Ubuntu image. To do so, I followed the following process:

Code: Select all
# Clone and switch the my kernel version
git clone https://github.com/hardkernel/linux.git
cd linux
git checkout -b 4.14.5-92 4.14.5-92

# Copy my .config
cp /boot/config-4.14.5-92 .config

# Edit and add an unset module to .config as a module (option m)

# Generate Module.symvers because I didn't find it on the Odroid Ubuntu install
make EXTRAVERSION=-92 modules

# Compile the missing modules
make EXTRAVERSION=-92 modules_prepare
make M=net/bluetooth

# Insert the module but it returns an error
insmod net/bluetooth/bluetooth_6lowpan.ko
insmod: ERROR: could not insert module net/bluetooth/bluetooth_6lowpan.ko: Invalid module format


dmesg is returning the following message:
Code: Select all
[372785.117064] bluetooth_6lowpan: version magic '4.14.5-92+ SMP preempt mod_unload ARMv7 p2v8 ' should be '4.14.5-92 SMP preempt mod_unload ARMv7 p2v8 '


I wonder if I am missing something?

Thanks for your help.
Last edited by stefann on Mon Jun 11, 2018 3:34 pm, edited 1 time in total.
stefann
 
Posts: 4
Joined: Mon Jun 11, 2018 2:44 pm
languages_spoken: english
ODROIDs: XU4

Re: Trying to add an unset kernel module

Unread postby odroid » Mon Jun 11, 2018 3:24 pm

Update your system first. The latest Kernel version is 4.14.47.
https://wiki.odroid.com/odroid-xu4/os_i ... st-upgrade

And follow this instruction to build your own kernel on the board natively.
https://wiki.odroid.com/odroid-xu4/os_i ... rnel_build
User avatar
odroid
Site Admin
 
Posts: 27973
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Trying to add an unset kernel module

Unread postby stefann » Mon Jun 11, 2018 4:09 pm

Thank you odroid.

I upgraded to the latest kernel and rebooted. Now, compiling the kernel as documented.

Is my above method working to just compile a single module instead of the kernel?
stefann
 
Posts: 4
Joined: Mon Jun 11, 2018 2:44 pm
languages_spoken: english
ODROIDs: XU4

Re: Trying to add an unset kernel module

Unread postby odroid » Mon Jun 11, 2018 4:12 pm

If the Kernel source version and running Kernel image are exactly same, it should work probably.
User avatar
odroid
Site Admin
 
Posts: 27973
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Trying to add an unset kernel module

Unread postby stefann » Tue Jun 12, 2018 6:05 pm

Hi odroid,

Following the build instruction did not work because it ended by building a dirty kernel ('+' sign tailing the version) causing a version mismatch when loading the module:
Code: Select all
[93093.994911] bluetooth_6lowpan: version magic '4.14.47-132+ SMP preempt mod_unload ARMv7 p2v8 ' should be '4.14.47-132 SMP preempt mod_unload ARMv7 p2v8 '

I am not sure what is causing the dirty build because I just modified the .config which is in the .gitignore but I was able to get a clean build by setting LOCALVERSION to empty. However, I still get an error while loading the module:
Code: Select all
$ make EXTRAVERSION=-132 LOCALVERSION= modules_prepare
$ make M=net/bluetooth
$ insmod net/bluetooth/bluetooth_6lowpan.ko
insmod: ERROR: could not insert module net/bluetooth/bluetooth_6lowpan.ko: Unknown symbol in module


dmesg:
Code: Select all
[93271.147319] bluetooth_6lowpan: loading out-of-tree module taints kernel.
[93271.147447] bluetooth_6lowpan: Unknown symbol lowpan_register_netdev (err 0)
[93271.147468] bluetooth_6lowpan: Unknown symbol lowpan_unregister_netdev (err 0)
[93271.147479] bluetooth_6lowpan: Unknown symbol lowpan_header_decompress (err 0)
[93271.147552] bluetooth_6lowpan: Unknown symbol lowpan_header_compress (err 0)
stefann
 
Posts: 4
Joined: Mon Jun 11, 2018 2:44 pm
languages_spoken: english
ODROIDs: XU4

Re: Trying to add an unset kernel module

Unread postby tobetter » Tue Jun 12, 2018 6:18 pm

Before loading bluetooth_6lowpan.ko, you should run modprobe 6lowpan.ko since this driver module contains the missing symbols lowpan_*. Probably, you could consider to copy your kernel module to somewhere in /lib/modules/your/kernel/version/* and run depmod to build kernel module dependencies.
tobetter
 
Posts: 2190
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Trying to add an unset kernel module

Unread postby stefann » Wed Jun 13, 2018 12:53 am

Awesome tobetter. It worked!

For the record, that's what I did:
Code: Select all
$ rm /lib/modules/4.14.47-132/kernel/net/bluetooth/bluetooth_6lowpan.ko
$ cp net/bluetooth/bluetooth_6lowpan.ko /lib/modules/4.14.47-132/kernel/net/bluetooth/
$ depmod
$ modinfo bluetooth_6lowpan                                                                                             
filename:       /lib/modules/4.14.47-132/kernel/net/bluetooth/bluetooth_6lowpan.ko
license:        GPL
version:        0.1
description:    Bluetooth 6LoWPAN
author:         Jukka Rissanen <jukka.rissanen@linux.intel.com>
srcversion:     F5D669AC2B0CE0D19EA3565
depends:        bluetooth,6lowpan
name:           bluetooth_6lowpan
vermagic:       4.14.47-132 SMP preempt mod_unload ARMv7 p2v8
$ modprobe bluetooth_6lowpan                                                                                             
$ lsmod |grep bluetooth_6lowpan
bluetooth_6lowpan      20480  0
6lowpan                28672  8 nhc_udp,nhc_routing,nhc_mobility,bluetooth_6lowpan,nhc_fragment,nhc_dest,nhc_hop,nhc_ipv6
bluetooth             409600  27 btrtl,bluetooth_6lowpan,btintel,bnep,btbcm,btusb


I imagine that "depmod" updated the symbols?
stefann
 
Posts: 4
Joined: Mon Jun 11, 2018 2:44 pm
languages_spoken: english
ODROIDs: XU4

Re: Trying to add an unset kernel module

Unread postby tobetter » Wed Jun 13, 2018 1:50 am

Thank you for the update. depmod is the command to build the dependencies cross the driver modules installed, such that, for your case, whenever you load the driver bluetooth_6lowpan.ko by modprobe command, it will load another kernel drivers that are referenced by it.
tobetter
 
Posts: 2190
Joined: Mon Feb 25, 2013 10:55 am
Location: Paju, South Korea
languages_spoken: Korean, English
ODROIDs: X, X2, U2, U3, XU3, C1

Re: Trying to add an unset kernel module

Unread postby odroid » Wed Jun 20, 2018 9:51 am

Newer Kernel 4.14.50-141 package has "bluetooth_6lowpan.ko" module now.
User avatar
odroid
Site Admin
 
Posts: 27973
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Linux Kernel 4.14 Debugging Party

Who is online

Users browsing this forum: No registered users and 0 guests