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: http://www.codesourcery.com/sgpp/lite/arm/portal/package7853/public/arm-none-linux-gnueabi/arm-2010.09-50-arm-none-linux-gnueabi.bin

To install it, simply run:


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


Then follow the usual procedure:


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


I saved the settings and continued the build:


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


And received the following 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:


And compared it to the output generated with my module:


Do you see the small difference?

Original Mod:


My Module compiled from amery sources:


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:


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:

    to

    Then edit the Makefile file and change:

    to

    and then complete the full build:

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


My NEW Module


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


and no message was displayed, so I typed:


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

So that’s all what I needed.

Support CNX Software - Donate via PayPal, become a Patron on Patreon, or buy review samples
Subscribe
Notify of
guest
29 Comments
oldest
newest most voted
JP
JP
8 years ago

Where it says “According to tldp.org and haifu.org, you can’t 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).”

It should be “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).

JP
JP
8 years ago

There’s a new official release of the Android 4.0 for the Mele AX000:
http://pan.baidu.com/share/link?shareid=24132&uk=3610159878 (now it’s 1.2)

Alexufo
Alexufo
8 years ago

@JP
Official firmware are encrypted for unpack.

JP
JP
8 years ago

@Alexufo
You mean that the rar is password protected?
The rar file doesn’t have a password, I just unpacked it.

JP
JP
8 years ago

I’ve uploaded the firmware to two random file hostings:

http://speedy.sh/SrAhj/Mele-HTPC-120907-Ver1.2.rar
http://www.sendspace.com/file/klfjzi

Remember to use the PhoenixCard 3.0.6 (not included on the rar) under Windows 7.

Alexufo
Alexufo
8 years ago

@JP
No) img file for phoenix card encrypted. This is image byte 2 byte copy of prepare SD card.

Lori Wing
Lori Wing
8 years ago

Hi All, this information you’re providing is great if you are into building the Allwinner A-10 tablets themselves, but I am a new owner of one of them and am just trying to find a manual where I can find out how to make it work. The one that was included in the box is basically useless and I know there has got to be something out there that will make my experience a whole lot happier one then it has been thus far. Can anyone point me in a direction to find an “ENGLISH” version instruction manual of how… Read more »

Loran
Loran
8 years ago

It’s also possible, and simpler IMO, to use the options ‘–force-vermagic’ and/or ‘–force-modversion’ to skip the (protection) check done for kernel module loading.

However these options are only available for ‘modprobe’ tool, and apparently not for the simpler ‘insmod’. (but if ‘modprobe’ is present on the Android image you’re using, it seems easier to use it than forcing a different LOCALVERSION /SUBLEVEL in your kernel config).

io
io
8 years ago

after the clone command, is sufficient enter in the folder linux-allwinner

cd linux-allwinner
git checkout lichee-3.0.8-sun4i

and when you compile, compile for 3.0.8+

JP
JP
8 years ago

Hey don’t install this update, is completely focused to Chinese market. Most common components has been removed (at first sight), so don’t say that you weren’t informed (even the launcher has changed).

Lundman
8 years ago

I recently learnt the “+” is added to EXTRAVERSION if you have local git changes. (so related to git). So you don’t have to edit the local file per se.

Lundman
8 years ago

As for HTPC V1.2, I have a dd image too, which isn’t “encrypted”. But, I would not recommend International users install this. Stay with the previous ICS image.

Sergey
Sergey
8 years ago

I am totally confused as to beg for help from you! those who are in what I will describe below understands and can help me. It’s about the MELE A2000 rev 1.3 with firmware version Android 4.0.4 v 1.1 (kernel version 3.0.8 +) About the desired result: 1-Connect USB GPS to SirfIII via the existing bridge on the PL2303. 2 USB Bluetooth connection to use OBDII ELM327 scanner. 3-Connect USB DAC PCM2704 On firmware downloaded and installed to the office site, all konechnozhe not work. Searching on the Internet responses, I realized that the simple solution to make it work… Read more »

JP
JP
8 years ago

@Lundman
Hi Lundman,
Thank you for your tip, there’s people that download the source using the “zip” method of github and don’t want to mess with git :).

(I want to say thank you for your hard work in the linux/opensolaris community and I respect and admire your constantly commitment to the community. Keep up the good work!!.)

Adi
Adi
8 years ago

Hi JP, can this be used to building drivers(modules) for other devices such as bluetooth dongle ?
You see I had been trying to similar for the hackberry board its based on A10 chip and quite similar to melee >>https://www.miniand.com/products/Hackberry%20A10%20Developer%20Board

Let me know if there can be any help, I am new to this (will be happy to provide the board too )

Cheers !

JP
JP
8 years ago

@Adi
I added support for USB bluethoot dongles, but I just have one to test (an unbranded chinese one), and it failed. I guess that it was incompatible with the internal USB uhb, I’ve seen this kind of problem with other development boards (mini6410, mini2440, Vortex86) with devices that have multiple descriptors.

JP
JP
8 years ago

For all the people reading this article:
There are some essential tools needed (can be downloaded from the market)
An updated “su” binary (switch user, no “superuser”)
https://play.google.com/store/apps/details?id=com.noshufou.android.su&hl=en

a complete busybox:
https://play.google.com/store/apps/details?id=stericson.busybox&feature=search_result#?t=W251bGwsMSwxLDEsInN0ZXJpY3Nvbi5idXN5Ym94Il0.

a SSH/SFTP server:
https://play.google.com/store/apps/details?id=berserker.android.apps.sshdroid&feature=search_result#?t=W251bGwsMSwxLDEsImJlcnNlcmtlci5hbmRyb2lkLmFwcHMuc3NoZHJvaWQiXQ..

Script Manager:
https://play.google.com/store/apps/details?id=os.tools.scriptmanager&feature=search_result

This applications (for me) are a MUST have if you want to mess with the OS.

Stanislav Sinyagin
8 years ago

I’m selling my A10 hacking kit, as I have no time to exercise with it: http://txlab.wordpress.com/2012/09/27/for-sale-allwinner-a10-hacking-kit/

Sergey
Sergey
8 years ago

Hello, may you can halp me?
I want connect a touchscreen to mk802, I have compiled module (usbtouchscreen.ko), which loaded, but /dev/input/event* don`t appear.
In dmesg I see that module was loaded. In /sys touchscreen is present. Vendor id and product id in /sys and in module source are correct. Why touchscreen may not work?
ps sorry for my english 🙂

Waldemar
Waldemar
8 years ago

@Sergey
Sergey, could you please make this loadable usbtouchscreen.ko available somehow for me? I am also trying to get my usb touchscreen working and will work on it. i’m struggling for a long time and it’s very high on my priority list 🙂 or have you in the meantime got it working ?
Thanks a lot ! 🙂

Ilya
Ilya
7 years ago

Hi, please upload compiled joydev module to a file share service.

gingsz
gingsz
7 years ago

Hello
I builded the module, but there is no .ko file, where can in find it?

gingsz
gingsz
7 years ago


Thank you, it’s a very useful tutorial. 🙂

Tomas Kaluza
Tomas Kaluza
7 years ago

Hello! I am asking for help. I want to add bluetooth support to my Mele A2000. I want to be able to add bluetooth mouse, keyboard and headphones. I want to use D-Link DBT-122 USB Dongle. I created a virtual sever on Virtualmaster.com to do the development. (I also created a template for everybodys use, it is called “Mele A2000 android kernel development”, direct link is https://www.virtualmaster.com/virtualmaster/cs/images/3087. Feel free to use it. The server that can be created using this template is paid, but costs only some 3,- EUR / month. I choose this way for the poor internet connection… Read more »

DOH
DOH
7 years ago

@JP
you have to follow the instructions and select the components you want to include. This is a good thing. Many of us don’t want the entire world.

DOH
DOH
7 years ago

@DOH
not sure why this went to the bottom. I replied in response to JP who said not to install this update.

Advertisements