E
E
emashev2020-05-16 19:10:32
linux
emashev, 2020-05-16 19:10:32

How to properly build a kernel module for armv7?

There is an ancient TV set-top box on android 4.2.2, I decided to make a console for retro games out of it. There are a lot of Chinese gempads in stock, which are defined as VID:PID 0079:0006 . But in my kernel on this console there is no module for them.
I found a piece of iron with the same A20 processor, kernel version and android version. There was also an instruction on how to compile this driver. I downloaded the sources, launched the assembly with parameters for cross-compilation:
./build.sh -p sun7i_android
The module was assembled, I threw it on the console - and there was a fiasco:

1|[email protected]:/system/vendor/modules # insmod hid-dr.ko                                                                                                                   
insmod: can't insert 'hid-dr.ko': invalid module format

In dmesg:
[15483.755630] hid_dr: disagrees about version of symbol module_layout


On the prefix core
[email protected]:/system/vendor/modules # uname -r                                                                                                                             
3.4.39+


I have 3.4.39 in the sources, in the Makefile I fixed SUBLEVEL to 39+ and rebuilt.
Still a fiasco.

I have already downloaded a couple of compiled modules from the console and compared with mine:

Here is from the console:
[email protected]:/temp/1# modinfo hi704.ko  
filename:       hi704.ko
license:        GPL
description:    A low-level driver for Hynix HI704 sensors
author:         raymonxiu
srcversion:     D520B3B57CDA80DAE6AC278
alias:          i2c:hi704
depends:        
intree:         Y
vermagic:       3.4.39+ SMP preempt mod_unload modversions ARMv7 p2v8


Here is my:

[email protected]:/temp/1# modinfo hid-dr.ko 
filename:       hid-dr.ko
license:        GPL
srcversion:     633B2932308A266BBE5C934
alias:          hid:b0003v00000079p00000011
alias:          hid:b0003v00000079p00000006
depends:        
intree:         Y
vermagic:       3.4.39+ SMP preempt mod_unload modversions ARMv7 p2v8


No difference. Maybe somehow you can bypass the check for a module mismatch with the kernel version?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
emashev, 2020-05-18
@emashev

I will answer myself, it turned out to assemble without swearing on insmod. I took the config from the prefix to /proc/config.gz
and edited the module assembly there. I built it with this config, not with arch/arm/ and insmod didn't swear anymore.
Perhaps someone will help.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question