Linux – How to load a module at runtime

kernel-moduleslinuxload

I just compiled the qcserial module which is a driver module for a Gobi USB modem. Now I have a couple of questions.

  1. Now I have two files: drivers/usb/serial/qcserial.ko and drivers/usb/serial/qcserial.o which one is the correct driver?
  2. Also, as I understand, it will need to go into /lib/modules/3.11.6/kernel/drivers/ but how do I know which sub directories from there onwards?
  3. Should I just be able to copy the files over and then load with modprobe qcserial?

What I have tried so far:

root@ariag25:~# mkdir /lib/modules/3.11.6/kernel/drivers/usb/serial
root@ariag25:~# cp drivers/usb/serial/qcserial.ko /lib/modules/3.11.6/kernel/drivers/usb/serial/
root@ariag25:~# ls -l /lib/modules/3.11.6/kernel/drivers/usb/serial
total 20
-rw-r--r-- 1 root root 17921 Jan  1 18:30 qcserial.ko
root@ariag25:~# modprobe qcserial
FATAL: Module qcserial not found.
root@ariag25:~# 

What am I missing? Do I also need to copy the .o file?

From where I compiled it, I have:

ls -l drivers/usb/serial/qc*
-rw-r--r-- 1 reg reg  3776 Oct 18 18:24 drivers/usb/serial/qcaux.c
-rw-r--r-- 1 reg reg  3212 Dec 28 10:14 drivers/usb/serial/qcaux.o
-rw-r--r-- 1 reg reg 12577 Oct 18 18:24 drivers/usb/serial/qcserial.c
-rw-r--r-- 1 reg reg 17921 Dec 28 10:44 drivers/usb/serial/qcserial.ko
-rw-r--r-- 1 reg reg  7743 Dec 28 10:44 drivers/usb/serial/qcserial.mod.c
-rw-r--r-- 1 reg reg 11688 Dec 28 10:44 drivers/usb/serial/qcserial.mod.o
-rw-r--r-- 1 reg reg  6912 Dec 28 10:44 drivers/usb/serial/qcserial.o

edit for Answer 1

Ok, I copied my linux-3.11.6-arm.tar into the target's /tmp/. I then executed tar -C / -tvf linux-3.11.6-arm.tar to extract it onto / but after this, I still would get

# modprobe qcserial
FATAL: Module qcserial not found.

I then wondered if the driver gat even copied:

# tar -C / -tvf linux-3.11.6-arm.tar | grep qcserial
-rw-r--r-- root/root     17921 2013-12-28 13:22 lib/modules/3.11.6/kernel/drivers/usb/serial/qcserial.ko

so that looks fine, but if I want to ls it, # ls /lib/modules/3.11.6/kernel/drivers/usb/ there's no serial directory within usb/ – why not? What happened?

Best Answer

You'll need to create a kernel package (make tar-pkg). Then copy it to your ARM system, for example to /tmp and extract to /. You'll get all driver modules installed into correct folders including proper modules.dep and other files needed to automatically resolve module dependencies.

modprobe qcserial should be working then.

Related Question