LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Compiling Device drivers (https://www.linuxquestions.org/questions/linux-newbie-8/compiling-device-drivers-4175478115/)

billvance 09-22-2013 03:32 PM

Compiling Device drivers
 
Howdy;

I'm Running Kubuntu 12.04 here.

I've done this a long time ago, but some things change, so
with the current lack of complete documentation, I'm left
with questions.

I recently bought a Sabrent usb video capture dongle, and
have downloaded a linux driver for it. It is stk1160-v4l.c
for release 0.9.3\_for\_v3.2.

Anyway, as I recall, the file needs to go into a particular
directory in the kernel source code, and be listed in a
particular file in order to be compiled. The kernel source
I have at the moment, (linux-source-3.2.0), doesn't seem to
have anything about this in the zillions of README files it
came with. At least I haven't found it yet.

The README.md file that was the only file to come with the
driver .c file says all you have to do is just type, "make",
and, "make install", but that doesn't do anything but error
generation.

Neither situation is helpful.

Does anybody know what I need to do here?

Thanks in advance.

Bill

Hungry ghost 09-22-2013 03:39 PM

I'm not an expert compiling drivers, but maybe if you copy here the error you get when you type make (on a clean, just uncompressed driver), someone might give you a hand :)

billvance 09-23-2013 01:16 AM

It wouldn't be the slightest bit helpful, as they
were all procedural in nature; I.e., no target, no
config/header files etc.

As I said, I need the proper dir to put it in, and
the list to add it to, assuming that's still the
proper procedure for these kinds of files. If its
not, then I need the new info for doing that.

Bill

astrogeek 09-23-2013 01:30 AM

Quote:

Originally Posted by odiseo77 (Post 5032659)
I'm not an expert compiling drivers, but maybe if you copy here the error you get when you type make (on a clean, just uncompressed driver), someone might give you a hand :)
Quote:

Originally Posted by billvance (Post 5032901)
It wouldn't be the slightest bit helpful, as they
were all procedural in nature; I.e., no target, no
config/header files etc.

As I said, I need the proper dir to put it in, and
the list to add it to, assuming that's still the
proper procedure for these kinds of files. If its
not, then I need the new info for doing that.

Bill


That is a rather rude and unhelpful response...

So, if we cannot see the errors, what would you consider would be helpful to us to help solve your problem?


*** UPDATED ***

The "proper procedure" for these types of files (driver.c), as the README says, is to compile them (i.e., run make as instructed). If make fails, then the proper procedure is to look at the resulting errors and meet any indicated requirements, then make it again until successful.

There is no magic directory or list that makes it all work error free.

billvance 09-23-2013 02:18 AM

My bad. Chalk it up to frustration and too long
without sleep, as I've been restoring my system
after re, re, re installing the OS. It is finally
more or less back to normal.

I'm no C programmer either. "C", stands for, "Cuneiform".

In reading through the file, It seemed to need being
in a particular directory for compiling, or need
full path/names for the #include files. That all
seemed do-able, but when I checked them, the last
two needed include files are AWOL on this system. These are:

#include "stk1160.h"
#include "stk1160-reg.h"

So now I have to find these for the 3.2.0 kernel.
Got any clues on those?

Bill

Hungry ghost 09-23-2013 02:20 PM

Quote:

Originally Posted by billvance (Post 5032942)
My bad. Chalk it up to frustration and too long
without sleep, as I've been restoring my system
after re, re, re installing the OS. It is finally
more or less back to normal.

I'm no C programmer either. "C", stands for, "Cuneiform".

In reading through the file, It seemed to need being
in a particular directory for compiling, or need
full path/names for the #include files. That all
seemed do-able, but when I checked them, the last
two needed include files are AWOL on this system. These are:

#include "stk1160.h"
#include "stk1160-reg.h"

So now I have to find these for the 3.2.0 kernel.
Got any clues on those?

Bill

You're not doing what you're told (which is really rude and frustrating for us). Again -- and I'm asking this for the last time -- what is the error message you get when you execute make in the clean driver directory? (By "clean" I mean a driver you've just decompressed and you haven't modified).

billvance 09-23-2013 03:25 PM

Ok, here you are.

makemake: *** No targets specified and no makefile found. Stop.

or,

make stk1160-v4l.c
make: Nothing to be done for `stk1160-v4l.c'.

Hungry ghost 09-23-2013 03:57 PM

Alright, so it seems you're not executing make inside the driver directory (or perhaps it doesn't have a makefile?). First, decompress the driver file. Depending on the file format you should execute tar zxvf file.tar.gz, or tar xjvf file.tar.bz2, or unzip file.zip.

Then use cd to enter the decompressed directory:

Code:

cd <path_to_the_driver_directory_here>
Finally, use ls to see what's inside the directory:

Code:

ls -l
Post the output of the last command here.

billvance 09-23-2013 04:25 PM

Here ya go.

ls -l
total 24
-rw-r--r-- 1 bill bill 2912 Jul 29 14:11 README.md
-rw-r--r-- 1 bill bill 18084 Sep 22 23:55 stk1160-v4l.c

astrogeek 09-23-2013 05:11 PM

Hey Bill!

Can you post the contents of the README.

If it says to run make, then there must be a Makefile somewhere, maybe the README has another clue.

Have you tried to build it with something like...

Code:

gcc -o driver stk1160-v4l.c
Maybe the output of that would provide additional clues.

billvance 09-23-2013 06:00 PM

I'll have to get back with you later, maybe tonight,
definitely tomorrow. My sleep cycles are catching up with me again.

Bill

zeebra 09-24-2013 05:35 AM

I was looking into these things some days ago, and came over quite a lot of interesting material. It seems to depend somewhat on how your Kernel implementation is in your distro.

Official Kernel.org doucmentation on the process:
https://www.kernel.org/doc/Documenta...ld/modules.txt


This one is interesting. Debian, which Kubuntu is based on. Information is clear and good:
http://www.cyberciti.biz/tips/build-...urce-tree.html
another similar one:
https://www.debian-administration.or..._kernel_module


Ps. I havent yet tried any of the methods and I am not using any of the above mentioned systems. I am using Mageia and a custom kernel and would probably recompile if needed.

billvance 09-24-2013 06:27 AM

ok, here's what the command did, stopping at a
#include in one of the missing files I finally managed to get.

gcc -o driver stk1160-v4l.c
stk1160-v4l.c:23:27: fatal error: linux/module.h: No such file or directory
compilation terminated.

And here's the README.md file.

IMPORTANT UPDATE
================

Completely deprecated, this driver is.
(Yoda)

The driver you are looking at is for Linux v3.2 **only**.
It will **not** work on any other kernel version. Please don't even
try unless you really know what you're doing.

Given stk1160 is fully mainlined since Linux v3.7 I've disabled issue tracking
for this github repository. If you have questions or want to report a bug
please use the video4linux mailing list (linux-media@vger.kernel.org) or
try asking in the IRC channel (#v4l).

If you want to stay updated with news about easycap devices you can
read the most excellent blog from Andrew Schalk.

http://easycap.blogspot.com.ar/

I hope you enjoy using stk1160 as much as I've enjoyed writing it!

stk1160-standalone
==================

stk1160 release 0.9.3\_for\_v3.2

This branch is intended to be used with v3.2.
__Please don't even try to use it with another one__.

This is the stk1160 driver (formerly known as easycap driver).
It's the driver needed to capture audio and video in some of those
little devices named as Easycap (if they are based on stk1160 chip).

You need to have this modules installed, but don't worry,
you don't have to insert them manually:

- snd\_usb\_audio
- snd\_ac97\_codec
- ac97\_bus
- saa7115
- videodev
- videobuf2\_core
- videobuf2\_vmalloc
- videobuf2\_memops
- v4l2\_common

Building and installing
-----------------------

make
make install

After this, perhaps you will have to run 'depmod -a'.

You should *not* get any warning.
If you do, most probably you did something wrong or you're using an incompatible kernel.

Usage
-----

After installing the driver you're ready to go.
If you now insert your usb easycap device you'll notice two modules get automatically loaded:
stk1160 and snd-usb-audio.
This can be seen using dmesg:

$ dmesg | grep registered
[48.561592] stk1160 2-2:1.0: V4L2 device registered as video0
[48.562284] usbcore: registered new interface driver stk1160
[49.169189] usbcore: registered new interface driver snd-usb-audio

Also, stk1160 will register a control-only alsa sound card.
This sound card is called 'stk1160-mixer'.
To enable sound capture you have to open alsamixer and selected
the 'Line' item on the capture menu for stk1160-mixer device.

This stk1160-mixer device is needed because snd-usb-audio
doesn't show mixer controls for the ac97 codec chip.
The real usb transfer for audio capture is done through snd-usb-audio.

Preventing old easycap driver from loading
------------------------------------------

If you want to prevent some module from loading
you can do so by adding it to blacklist file.

On many distributions this can be done like this:

echo "blacklist easycap" >> /etc/modprobe.d/blacklist.conf

This way easycap won't be loaded automatically by udev;
you can still load it manually, of course.

Hungry ghost 09-24-2013 12:45 PM

Umm, the readme is not clear. I navigated through the website linked in the readme, but couldn't find clear instructions. You probably need to install the kernel headers for your kernel, but without a makefile, I have no idea how to compile the driver. Sorry I can't help; maybe a more experienced user could tell us how to compile it (in case they know how to do it).

turtleli 09-24-2013 04:27 PM

Your first problem is that you are missing most of the driver. Including the README you have 2 out of the 9 files.

Go to the stk1160 github, download all the files(don't keep the files you currently have) there and then see whether make will work.


All times are GMT -5. The time now is 02:24 AM.