How to build kernel module?

t20004571
Posts: 8
Joined: Fri Oct 19, 2012 2:28 am

How to build kernel module?

Postby t20004571 » Thu Nov 15, 2012 1:41 am

I want build pl2303.ko and ftdi_sio.ko two files, and has also been successfully build.
However, when these two files into the MK808 within /system/lib/modules and execute insmod will error.

# adb shell dmesg
log:
<4>[ 4818.036456] pl2303: Unknown symbol malloc_sizes (err 0)

Here's my build environment and processes:

OS:ubuntu 12.04 64bit
CROSS COMPILE:android-ndk-r8b/toolchains/arm-linux-androideabi-4.6

apt-get install:
# sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-dev:i386 g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc zlib1g-dev:i386
# sudo apt-get install ia32-libs
# sudo apt-get install lib32ncurses5-dev
# sudo apt-get install sharutils
# sudo apt-get install lzop
# sudo apt-get install qt3-dev-tools libqt3-mt-dev
# sudo apt-get install memtester

kernel source(thanks omegamoon):
# sudo git clone https://github.com/omegamoon/rockchip-rk30xx-mk808.git

Set which driver to make ko file:
# make menuconfig
Device Drivers --->
-----USB Support --->
----------USB Serial Converter support --->
---------------<M> USB FTDI Single Port Serial Driver
---------------<M> USB Prolific 2303 Single Port Serial Driver

build kernel module:
# make -j 12 CROSS_COMPILE=~/android-ndk-r8b/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86/bin/arm-linux-androideabi- modules > ~/makelog.txt

push pl2303.ko and ftdi_sio.ko these files to MK808 /system/lib/modules:
# adb push ~/rockchip-rk30xx-mk808/drivers/usb/serial/pl2303.ko /system/lib/modules
# adb push ~/rockchip-rk30xx-mk808/drivers/usb/serial/ftdi_sio.ko /system/lib/modules

insmod ko file:
# adb shell insmod /system/lib/modules/pl2303.ko
get an error:
insmod: init_module '/system/lib/modules/pl2303.ko' failed (No such file or directory)

show MK808 dmesg:
# adb shell dmesg
get an error:
<4>[ 8807.234058] pl2303: Unknown symbol malloc_sizes (err 0)

Can anyone help me? Thanks.
You do not have the required permissions to view the files attached to this post.

AndrewDB
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: How to build kernel module?

Postby AndrewDB » Thu Nov 15, 2012 4:23 am

Hi,
I suggest you use a different toolchain, such as arm-linux-gnueabi and NOT arm-linux-androideabi to compile the kernel.

t20004571
Posts: 8
Joined: Fri Oct 19, 2012 2:28 am

Re: How to build kernel module?

Postby t20004571 » Thu Nov 15, 2012 5:43 am

I use apt get gcc-arm-linux-gnueabi like this:
# apt-get install gcc-arm-linux-gnueabi

compile kernel module:
# make -j 12 CROSS_COMPILE=arm-linux-gnueabi- modules > ~/makelog.txt

insmod pl2303.ko and ftdi_sio.ko still get the same error:
<4>[26442.633270] pl2303: Unknown symbol malloc_sizes (err 0)
<4>[26451.581407] ftdi_sio: Unknown symbol malloc_sizes (err 0)
You do not have the required permissions to view the files attached to this post.

AndrewDB
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: How to build kernel module?

Postby AndrewDB » Thu Nov 15, 2012 9:44 am

t20004571 wrote:I use apt get gcc-arm-linux-gnueabi like this:
# apt-get install gcc-arm-linux-gnueabi

compile kernel module:
# make -j 12 CROSS_COMPILE=arm-linux-gnueabi- modules > ~/makelog.txt

insmod pl2303.ko and ftdi_sio.ko still get the same error:
<4>[26442.633270] pl2303: Unknown symbol malloc_sizes (err 0)
<4>[26451.581407] ftdi_sio: Unknown symbol malloc_sizes (err 0)


OK:
1) Build the kernel before you build the modules
2) build the modules, passing -V as a parameter to make (make becomes very verbose, but in this case you want it).
3) Then do a make modules_install and pass as a parameter the output directory that you want to hold your modules.

t20004571
Posts: 8
Joined: Fri Oct 19, 2012 2:28 am

Re: How to build kernel module?

Postby t20004571 » Sat Nov 17, 2012 3:31 am

I don't know how to passing -V as a parameter to make kernle module. :oops:
Could you tell me how to passing -V as a parameter to make? and make modules_install next.

here's my make command:
1.) make -j 12 CROSS_COMPILE=arm-linux-gnueabi- uImage > ~/uImagelog.txt

2.) make -j 12 CROSS_COMPILE=arm-linux-gnueabi- modules > ~/moduleslog.txt

3.) make modules_install INSTALL_MOD_PATH=~/kernel_modules > ~/modules_install_log.txt
You do not have the required permissions to view the files attached to this post.

AndrewDB
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: How to build kernel module?

Postby AndrewDB » Sat Nov 17, 2012 9:47 pm

Did you try to load the modules you built this last time?

t20004571
Posts: 8
Joined: Fri Oct 19, 2012 2:28 am

Re: How to build kernel module?

Postby t20004571 » Sun Nov 18, 2012 12:38 am

AndrewDB wrote:Did you try to load the modules you built this last time?


Yes, but still get same error.
The path I load last time is "~/kernel_modules/lib/modules/3.0.8+/kernel/drivers/usb/serial/pl2303.ko"

I think may be I less some packages or environment settings are not complete. :?:

AndrewDB
Posts: 144
Joined: Sun Oct 28, 2012 5:53 pm

Re: How to build kernel module?

Postby AndrewDB » Sun Nov 18, 2012 3:23 am

OK, I'll try to reproduce the error you are getting on my own MK808 after I get back to my office this coming week.

yobikap
Posts: 119
Joined: Tue Oct 09, 2012 1:08 pm

Re: How to build kernel module?

Postby yobikap » Mon Dec 24, 2012 5:58 am

I know what the exactly the problem is, that the module produces a "malloc_sizes error".

In the default kernel sources, SLAB is configured as the memory allocator. Change this to SLUB (most RK3306 devices comes with SLUB).

run:

Code: Select all

make menuconfig


General Setup > Choose SLAB allocator


After this, recompile your kernel, and compile your module again.

Source: http://blog.lophilo.com/2012/06/slab-slub-and-slob-linux-allocators.html

whitedavidp
Posts: 2
Joined: Sat Sep 07, 2013 10:29 am

Re: How to build kernel module?

Postby whitedavidp » Sat Oct 05, 2013 8:08 pm

Hello. I am trying to do the same sort of thing for my Minix Neo X5. Did this ever get resolved and working? Was the issue SLUB vs. SLAB? Do you have to build the kernel first before trying to build the modules? When I try to perform the make of the modules first I get prompted for which Wifi to use. Since I am only interested in the USB->Serial modules I responded 1-no wifi. Is this ok? Also I get prompted for something regarding gpios of which I am ignorant. What value should be entered? Thanks!


Return to “Development”

Who is online

Users browsing this forum: No registered users and 3 guests