[CM 10.2] linux headers for building a kernel module? - Nexus 7 Developer Discussion [Developers Only]

I'm trying to compile a kernel module for Cyanogenmod 10.2.1 on a Nexus 7 tablet (tilapia). I'm using for this task an ARM virtual machine with Debian installed on it.
To compile the module I need the CM linux headers, but I can't find where to get them. Can you please link me the source repo?
PS: I want to compile a driver for a usb to lan adapter:
http://www.asix.com.tw/download.php?sub=driverdetail&PItemID=105
http://www.lindy-usa.com/usb-20-fast-ethernet-adapter-usb-micro-b-42948.html

Lucas Malor said:
I'm trying to compile a kernel module for Cyanogenmod 10.2.1 on a Nexus 7 tablet (tilapia). I'm using for this task an ARM virtual machine with Debian installed on it.
To compile the module I need the CM linux headers, but I can't find where to get them. Can you please link me the source repo?
PS: I want to compile a driver for a usb to lan adapter:
http://www.asix.com.tw/download.php?sub=driverdetail&PItemID=105
http://www.lindy-usa.com/usb-20-fast-ethernet-adapter-usb-micro-b-42948.html
Click to expand...
Click to collapse
You don't need "cm linux" headers. There is no such thing. What you need is to compile from source the kernel you are using....which is some 3.1.10 kernel. Then you need to have the "3.1.10 kernel headers" installed. Finally you cross compile the USB to Lan driver against the sources of the kernel you compiled. If the compiled kernel is there....then the cross compiler must be properly linked to the source...and it will find the header files it needs and warn you of missing dependencies. It could be that you'll need to enable some things in the kernel build in order to have all the needed support for your driver.

Related

[FAQ/HOWTO] An introduction to how-to-build a kernel for MT6589

Hi guys,
I was working on this since some time and here it is
Please read FAQ first
FAQ :
Can I compile a MT6589 kernel for every phone ?
As you know, a MT6589 kernel won't fit in every MT6589 smartphone because of specific configs/files in the kernel source tree.
So, if you compile my kernel which is expected to work on a Faea F2S don't expect it to work on a Acer Liquid E3 for example.
Conclusion : You have to get the kernel source for your phone​
How can I check my kernel source ?
Of course, this is not enough to see "source code for ZTE N986", you have to check if it's full or not and if it works.
Most people don't know what is working kernel source. You just have to read the GPL guidelines that every manufacturer have to complain with :
“ The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. ”
The part which has not to be included is the toolchain but there should reference to it (which toolchain to use)
For MT6589 kernel, the toolchains arm-eabi-4.6 and arm-linux-androideabi-4.6 should be used. (mtk used arm-linux-androideabi-4.6 for kernel but it should be arm-eabi-4.6)
So now you know which toolchain to grab and then for kernel source you have to check this minimal structure :
bionic
kernel
mediatek
build
config
custom
kernel
platform​README​
If I have kernel source, can I build it for my device ?
Erm... Sometimes the structure is here but the kernel source is messy... Why ?
Because you were not provided the matching source of the kernel used on your smartphone and the reasons are multiple (I won't give details).
So, the idea is to run a first build. If you get errors, then check the step above about toolchain and structure.
The next step for fixing errors is to play with source. Good luck for that.​
What are the benefits of a custom kernel for MT6589 ?
First big benefit is to introduce kitkat compatibility because there was an issue on android binder driver in mtk kernel source.
Next benefit is to be able to remove some stuff from mtk which is useless on user side and waste ressources (a lot of debug for example).
Others benefits will be in optimizations or new features (see frandom for example)​
HOWTO :
Build from my repo (specific devices supported) - It's not for compiling your kernel source but to understand how kernel build works​I explain how to build from my repo first because it can help you to understand how you should build kernel source
Prerequisites : A build environment (actually Ubuntu Saucy x64 with build-essentials, ccache, repo, java, perl v5.14+ and openssl) and I won't explain how to get one as there is multiple howto on the net.
For repo, the idea is to create a bin directory in your $HOME (usually /home/accountname/), copy repo binary inside it and then add this bin to $PATH var.
BE CAREFULL TO WHAT YOU DO WITH $PATH VAR ! I always see people doing :
Code:
export PATH=/home/foo/bin
this is erasing $PATH var, just check before and after with echo $PATH
So the idea is to introduce your path AFTER the actual $PATH var
This is easy...
Code:
export PATH=[COLOR="red"]$PATH:[/COLOR]/home/foo/bin
And of course, $PATH is reset once you close terminal and I won't explain how to set $PATH automatically.
Once you got this, everything should be working and it will be easy
Code:
mkdir workdir
cd workdir
repo init -u https://github.com/Dr-Shadow/android_kernel_mt6589_manifest.git -b master
repo sync
Then you should get this in your workdir :
kernel
manifest
mtk-tools
out
ramdisk
scripts
toolchain​Just do :
Code:
cd kernel
./certificates.sh
./build.sh
./certificates.sh is needed only once (it's for signing flashable zip and it will setup some keys for it, just reply to questions and don't add passphrase)
And of course, the build.sh contains most things you need to know on steps for building kernel (which commands to use) and you need to know how it works ​Build from your own kernel source​
I'm building the doc... I have to remind which vars need to be overriden
Reserved
Reserved #2
Thanks for making this thread brother it will help us to learn... Subscribed
Looking forward to the how-to to build with your own kernel source.
Dr-Shadow said:
Hi guys,
I was working on this since some time and here it is
Click to expand...
Click to collapse
Thank you Dr-Shadow! This is very cool. I'm going to try it out!
Great
It's always nice to see further development on MTK Based Devices.
Regards
I'll chip in and say thanks too. Finally getting around to trying to compile Alcatel's OneTouch Hero (aka TCL Y910) provided sources.
I might be in as well with A820, but I'm relatively new to Android and have only done porting of 4.1 and 4.2 so far.
Haven't built anything although I have some knowledge about the source code and SDK, which I've only used for reference purposes and the tools from it.
Will try to compile the stock kernel this weekend, but I'm not quite sure if something else is needed, even if the kernel source seems complete to me.
I'm a quick learner and have a lot of programming experience in other technologies, even thought I'm more of a front-end developer these days.

[Q] Add driver to kernel

Hi,
I'm building a custom rom and everything works great except one driver!
I made a "make menuconfig" in kernel and the driver is not listed under device drivers. How can I add the driver?
I downloaded the Linux driver and successfully made .ko modules. Should I add the .ko module to kernel or the files "as is"?
After some hours of google this problem I found something about "linux-headers packages" insted of kompiling kernel.
"Reasons for NOT compiling a custom kernel - You merely need to compile a special driver. For this, you only need to install the linux-headers packages" - How?
Please help

[Q] Installing USB Ethernet Adapter drivers

I recently got an ASIX AX88179 USB 3.0 to Gigabit Ethernet adapter for my Android device running CyanogenMod based on Android 5.1.1 and the 3.4.* kernel.
The drivers for the device are provided as source code and are available:
http://www.asix.com.tw/FrootAttach/driver/AX88179_178A_LINUX_DRIVER_v1.14.2_SOURCE.tar.gz
ASIX represents that the drivers are "For Android 1.x/2.x/3.x/4.x/5.x, Linux kernel 2.6.25 and later".
I attempted to compile the drivers using the CyanogenMod-included Terminal emulator App, but could not get anything to compile. It seemed that the "make" command or tool is not recognized.
I found a note in the drivers source readme file:
Code:
Prepare to build the driver, you need the Linux kernel sources installed on the
build machine, and make sure that the version of the running kernel must match
the installed kernel sources.
I found kernel sources on https://www.kernel.org/ . How do I make use of the kernel sources?
The version 3.4.* kernel is frequently updated. Should I be recompiling the driver with new, updated kernel sources every time a new kernel version is installed?
Must the drivers be compiled on the system they are to be used on?
Is there a better way to handle driver preparations or acquisitions?

Building custom kernel for lineageos 17

I need help compiling the kernel for lineageos. I have followed all the instructions on their site for payton until brunch payton, instead using mka bootimage because I just want the kernel. Regardless, using brunch payton and mka bootimage I am met with the same error
error: vendor/motorola/sdm660-common/Android.bp:220:1: module "CneApp" variant "android_common": module source path "vendor/motorola/sdm660-common/proprietary/vendor/app/CneApp/CneApp.apk" does not exist
And sure enough this file is not there.
This has to do with the proprietary blobs, however I followed the steps exactly how they said to do it. It created the folders for the blobs and got some files. I did it by connecting my lineageos running moto x4 to the pc with adb.
All I need is the Moto x4 lineageos kernel built with the
CONFIG_F_USB_MASS_STORAGE=y
configuartion added to payton's defconfig. It should be simple, but the developer of lineageos for payton hasn't responded to me to add this in. This will enable support for DriveDroid
If anyone has experience with compiling android kernels I really need some help. The kernel that lienageos uses is msm8998. I would use the stock kernel since Moto released the latest however their tethering hardware acceleration is bugged all to hell so I'm using lineage.
I managed to get it to build with using the blobs from themuppets github, but I do not like it because they are outdated. Anyways, it built, but using the usb config settings in the defconfig did not help, DriveDroid still does not work. I'm starting to think this is just an incompatibility with android 10.
U building standalone ?
dhinesh_cool said:
U building standalone ?
Click to expand...
Click to collapse
if by standalone you mean just the kernel then yes. but i gave up, somethings up with the moto x4's usb. i have problems in fastboot with it, and now in the kernel. it's like the hardware is wired way different from other phones or the kernel is handling it improperly. but i cannot get this thing to build with usb mass storage.
I had the same problem while extracting the metadata from the phone. I could solve it by using the method that extracts them from a built image as described here: https://wiki.lineageos.org/extracti...acting-proprietary-blobs-from-file-based-otas
TIP: on the step "mount" step, I found that there is no "product.img" to be mounted. I went ahead and it worked anyways.

Matching a kernel's config for compatible kernel modules

I have:
Downloaded the exact kernel version running on my device from an AOSP mirror (4.9.170) (https://github.com/aosp-mirror/kernel_common.git)
Downloaded the exact compiler used to compile the kernel from my device:
Ran `cat /proc/version`, which returns "Linaro GCC 5.3-2016.05", which I downloaded from https://releases.linaro.org/components/toolchain/binaries/5.3-2016.05/aarch64-linux-gnu/
Took the kernel configuration from `/proc/config.gz`, copied it to the kernel source directory `kernel_common` as `.config`
Ran `make ARCH=arm64 CROSS_COMPILE=xxx oldconfig`
What I'm seeing:
First, the downloaded kernel source for 4.9.170 seems to think that my `config` is incomplete, since it will prompt me to answer ~15 extra configuration questions.
Second, this old Linaro compiled doesn't appear to support `-fstack-protector-strong` despite it being explicitly enabled in the `/proc/config.gz` file. So I end up disabling it with `./scripts/config --disable CONFIG_CC_STACKPROTECTOR_STRONG`
Finally, after successfully compiling, I take `net/ipv4/tcp_westwood.ko`, just as a test module, and try to load it on my Android device, and it fails:
`insmod: failed to load tcp_westwood_5.ko: Exec format error`
And in dmesg output: `tcp_westwood: disagrees about version of symbol module_layout`
My questions:
Can I assume that the `/proc/config.gz` file is not the actual file used to compile the running kernel, considering it doesn't completely configure the 4.9.170 kernel?
Am I on the right path to getting a kernel module that my kernel will load?
Background information:
I'm hoping this isn't very relevant, but just to head off some questions
This is a T95 Android TV device running what appears to be, to this newbie's eyes, a very Frankenstein'd Android 10 install (See https://www.cnx-software.com/2020/0...-comes-with-mali-g31-gpu-supports-android-10/)
I can't find any official - or unofficial - source for this device, which is why I'm going to all the trouble above.
I really appreciate any help, thank you!

Categories

Resources