Building Kernel Modules for AllWinner A10 Android Devices (e.g. Joystick Support)

Reader JP has enabled Joystick support in Android 4.0.4 on its Mele A1000, this now works with a Playstation2 joystick via USB adapter, a Huskee PC joystick, and 2 other unbranded joysticks. In order to enable Joystick support he had to build a kernel module, and encountered a few issues, so he wrote an how-to which shows what challenges he went through and what solutions he found to those issues.I’m sharing today a slightly edited version of this how-to.

This How-to assumes that you have a valid Linux environment where you can build allwinner A10 kernel. The toolchain used was “Sourcery CodeBench for ARM GNU/Linux Lite“ which can be downloaded here:

To install it, simply run:

sudo ./arm-2010.09-50-arm-none-linux-gnueabi.bin

You’ll also need the latest Allwinner A10 kernel source:

git clone git://

Then follow the usual procedure:

make ARCH=arm sun4i_crane_defconfig
make menuconfig ARCH=arm

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 <[email protected]>
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*
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
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 and, 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.

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.