July 16, 2020, 12:35:56 pm


Have you visited the Allwinner Chipset wiki? - http://linux-sunxi.org/

Can someone help me compile a driver ?

Started by AndiBcool, April 24, 2014, 06:54:05 pm

Previous topic - Next topic


Im using this image http://www.cubieforums.com/index.php?topic=1275.0
for Cubietruck

This image seem to miss headers.

root@cubie:/usr/src/linux-sunxi# sudo apt-get install linux-headers-$(uname -r)
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package linux-headers-3.4.79-sun7i
E: Couldn't find any package by regex 'linux-headers-3.4.79-sun7i'

Slovenia told me to download headers from here: http://www.mediafire.com/download/j72uuh8h9q1xw2n/headers-3.4.79.tgz
and unpack em in /usr
that i did it overwrot some files and added more.

Later he told me to do this:
git clone https://github.com/patrickhwood/linux-sunxi
cd linux-sunxi
curl https://raw.githubusercontent.com/igorpecovnik/Cubietruck-Debian/master/config/kernel.config > .config
make prepare
make scripts

so i did go into /usr/src/ and this that.
that worked got no errors.

still when i try to compile i get the same errormessage as above he looks for headers and cant find him.

I have no clue what i need to do. The driver i need to compile is found here:

I found some other git for driver too: http://git.linuxtv.org/media_build.git

sudo apt-get install build-essential checkinstall git patchutils libproc-processtable-perl

sudo apt-get install linux-headers-$(uname -r)

mkdir ~/rtl2832u/
cd ~/rtl2832u/

git clone git://linuxtv.org/media_build.git

cd media_build


sudo make install

This also needs the headers.

Oh on the Raspberry Pi there is also a old driver delivered with the debian wheezy and openelec images.

Just need help how to do this and where i have to place the files to make it work.



April 26, 2014, 04:37:08 am #2 Last Edit: May 14, 2014, 08:58:34 am by mcct
So, you're trying to compile a "out-of-tree" module for a custom kernel (pat's 3.4.79+), right? Then no "linux-headers" package from official repositories.

From https://www.kernel.org/doc/Documentation/kbuild/modules.txt:

Quote--- 2.1 Command Syntax

   The command to build an external module is:
      $ make -C <path_to_kernel_src> M=$PWD

   The kbuild system knows that an external module is being built
   due to the "M=<dir>" option given in the command.

   To build against the running kernel use:

      $ make -C /lib/modules/`uname -r`/build M=$PWD

Your <path_to_kernel_src> is /usr, as that's where you have unpacked your headers-3.4.79.tgz. If you cross-compile, then you specify some different directory and add some directives like export ARCH=arm; CROSS_COMPILE=arm-linux-gnueabihf
Edit: The trailing "-" was missing:
export ARCH=arm; CROSS_COMPILE=arm-linux-gnueabihf-
This worked for me when I cross-compiled Pat's kernel from source and a module.


Thanks for the help.

I think your try is the right direction.
Im using the version 1.9 now that should include the linux headers.
However i dont know the location of the linux headers.

The make file looks in usr/src/linux-headers- 3.4.79-sun7i+
but usr/src/ is empty

I will download the now the kernelsource again to usr/src/:
git clone https://github.com/patrickhwood/linux-sunxi
cd linux-sunxi
curl https://raw.githubusercontent.com/igorpecovnik/Cubietruck-Debian/master/config/kernel.config > .config
make prepare
make scripts

If you command dont work i guess i will need to config the make file of the driver:
# License: GPL
# RTL2832U Driver

# `uname -r` can be 3.7-Comment or 3.7.3-comment ...
DETECT_KERNEL_MACRO := case `uname -r` in \
      3.15*) echo "ERROR";; \
      3.14*) echo "ERROR";; \
      3.13*) echo "ERROR";; \
      3.12*) echo "3110";; \
      3.11*) echo "3110";; \
      3.10*) echo "390";; \
      3.9*) echo "390";; \
      3.8*) echo "360";; \
      3.7*) echo "360";; \
      3.6*) echo "360";; \
      3.5*) echo "350";; \
      3.4*) echo "340";; \
      3.3*) echo "330";; \
      3.2*) echo "320";; \
      3.1*) echo "300";; \
      3.0*) echo "300";; \
      *) echo "ERROR";; \

# Choose here which include file to use: from autodetect or manually

# ----------------------------------------

# current dir
KERNVER=`uname -r`
DISTRO:=$(shell test -f /etc/redhat-release && echo 'redhat' || echo 'other')

dvb-usb-rtl2832u-objs := demod_rtl2832.o dvbt_demod_base.o dvbt_nim_base.o \
foundation.o math_mpi.o nim_rtl2832_mxl5007t.o nim_rtl2832_fc2580.o \
nim_rtl2832_mt2266.o rtl2832u.o rtl2832u_fe.o rtl2832u_io.o \
tuner_mxl5007t.o tuner_fc2580.o tuner_mt2266.o tuner_tua9001.o \
nim_rtl2832_tua9001.o tuner_fc0012.o nim_rtl2832_fc0012.o demod_rtl2836.o \
dtmb_demod_base.o dtmb_nim_base.o nim_rtl2836_fc2580.o nim_rtl2836_mxl5007t.o \
tuner_e4000.o nim_rtl2832_e4000.o tuner_mt2063.o demod_rtl2840.o \
tuner_max3543.o nim_rtl2832_mt2063.o nim_rtl2832_max3543.o \
nim_rtl2840_mt2063.o nim_rtl2840_max3543.o qam_demod_base.o qam_nim_base.o \
tuner_tda18272.o nim_rtl2832_tda18272.o rtl2832u_ioctl.o nim_rtl2832_fc0013.o \

obj-m += dvb-usb-rtl2832u.o

EXTRA_CFLAGS += -I$(KBUILD_SRC)/drivers/media/dvb/dvb-usb/ \
-I$(KBUILD_SRC)/drivers/media/dvb/dvb-core/ \
-I$(KBUILD_SRC)/drivers/media/dvb/frontends/ \
-I$(KBUILD_SRC)/drivers/media/common/tuners/ \

KINS = /lib/modules
ifeq ($(DISTRO),redhat)
KDIR = /usr/src/kernels/$(KERNVER)
KDIR = /usr/src/linux-headers-$(KERNVER)

make -C $(KDIR) SUBDIRS=$(PWD) modules

mkdir -p $(KINS)/$(KERNVER)/kernel/drivers/media/dvb/dvb-usb/
cp dvb-usb-rtl2832u.ko $(KINS)/$(KERNVER)/kernel/drivers/media/dvb/dvb-usb/
depmod -a

-rm -f *.o *.ko *.mod.c .*.o.cmd .*.o.d .*.ko.cmd Module.symvers Module.markers modules.order
-rm -rf .tmp_versions

Since i dont really have a clue what this stuff is all about (hence why i post in Beginners) i dont have much faith in this stuff.

Last option for me would be to create the missing directory and put the kernelsorces in there, after that i dont know.


April 29, 2014, 01:34:37 pm #4 Last Edit: May 02, 2014, 12:41:07 am by mcct
Man, I've just successfully compiled your driver RTL2832 from https://github.com/valtri/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0!!

You get Patric's kernel tree, go to its root, put your .config there (no need to download, just run zcat /proc/config.gz>.config) and run  make scripts, make prepare as you were going to.
Then cd to your DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0 source directory. You're supposed to run make ARCH=arm -C ~/linux-sunxi-pat-3.4.79 M=$PWD, but you'll get lots of fatal error: dvb-usb.h: No such file or directory. To avoid it, first run

ln -s ~/linux-sunxi-pat-3.4.79/drivers/media/dvb/{frontends,dvb-core,dvb-usb}/*.h .

You'll get the only WARNING: Symbol version dump ~/linux-sunxi-pat-3.4.79/Module.symvers is missing; modules will have no dependencies and modversions.

Now you can sudo modprobe ./dvb-usb-rtl2832u.ko. No errors. And no module in lsmod.
$ sudo modprobe -vvv ./dvb-usb-rtl2832u.ko 2>&1|grep fail
modprobe: DEBUG: lookup failed - trying to check if it's builtin

I believe its due to that WARNING. If you compile the entire kernel, this warning must not show any more.
Edit: it's due to newly compiled kernel being 3.4.79-sun7i (no "+" at the end!). Cannot track down the origin of that "plus", but if you boot into the new compiled kernel (moving modules directory and uImage), then no vermagic inconsistency. Still, dvb-usb-rtl2832u.ko won't load, telling "Unknown symbol", but these problems are linux-specific and in no way relevant to cubieboard. Please, report if you finally win.

Note: My newly compiled easycap.ko (from very old version 8.41) works fine with that flavor of Easycap video capture USB dongle I have.

Good luck.


You could try editing the .config file line:
to remove the "-sun7i+" so that it matches the kernel vermagic of the unpacked headers-3.4.79.tgz
and then re-compile the modules.
You can use modinfo to check the vermagic of the new module.


May 10, 2014, 11:02:30 pm #7 Last Edit: May 10, 2014, 11:29:05 pm by AndiBcool
Would be awesome if you can tell me what commands i need to use and what to do.
Like a step by step guide.
I have 3 people telling me different things, all say they manage to compile the driver but forgot to tell what exaclty i need to put in.
I just did set up the image the 4th time cloning the complete kernel sorce to cubietruck and try again.
so here is what i did from start:
After image is running:
sudo apt-get install build-essential
apt-get install curl
git clone https://github.com/patrickhwood/linux-sunxi
cd linux-sunxi
curl https://raw.githubusercontent.com/igorpecovnik/Cubietruck-Debian/master/config/kernel.config > .config
make prepare
make scripts

Does all work fine
git clone https://github.com/tmair/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0
cd DVB*
cd RTL*
make ARCH=arm -C ~/linux-sunxi M=$PWD

I get the error message
WARNING: Symbol version dump /root/linux-sunxi/Module.symvers
           is missing; modules will have no dependencies and modversions.

like mcct said. But it seem to compile
modprobe ./dvb-usb-rtl2832u.ko

The driver also does not show in lsmod
modinfo shows:
modinfo dvb-usb-rtl2832u.ko

filename:       /usr/src/DVB-Realtek-RTL2832U-2.2.2-10tuner-mod_kernel-3.0.0/RTL2832-2.2.2_kernel-3.0.0/dvb-usb-rtl2832u.ko
license:        GPL
version:        2.2.2
description:    Driver for the RTL2832U DVB-T / RTL2836 DTMB USB2.0 device
author:         Dean Chung<DeanChung@realtek.com>
author:         Chialing Lu <chialing@realtek.com>
author:         Realtek
srcversion:     AAA25889BBFEB311C88E559
alias:          usb:v0CCDp00E0d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0CCDp00D4d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0CCDp00D3d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0413p6A03d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1680pA332d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp9520d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp9530d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp9540d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp9550d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp9580d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp0680d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp0650d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp0640d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp0630d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v185Bp0620d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1164p3284d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1164p3280d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1164p6601d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0413p6F11d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0413p6680d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpA683d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4Dp0139d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpD286d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpC280d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpD803d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpC803d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpB803d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4DpA803d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1F4Dp0837d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pE41Dd*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD3A4d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD3A1d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pE77Bd*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD39Ed*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD39Cd*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD39Bd*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD39Ad*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD398d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD397d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD396d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD395d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD394d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1B80pD393d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1554p5026d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1554p5020d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1554p5013d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v13D3p3282d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v13D3p3274d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v13D3p3234d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0CCDp00B3d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0CCDp00A9d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p9202d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p3103d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p9201d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p8202d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p2101d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1108d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1107d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1106d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1105d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1104d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1103d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1102d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1D19p1101d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2825d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2824d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2811d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2810d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2823d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2822d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2821d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2820d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2837d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2834d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2841d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2840d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2839d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2836d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2838d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp2832d*dc*dsc*dp*ic*isc*ip*
vermagic:       3.4.79-sun7i+ SMP preempt mod_unload modversions ARMv7 p2v8
parm:           debug:Set debugging level (0=disable, 1=info, 2=xfer, 4=rc (or-able)), default=0 (int)
parm:           demod:Set default demod type (0=dvb-t, 1=dtmb, 2=dvb-c), default=0 (int)
parm:           dtmb_err_discard:Set error packet discard type (0=not discard, 1=discard), default=0 (int)
parm:           rtl2832u_rc_mode:Set default rtl2832u_rc_mode (0=rc6, 1=rc5, 2=nec, 3=disable rc), default=3 (int)
parm:           rtl2832u_card_type:Set default rtl2832u_card_type type (0=dongle, 1=mini card), default=0 (int)
parm:           snrdb:SNR type output (0=16bit, 1=dB decibel), default=0 (int)
parm:           adapter_nr:DVB adapter numbers (array of short)

So i guess it wont run because like carryonrewardless said it thinks its not for this Kernel.
So where do i find that config file to mod nd try the driver again ?
Oh i think u mean the .config i did curl.
i did edit it and did the make prepare and scripts but was nit the same he did also not do any scritps.
i did delete the driver (*.ko) and did make again but it was kinda fast also not like before but gave same warning.
Did modprobe again and still does not show in lsmod.

Still big thanks to you two helped me a lot but would have prefered if you did a step by step guide because im a beginner in such things and dont know much about the Linux shell too.
Might try fresh install with modded config or looking for some syntax how i can fix my version so that the driver might run.
Does also not show with dmesg.


May 12, 2014, 09:48:27 am #8 Last Edit: May 13, 2014, 07:12:41 am by mcct
Quote from: carryonrewardless on May 06, 2014, 05:59:52 am
You could try editing the .config file line:
to remove the "-sun7i+" so that it matches the kernel vermagic of the unpacked headers-3.4.79.tgz
and then re-compile the modules.
You can use modinfo to check the vermagic of the new module.

Unfortunately, it's not that easy. CONFIG_LOCALVERSION value may not get you where you want, and there's some discussion to that matter at http://stackoverflow.com/questions/12910969/buildroot-how-to-change-kernel-version-string: scripts/setlocalversion interferes.

But if you take Patrick's kernel source and .config he supplies, then the kernel and modules should compile in concert and leave you with -sun7i+ version, and afterwards you can change options according to Pecovnic, if you like. Also, I am not sure that make prepare won't hurt; the pristine kernel you get in result may not be what you want.

There's one strange thing about modules; my easycap.ko driver is loaded OK by insmod, but fails to load by modprobe. Although, after I substituted my home-made module for the stock one, it loads automatically when I attach the USB adaptor.


Quote from: mcct on May 12, 2014, 09:48:27 am
Unfortunately, it's not that easy. CONFIG_LOCALVERSION value may not get you where you want, and there's some discussion to that matter at http://stackoverflow.com/questions/12910969/buildroot-how-to-change-kernel-version-string: scripts/setlocalversion interferes.

This provides no contradiction. If you don't wish to edit .config directly you can use make .... menuconfig to adjust the localversion parameter before the the compile.
Use modinfo to check the module parameters after compiling.


So what commands i need to do to compile a working driver ?
By the way the Raspberry seems to have the same problem with missing kernel Headers but has an old driver in kernel. Need the other to get DVB-C support.


It looks like from my attempts at getting this going and from a fair bit of reading including:
that this DVB device will not be working on a 3.4 kernel. It was only fully up & going on 3.7 which is possibly not available for your cubieboard nor for my Allwinner A10 device.
The best chance is when 3.15 kernel is released for the Allwinner chips sometime soon.


i got a f0013 Tuner and it works on Raspberry pi but only DVB-T.
Somone managed to complie the driver for Kernel 3.6.11 and the other git has options for kernel headers 3.2 up to 3.11.

Dont really know maybe thease problems are because of missing kernel Headers and the missing Module.symvers file.

By the way i did try to compile it for Linux mint ( using the instructions given on git) but also got errors of missing directory that is actually there.

Dont know i think this compiling on linux is buggy and dont really work well.


The missing linux headers is part of the problem. Because we dont have linux headers you will also missing Module.symvers.
Without it you cant compile a working driver it seems.
This file is also not in the zip File slovenia did provide.

Here is what i found with same problem on raspberry pi:

"The main problem with that, is the absence of a file named Module.symvers, that contains the symbol versions of the running kernel and all of its modules. That file would normally come in the linux-headers package, that I mentioned above. To get that file, and be able to build 'good' modules for the kernel, you would need to build the entire kernel and all its modules yourself. At the end of the build, the file will be created."