allwinner kernel build

refs:

http://www.cnx-software.com/2012/09/11/building-kernel-modules-for-allwinner-a10-devices-android/


make ARCH=arm cubieboard_defconfig
make menuconfig ARCH=arm

make your changes  for config


I then selected the modules needed for different kind of joysticks namely:

 --- Networking support
  <*>   Bluetooth subsystem support  ---> 
  <M>   HIDP protocol support
        Bluetooth device drivers  --->
  <M> HCI USB driver

[*] HID Devices  --->  
    Special HID drivers  --->    
  <M> Sony PS3 controller
  <M> DragonRise Inc. game controller                                                                              
           [*]   DragonRise Inc. force feedback
  <M> Pantherlord/GreenAsia game controller                                                                         
           [*]   Pantherlord force feedback support
  <M> GreenAsia (Product ID 0x12) game controller support                                                           
           [*]   GreenAsia (Product ID 0x12) force feedback support                                                         
  <M> SmartJoy PLUS PS2/USB adapter support                                                                         
           [*]   SmartJoy PLUS PS2/USB adapter force feedback support

I saved the settings and continued the build:

modules_install INSTALL_MOD_PATH=/MELE/Modules39
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- modules_install INSTALL_MOD_PATH=/MELE/MODULES

Then I copied my modules to my sdcard, went to a terminal that I downloaded from the android market and did (as root):

# insmod mymodule.ko

And received the following error:

insmod: init_module 'joydev.ko' failed (Exec format error)

So I thought: “It cannot be, I compiled the right kernel the right way, with the correct compiler that the guys at Mele used…” After some cups of coffee I found the mystical mistake by checking an existing kernel module from the Mele:

# modinfo rtl8150.ko

filename:       rtl8150.ko
license:        GPL
description:    rtl8150 based usb-ethernet driver
author:         Petko Manolov <petkan@users.sourceforge.net>
alias:          usb:v0586p401Ad*dc*dsc*dp*ic*isc*ip*
alias:          usb:v1557p8150d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v07B8p401Ad*dc*dsc*dp*ic*isc*ip*
alias:          usb:v3980p0003d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0411p0012d*dc*dsc*dp*ic*isc*ip*
alias:          usb:v0BDAp8150d*dc*dsc*dp*ic*isc*ip*
depends:
vermagic:       3.0.8+ preempt mod_unload modversions ARMv7

And compared it to the output generated with my module:

# modinfo hid-sony.ko

filename:       hid-sony.ko
license:        GPL
alias:          hid:b0003v0000054Cp0000024B
alias:          hid:b0005v0000054Cp00000268
alias:          hid:b0003v0000054Cp0000042F
alias:          hid:b0003v0000054Cp00000268
depends:
vermagic:       3.0.39 preempt mod_unload modversions ARMv7

Do you see the small difference?

Original Mod:

vermagic:       3.0.8+ preempt mod_unload modversions ARMv7

My Module compiled from amery sources:

vermagic:       3.0.39 preempt mod_unload modversions ARMv7

So that was the problem, the kernel refused to load the module because the “vermagic” is not the same.

So the logical thought would be to get the sources of 3.0.8+ kernel, and amery github repo has that too in a specific branch (lichee-3.0.8-sun4i)

So I compiled it, made the modules and the new vermagic looked as follows:

vermagic:       3.0.8 preempt mod_unload modversions ARMv7

The missing “+” is the problem, as it should show 3.0.8+ instead..

So I said, If I change the vermagic of the module the problem will be resolved, but.. if I change the vermagic and use the 3.0.39 source the kernel will explode and the world will collapse!

According to tldp.org and haifu.org, you can build a kernel module using version 3.0.xx (e.g. kernel 3.0.39), and load it in a system running kernel 3.0.yy (e.g. kernel 3.0.8.

So here are 2 methods I’ve followed to change the vermagic:

  • The hard and dirty way: With objcopy you can remove the .modinfo from the original Mele Module and insert that part on your compiled module, so the vermagic will be the same.
  • The easy and “not so dirty way”: Well, I know that this is dirty, but if you’re in a hurry…
    Go to amery source folder, edit the .config file and change:

    CONFIG_LOCALVERSION=""

    to

    CONFIG_LOCALVERSION="+"

    Then edit the Makefile file and change:

    SUBLEVEL = 39

    to

    SUBLEVEL = 8

    and then complete the full build:

    # make clean
    # make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
    # make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- modules_install INSTALL_MOD_PATH=/MELE/MODULES

You MUST compile the entire kernel, so the proper vermagic is inserted into the modules, if you are lazy and just compile the modules, the vermagic will be not inserted and you’ll see the same error again.

Then I checked the vermagic again:

Original Mele Module

vermagic:       3.0.8+ preempt mod_unload modversions ARMv7

My NEW Module

vermagic:       3.0.8+ preempt mod_unload modversions ARMv7

So to be sure, I copied the module to the sdcard, went to the terminal as root and did:

# insmod mymodule.ko

and no message was displayed, so I typed:

# dmesg

And at the end of the message, the module was correctly inserted!!

So that’s all what I needed.



Read more: http://www.cnx-software.com/2012/09/11/building-kernel-modules-for-allwinner-a10-devices-android/#ixzz2uF5GgeeZ

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值