4

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?

  • Why don't you want to compile the module "statically" i.e. '*' instead of 'M'? – yegorich Dec 28 '13 at 19:16
  • Because at this point, I can not reload the complete kernel structure & rootfs. However, it's a fair question :) – cerr Dec 28 '13 at 19:19
  • What embedded distro are you using? – yegorich Dec 28 '13 at 19:23
  • @yegorich embedded debian – cerr Dec 28 '13 at 20:19
1

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.

  • I instead did a make tar-pkg -j8 ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- to get it compiled for the correct arch, I now have a linux-3.11.6-arm.tar seemingly including all the modules, not only qcserial. I also got a message like "** ** ** WARNING ** ** ** Your architecture did not define any architecture-dependent files to be placed into the tarball. Please add those to /home/reg/semios/linux-3.11.6/scripts/package/buildtar ..." - which I don't understand... what "architecture-dependent files" does that refer to? – cerr Dec 28 '13 at 20:25
  • 1
    @cerr don't pay attention to this warning. As long as you get linux-3.11.6-arm.tar everything is O.K. Btw you can remove /boot folder from the archive. This archive has all drivers, that you have compiled as modules. I've also used Embedded Debian and used this method to install driver modules. – yegorich Dec 28 '13 at 22:03
  • 1
    FYI: If you don't necessarily need to use Debian, you could use Buildroot. It would install modules direct to your rootfs archive during the building stage. – yegorich Dec 28 '13 at 22:06
  • I don't necessarily need to use debian for this one, it 'just' came with it sio i decieded to go ahead with it. I've used buildroot on other platforms before but would need to figure out some basics again before i can get started... – cerr Dec 28 '13 at 23:17
  • 1
    If you have used tar -C / -tvf linux-3.11.6-arm.tar for extraction, than you have just listed the files. You should use tar -C / -xvf linux-3.11.6-arm.tar to extract files, i.e. -x option. – yegorich Dec 29 '13 at 12:21
2

There are two utilities to load modules: insmod and modprobe. insmod is a low-level utility: it loads a module file, given by its full path. modprobe is a high-level utility: you pass it a module name, and it looks up that module name in the module database, loads any necessary dependencies then loads the module itself. If the module isn't recorded in the module database, modprobe fails.

In addition to copying the module file, you need to update the module database. Run depmod -a to regenerate the whole database`.

It doesn't matter where you put the module file as long as it's somewhere under /lib/modules/3.11.6 (where 3.11.6 is your kernel version as returned by uname -r). Normally the kernel subdirectory is reserved for modules that came with the kernel itself, you should put yours in another subdirectory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.