Building a First Kernel for the Galaxy A20
by physwizz
At last, I've been able to build a very basic kernel.
This is a first attempt.
It's not overclocked so don't expect anything miraculous.
Thanks to @Chatur27for building help and @Topser99 for the flashable zip
THIS IS WHAT I DID
Requirements
Use Linux 64bit ( I used Linux Mint Mate in a Virtual Box)
Linux setup
$ sudo apt update
$ sudo apt upgrade
$ sudo apt-get install git-all
$ git config --global user.name "physwizz"
$ git config --global user.email "[email protected]"
Kernel setup
1. Download the compiler
GitHub - physwizz/compiler
Contribute to physwizz/compiler development by creating an account on GitHub.
github.com
Unzip into "Compiler" folder
2. Download the Source Code (https://opensource.samsung.com/main)
Search for A205 and select QQ version (Latin)
Extract the kernel.tar.7z
extract into "Kernel" folder
Beginners guide to github
I have always had a lot of difficulty with github.
I have jotted down a few things which might help some new kernel builders.
A. Github Setup
1. Go to github and Open a new Repo
I called mine "physwizz_kernel"
2. To set up SSH key
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Github Name"
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Press enter 3 times
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
$ sudo apt-get install xclip
$ xclip -sel clip < ~/.ssh/id_rsa.pub
3. The SSH key will be in clipboard
Go to github settings => SSH and GPG keys
Paste key here
B. Using github
1. Open Terminal In The Kernel Folder
$ git init
$ git remote add origin (github id) mine is [email protected]: physwizz/physwizz_kernel.git
$ touch README
$ git add README
$ git add --all
$ git commit -m "Initial commit"
$ git push -u origin main
2. To cherry pick a commit from another github repository
firstly add the other repository to your kernel
$ git remote add other https:<other address>
$ git fetch --all
$ git cherry-pick [hash_id]
3. to push changes to github
$ make clean && make mrproper
$ git add --all
if the change is your own
$ sudo git commit -a
write comment
ctrl o (to output)
enter
ctrl x (to exit)
then
$ git push origin main
if the change is a cherry pick
$ git commit "change made" --author="Author's name<author's email>"
then
$ git push origin main
4. If it doesn't work or if you want to try something else
$ git revert <commit hash code>
$ git push origin main
Or
$ git reset --hard < last clean commit hash >
$ git push origin main -f
$ git cherry pick <clean commits >
$ git push origin main
5. to edit last commit
$ git commit --amend -e
$ git push origin main
Please give any feedback.
@physwizz
Kernel Building
1. open the defconfig file with text editor
Mine was located at
/home/physwizz/Kernel/arch/arm64/configs/exynos7885-a20_defconfig
You can make a copy of this file and call it original_defconfig
CHANGES I MADE
physwizz_kernel_V1
CONFIG_LOCALVERSION="physwizz"
# CONFIG_CC_STACKPROTECTOR_STRONG is not set
Later versions in post #2
2. open terminal
cd Kernel
make clean && make mrproper
export CROSS_COMPILE=/home/physwizz/compiler/bin/aarch64-linux-android-
export ARCH=arm64
export ANDROID_MAJOR_VERSION=q
make exynos7885-a20_defconfig
make
3. Output is found in /home/physwizz/Kernel/arch/arm64/boot
4. Copy Image from boot folder and Insert it into the MyKernel.zip
5. Extract Version and edit it then reinsert
To use Anykernel to make your own zip
Extract MyKernel.7z to a folder, copy kernel image there, open terminal in that folder and type:
zip -r9 UPDATE-AnyKernel3.zip * -x .git README.md *placeholder
TheUPDATE-AnyKernel3.zip will be in the folder.
Cut and paste it outside the folder then flash it from TWRP.
Make sure you don't leave the UPDATE-AnyKernel3.zip in the MyKernel folder because it will interfere with the next zip you make.
Need to flash Magisk 20.4 or Magisk 21
Works with stock dtbo or Eureka dbto
If you flash Eureka dbto you will get overclocking of the GPU.
Overclocking
Version 1.4 is when I started overclocking
See post 2
Compiler (you can clone this)
https://github.com/physwizz/compiler
Source
https://github.com/physwizz/physwizz_kernel
NEWER VERSIONS IN POST#2
physwizz collection
A collection of guides, kernels and ROMs. Guides Complete Guide to the A20 GSIs for the A20 Quick Root and TWRP for the A20 Making my First Kernel for the A20 A20 Rooting Guide Making Your Own ROM Making Your Own Version of QwizzROM-a20...
forum.xda-developers.com
New Versions
Version 1.1 has one Samsung security disabled
# CONFIG_SECURITY_DEFEX is not set
Version 1.25
Version 1.25 has all 6 CPU governors enabled
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
Version 1.3
Userspace is the default governor
More securities disabled
Selinux enforcing
# CONFIG_TIMA is not set
# CONFIG_TIMA_LKMAUTH is not set
# CONFIG_TIMA_LKM_BLOCK is not set
# CONFIG_TIMA_LKMAUTH_CODE_PROT is not set
# CONFIG_UH is not set
# CONFIG_UH_RKP is not set
# CONFIG_RKP_KDP is not set
# CONFIG_RKP_NS_PROT is not set
# CONFIG_RKP_DMAP_PROT is not set
# CONFIG_TIMA_LOG is not set
# CONFIG_KNOX_KAP is not set
# CONFIG_DM_VERITY is not set
# CONFIG_SEC_RESTRICT_ROOTING is not set
# CONFIG_SEC_RESTRICT_SETUID is not set
# CONFIG_SEC_RESTRICT_FORK is not set
# CONFIG_SEC_RESTRICT_ROOTING_LOG is not set
# CONFIG_INTEGRITY is not set
# CONFIG_INTEGRITY_SIGNATURE is not set
# CONFIG_INTEGRITY_ASYMMETRIC_KEYS is not set
# CONFIG_INTEGRITY_AUDIT is not set
# CONFIG_SECURITY_DSMS is not set
# CONFIG_PROCA is not set
Version 1.4
Overclocked
Big 2080 Little 169
https://github.com/physwizz/physwizz_kernel/commit/06df375cfe6d9897a846eee8bcf9b05a48ae9cb7
v1.45
CPU underclocking
https://github.com/physwizz/physwizz_kernel/commit/261a80eb4ac14dc01c82af204d90420e220f386f
https://github.com/physwizz/physwizz_kernel/commit/6ff437e452d14d2bff2fd01bebd4af2e26f713d0
v1.46
Interactive set as default governor
Running very smoothly
V1.47
GPU overclocked
https://github.com/physwizz/physwizz_kernel/commit/839b38e9ec5f029a6764f057b78e5a0132dc281c
This didn't work
V1.49
Overclocking big CPU to 2184
https://github.com/physwizz/physwizz_kernel/commit/19ebb155873bfa2cf26cc685c8a746927d221064
V1.51
CPU minimum both 208MHz
V1.52
Cpu boost
Mali bts optimisation
Page boot
Muic support vbus boost
physwizz v2.19 A20
@physwizz
-Most securities disabled
-CPU Governors: conservative, ondemand, userspace, powersave, interactive, performance.
-Interactive is default governor
-SE linux enforcing
-CPU overclocked and underclocked
-Big: 208 - 2184
-Little: 208 - 1690
-GPU: 343 - 1300
-Works with Magisk 21
-Spectrum support enabled
-1.33mb dtbo.img (Thanks to geckyn & Chatur for dtbo config method)
Resources for further development
Resources from Carlos
· Overclock to CPU (https://github.com/carlos-burelo/Qu...mmit/9bb4d77e2f53ce7f4ada191c119d1127f9eee335)
· Permisive Mode (https://github.com/carlos-burelo/Qu...mmit/1a5a4a1bdd38115a0f7590b8f339fae856583a92)
· Enable Governors (https://github.com/carlos-burelo/Qu...mmit/1bfa400ca5c26746d99531180367d7195c4570b8)
Resources From Chatur
https://github.com/Chatur27/Eureka-...mmit/54a8b7104eb91b6847cb266ae3983aead1773855
https://github.com/Chatur27/Eureka-...mmit/d8591fc630ee75919dab405948190b92a80b17f9
https://github.com/Chatur27/Eureka-...mmit/b86b8733b4fd37790ba7921b9241b2bbbfdb6da9
https://github.com/Chatur27/Eureka-...mmit/305ec130c8a2a101c7166af9ed178d4ac4925596
https://github.com/Chatur27/Eureka-...mmit/295619ff9a097aa4ba2ee6109a23c0b440ec60fe
Thanks for your hard working, waiting for the overclocked kernel.
D00Mx64 said:
Thanks for your hard working, waiting for the overclocked kernel.
Click to expand...
Click to collapse
Overclocking requires adding lines of programming.
Right now I'm just tweaking the config file
Version 1.25 has all 6 CPU governors enabled
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
Version 1.3
Userspace is the default governor
More securities disabled
Selinux enforcing
Works with stock dtbo or Eureka dbto
If you flash Eureka dbto you will get some overclocking.
Frequency ranges
Stock dtbo
Big 936 - 1560
Little 449 - 1352
GPU 343 - 676
Eureka dtbo
Big 312 - 1560
Little 208 - 1352
GPU 343 - 1300
D00Mx64 said:
Thanks for your hard working, waiting for the overclocked kernel.
Click to expand...
Click to collapse
version 1.4
Overclocked
Big 2080 Little 1690
physwizz v1.45
Most securities disabled
All CPU Governors enabled
Userspace is default governor
SE linux enforcing
CPU overclocked and underclocked
Big: 312 - 2080
Little: 208 - 1690
Works with Magisk 21
Works with stock dbto
I will make interactive the default governor in v1.46
It's much smoother than userspace
Version 1.46 is running very smoothly
physwizz v1.46
Most securities disabled
All CPU Governors enabled
Interactive is default governor
SE linux enforcing
CPU overclocked and underclocked
Big: 312 - 2080
Little: 208 - 1690
Works with Magisk 21
Works with stock dbto
https://mega.nz/file/N1EkmDrD#x8dENjwTjghiN1HjdcGIk9cWW-nmwCGuqBr4G3DgvOQ
To use Anykernel to make your own zip
Extract MyKernel.7z to a folder, copy kernel image there, open terminal in that folder and type:
zip -r9 UPDATE-AnyKernel3.zip * -x .git README.md *placeholder
The zip will be in the folder.
Cut and paste it outside the folder then flash it from TWRP.
https://mega.nz/file/8sMA3Bpa#2iyTwsp1rmHdhy84tInEDpnmBIOc8ydkimeSfQSq2ZA
physwizz v1.47 A20
Most securities disabled
All CPU Governors enabled
Interactive is default governor
SE linux enforcing
CPU overclocked and underclocked
Big: 312 - 2080
Little: 208 - 1690
Works with Magisk 21
Works with stock dbto
GPU overclocked 343 - 1300
V1.51
CPU minimum both 208MHz
V1.52
Cpu boost
Mali bts optimisation
Page boot
Muic support vbus boost
to push changes to github
if the change is your own
$ sudo git commit -a
if the change is a cherry pick
$ sudo git commit "change made" --author="Author's name<author's email>"
then
$ git push origin main
If it doesn't work or if you want to try something else
$ git revert<commit hash code>
physwizz v2.19 A20
@physwizz
-Most securities disabled
-CPU Governors: conservative, ondemand, userspace, powersave, interactive, performance.
-Interactive is default governor
-SE linux enforcing
-CPU overclocked and underclocked
-Big: 208 - 2184
-Little: 208 - 1690
-GPU: 343 - 1300
-Works with Magisk 21
-Spectrum support enabled
-1.33mb dtbo.img (Thanks to geckyn & Chatur for dtbo config method)
@phiswizz do you know if this works to obtain bootloader unlock for the Galaxy SM-A215U
://ge0n0sis.github.io/posts/2016/05/how-to-lock-the-samsung-download-mode-using-an-undocumented-feature-of-aboot/
I have always had a lot of difficulty with github.
I have jotted down a few things which might help some new kernel builders.
B. Using github
1. Open Terminal In The Kernel Folder
$ git init
$ git remote add origin (github id) mine is [email protected]: physwizz/physwizz_kernel.git
$ touch README
$ git add README
$ git add --all
$ git commit -m "Initial commit"
$ git push -u origin main --force
To cherry pick a commit from another github repository
firstly add the other repository to your kernel
$ git remote add other https:<other address>
$ git cherry-pick [hash_id]
to push changes to github
$ make clean && make mrproper
$ git add --all
if the change is your own
$ git commit -a
write comment
ctrl o (to output)
enter
ctrl x (to exit)
then
$ git push origin main
if the change is a cherry pick
$ git commit "change made" --author="Author's name<author's email>"
then
$ git push origin main
If it doesn't work or if you want to try something else
$ git revert <commit hash code>
$ git push origin main
to edit last commit
$ git commit --amend
$ git push origin main
Related
Hi, I'm trying to build the tun module for VPN, but I can't load it because it seems my toolchain only builds for ARMv6.
Code:
tun: version magic '2.6.32.15-gf9c0527 preempt mod_unload ARMv6 ' should be '2.6.32.15-gf9c0527 preempt mod_unload ARMv7 '
Toolchains tested:
- android-ndk-r4b-linux-x86.zip
- arm-2010q1-188-arm-none-eabi-i686-pc-linux-gnu.tar.bz2.tar
What I did:
- downloaded 2.6.32.15 from kernel.org
- adb pulled config.gz from running android kernel, unpacked and moved it to .config
- export PATH=$PATH:/path/to/toolchain
- make ARCH=arm CROSS_COMPILE=$mytoolchain oldconfig
- make ARCH=arm CROSS_COMPILE=$mytoolchain menuconfig -> tuned version information and enabled tun module
- make ARCH=arm CROSS_COMPILE=$mytoolchain
- adb push drivers/net/tun.ko ...
insmod failes.
So what am I missing? Is the original HTC kernel somewhat otherwise patched? HTC doesn't seem to have released the 2.6.32.15 sources yet...whatever.
Thanks for any hints
Try the ndk toolchain or the prebuilt one in aosp. Use the 4.4.0 one.
Already tried the 4.4.0 one, same with the aosp toolchain from git.
I do think the stock 2.6.32.15 kernel is missing something (HTC patches?).
It's noticeable that some symbols like CONFIG_CPU_32v7 are not there when run oldconfig / menuconfig related to the original /proc/config.gz.
Already seen this in some custom Roms (module not loadable because of version mismatch), so has anyone built a functional (so loadable) module for HTC's Froyo Kernel? And if, how?
OK, very very dirty:
Get 2.6.32 from Android Kernel's git.
Code:
adb pull /proc/config.gz
gunzip -c config.gz > .config
make ARCH=arm CROSS_COMPILE=arm-none-eabi- menuconfig
## enable tun/tap module and append correct localversion ##
sed 's/EXTRAVERSION = .9/EXTRAVERSION = .15/g' Makefile #ouch
make ARCH=arm CROSS_COMPILE=arm-none-eabi- modules
adb push drivers/net/tun.ko ... and so on
I've decided to make a short tutorial and present the way I compile kernel modules (outside the kernel sources).
I've built few kernel modules (governors - ineractive and smartass, cifs, nls, etc) and I started receiving private messages asking how I did it.
For kernel modules that come with the kernel itself - cifs / tun for example - they just work if you compile the kernel and activate correct config parameters.
Some other modules (such as the smartass governor that doesn't come with the kernel) you compile outside the kernel source. However they require changes since kernel does not export the symbols the module needs to use - so you have to know what k_all_syms are needed, grab them from the phone and update the kernel module.
So there will be changes there. However, the main steps are:
a) follow tutorials to get the kernel / android ndk to compile. People seem able to do this.
b) then take the module you want (For example cpufreq_smartass.c from here: http://pastebin.com/rR4QUCrk ) and copy it in a new folder on the disk.
c) create a Makefile like the one below, but with your paths of course:
Code:
KERNEL_DIR=/home/viulian/android_platform/kernel-2.1.A.0.435/kernel
obj-m := cpufreq_smartass.o
PWD := $(shell pwd)
default:
$(MAKE) ARCH=arm CROSS_COMPILE=/home/viulian/android_platform/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
clean:
$(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) clean
d) execute make
Of course, the module source needs to be adjusted as you need to put in the frequencies, and also update the k_all_syms pointers .. But you can retrieve them from /proc/kallsyms on the device itself - just look for the method name, and use the address you see in the log.
If you still can't get it to compile, try to compile a very basic hello_world kernel module. I used the code below when testing:
Code:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("viulian, 2011");
MODULE_DESCRIPTION("Demo module for X10i");
int init_module(void)
{
printk("<1>Hello world\n");
// A non 0 return means init_module failed; module can't be loaded.
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
It is not perfect, but if you manage to insmod-it and check dmesg, you will see "Hello world" written there.
One more thing, linux kernel is fussy about the module versions. Even if nothing is changed between two kernel versions related to what a module needs, is enough a small difference in module's modinfo value to make the kernel to refuse the module.
For this, you need to trick your local kernel and adjust EXTRAVERSION value in kernel's main Makefile to have the exact version of the one on the device:
In X10 stock kernel (GB 2.3.3 release), the kernel version is 2.6.29-00054-g5f01537 visible in phone settings.
This means that the kernel on the phone will only accept modules that are compiled for that exact version. But the kernel version is just a string in the module .ko, so is a string comparison - the module might work perfectly, but is not loaded.
There is luck though, the string value comes from a define in kernel's Makefile, which you can change before you compile!
The Makefile in the kernel you are going to use to build the module will have to include these lines at the top:
Code:
VERSION = 2
PATCHLEVEL = 6
SUBLEVEL = 29
EXTRAVERSION = -00054-g5f01537
Other than that, it should work .. Expect phone reboots and difficulty to debug if stuff goes wrong. Android kernel doesn't come with syslog functionality, kernel prints are found in /proc/kmsg. Dmesg works, but you can't execute if if phone reboots.
I usually had to keep another adb shell opening with 'cat /proc/kmsg' which showed as much as possible from the module's outputs.
Happy compiling on your risk!
Good
Sent from my GT-S5570 using Tapatalk
Nice really nice.
Anyone help me.have someone who could compile the linux bluetooth modules please? Iam noob in linux
http://www.multiupload.com/58OPISAYNH
Anyone please can make a video tutorial?
That's really nice of you for sharing this.
Guide to Compiling Custom Kernel Modules in Android
I've spent the better part of today trying to figure out how to compile and load a custom kernel modules in android to aid me in my research. It has been in entirely frustrating experience, as there is almost no documentation on the topic that I can find. Below you will find my attempt at a guide. Hopefully this will help save someone else the hassle.
PREREQUISITES
Disclaimer: This list may be incomplete, since I've not tried it on a fresh install. Please let me know if I've missed anything.
Install the general android prereqs found here .
Download and un(zip|tar) the android NDK found here .
http://developer.android.com/sdk/ndk/index.html
Download and un(zip|tar) the android SDK found here .
http://developer.android.com/sdk/index.html
Download and untar the kernel source for your device. This can usually be found on the website of your device manufacturer or by a quick Google search.
Root your phone. In order to run custom kernel modules, you must have a rooted phone.
Plug your phone into your computer.
PREPARING YOUR KERNEL SOURCE
First we must retrieve and copy the kernel config from our device.
Code:
$ cd /path/to/android-sdk/tools
$ ./adk pull /proc/config.gz
$ gunzip ./config.gz
$ cp config /path/to/kernel/.config
Next we have to prepare our kernel source for our module.
Code:
$ cd /path/to/kernel
$ make ARCH=arm CROSS_COMPILE=/path/to/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi- modules_prepare
PREPARING YOUR MODULE FOR COMPILATION
We need to create a Makefile to cross-compile our kernel module. The contents of your Makefile should be similar to the following:
Code:
obj-m := modulename.o
KDIR := /path/to/kernel
PWD := $(shell pwd)
CCPATH := /path/to/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-linux-androideabi- -C $(KDIR) M=$(PWD) modules
COMPILING AND INSTALLING YOUR MODULE
Code:
$ cd /path/to/module/src
$ make
$ cd /path/to/android-sdk/tools/
$ ./adb push /path/to/module/src/modulename.ko /sdcard/modulename.ko
RUNNING YOUR MODULE
Code:
$ cd /path/to/android-sdk/
$ ./adb shell
$ su
# insmod /sdcard/modulename.ko
---------- Post added at 07:40 PM ---------- Previous post was at 07:37 PM ----------
IMPORNTANT TOO
Preparing a build environment
To build an Android kernel, you need a cross-compiling toolchain. Theoretically, any will do, provided it targets ARM. I just used the one coming in the Android NDK:
$ wget http://dl.google.com/android/ndk/android-ndk-r6b-linux-x86.tar.bz2
$ tar -jxf android-ndk-r6b-linux-x86.tar.bz2
$ export ARCH=arm
$ export CROSS_COMPILE=$(pwd)/android-ndk-r6b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
For the latter, you need to use a directory path containing prefixed versions (such as arm-eabi-gcc orarm-linux-androideabi-gcc), and include the prefix, but not “gcc”.
You will also need the adb tool coming from the Android SDK. You can install it this way:
$ wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
$ tar -zxf android-sdk_r12-linux_x86.tgz
$ android-sdk-linux_x86/tools/android update sdk -u -t platform-tool
$ export PATH=$PATH:$(pwd)/android-sdk-linux_x86/platform-tools
not yet ((((
Come on, please make video tuto
that's interesting.
Thanks for sharing
Any takers to do a video status? Come on people it would be good for newbies like me and many that tme around. When teaching the community grows.
hi
i'm traing to compile module for acer a500.
but i have got an error: Nothing to be done for `default'.
my makefile:
Code:
obj-m += hello.o
KDIR := /home/hamster/android
PWD := $(shell pwd)
CCPATH := /home/hamster/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-linux-androideabi- -C $(KDIR) M=$(PWD) modules
acer kernel code is located in /home/hamster/android
could you help me?
thanks
Thanks man. The step "modules_prepare" is what did the trick for me!
Makefile including tabs
hamsterksu said:
hi
i'm traing to compile module for acer a500.
but i have got an error: Nothing to be done for `default'.
my makefile:
Code:
obj-m += hello.o
KDIR := /home/hamster/android
PWD := $(shell pwd)
CCPATH := /home/hamster/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-linux-androideabi- -C $(KDIR) M=$(PWD) modules
acer kernel code is located in /home/hamster/android
could you help me?
thanks
Click to expand...
Click to collapse
This is probably because you need to add a tab in front of your $(MAKE). Without the tab it will not recognize the command.
Help with compiling module
I am trying to compile a module for Galaxy S. I am getting this error.
# insmod hello_world.ko
insmod: init_module 'hello_world.ko' failed (Exec format error)
These are the module related options that I have enabled in the .config
CONFIG_MODULES=y
CONFIG_MODULE_FORCE_LOAD=y
CONFIG_MODULE_UNLOAD=y
CONFIG_MODULE_FORCE_UNLOAD=y
# CONFIG_MODVERSIONS is not set
# CONFIG_MODULE_SRCVERSION_ALL is not set
Further this is the cat /proc/kmsg out put
<3>[53597.457275] hello_world: version magic '2.6.35.7-I900XXJVP-CL264642 preempt mod_unload ARMv7 ' should be '2.6.35.7-I9000XXJVP-CL264642 preempt mod_unload ARMv7 '
Why am I getting this error??
These are the steps I followed,
1. Downloaded the GT-I9000_OpenSource_GB.zip from samsung open source.
2. Change the EXTRAVERSION to EXTRAVERSION = .7-I900XXJVP-CL264642 (kernel version shown on phone is [email protected] #2)
I tried with EXTRAVERSION = [email protected] as well.
3. Added this line to the main make file -
core-y := usr/ TestModule/
5. Place the TestModule/ with the module code on the root directory.
6. Created the TestModule/Makefile and added this entry
obj-m := hello_world.o
4. On the read me of the kernel source it says to install Sourcery G++ Lite 2009q3-68 toolchain for ARM EABI, which I did.
5. Execute 'make aries_eur_defconfig'.
6. Execute make (again this is how the readme in the source says)
I have compiled this module for the emulator and it works fine, What am I doing wrong here?
Thanks in advance.
hamsterksu said:
hi
but i have got an error: Nothing to be done for `default'.
Code:
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-linux-androideabi- -C $(KDIR) M=$(PWD) modules
Click to expand...
Click to collapse
be sure to have {tab} not space or other symbol before: $(MAKE) in:
Code:
default:
$(MAKE) ARCH=arm CROSS_COMPILE=$(CCPATH)/arm-linux-androideabi- -C $(KDIR) M=$(PWD) modules
Hello,
I'm trying to load a module in my GS3 but I encounter problems about version. Maybe it's just a mismatch between the kernel i use to compile and the one on my phone.
I have a 3.0.31-742798 kernel version on my GS3, so I put this info in the makefile like viulian said but it didn't work.
I manage to compile and put the module on the phone, but when I want to insmod it, I've got
Code:
insmod: init_module 'hello_world.ko' failed (Exec format error)
and the /proc/kmsg say
Code:
... disagrees about version of symbol module_layout
And there no config.gz on the /proc/ dir like fabricioemmerick suggest to use
EDIT: I try to modify the symbol by copying the one of module from the phone. Have another error.
btw , with modinfo I found that the compilation always add -gc33f1bc-dirty after the subversion. Maybe something in the compilation goes wrong. Still use the stock kernel and the toolchain from the ndk sourcecode
m00gle said:
Hello,
I'm trying to load a module in my GS3 but I encounter problems about version. Maybe it's just a mismatch between the kernel i use to compile and the one on my phone.
I have a 3.0.31-742798 kernel version on my GS3, so I put this info in the makefile like viulian said but it didn't work.
I manage to compile and put the module on the phone, but when I want to insmod it, I've got
Code:
insmod: init_module 'hello_world.ko' failed (Exec format error)
and the /proc/kmsg say
Code:
... disagrees about version of symbol module_layout
And there no config.gz on the /proc/ dir like fabricioemmerick suggest to use
EDIT: I try to modify the symbol by copying the one of module from the phone. Have another error.
btw , with modinfo I found that the compilation always add -gc33f1bc-dirty after the subversion. Maybe something in the compilation goes wrong. Still use the stock kernel and the toolchain from the ndk sourcecode
Click to expand...
Click to collapse
Maybe your kernel source code version and your phone kernel version is different. If both are 3.0.31 but just the subversion is different, you can
try "insmod -f" to load. The -f option will ignore the version.
How can I get a dmesg of a specific kernel module using adb shell or any other way?
ravike14 said:
How can I get a dmesg of a specific kernel module using adb shell or any other way?
Click to expand...
Click to collapse
I'm not sure I understand the question ... you can just dmesg and grep by the module name ? Or some string that the module outputs ? You have full control
viulian said:
I'm not sure I understand the question ... you can just dmesg and grep by the module name ? Or some string that the module outputs ? You have full control
Click to expand...
Click to collapse
That's the part I don't understand, the grep part.. When I enter grep with my commamd I get as it's not a recognized command.. I'm using Windows is that the reason?
I'm using 'adb shell dmesg > dmesg.txt' how do I add the grep part for it and and the module name.. I did alot research but all are Linux kernel specific debugging guides.. What would be the exact command to grep a specific module.ko logs?
Sent from my HTC_Amaze_4G using XDA Premium 4 mobile app
ravike14 said:
I'm using 'adb shell dmesg > dmesg.txt' how do I add the grep part for it and and the module name.. I did alot research but all are Linux kernel specific debugging guides.. What would be the exact command to grep a specific module.ko logs?
Click to expand...
Click to collapse
I think I understand now
The order is this:
a) DroidSSHd from here: http://code.google.com/p/droidsshd/downloads/list
b) Busybox installer from the market.
c) Putty on your windows to connect to the phone
Now you can dmesg + grep once you are connected to the phone (don't forget to su before and allow DroidSSHd root).
You need to be connected to the phone since it is much more easier. Use the phone as your remote Linux machine.
How To Compile Rom From Source
We need following things to compile ROM from source
A Computer( Linux or Mac)
Java JDK
Some required Package for building Rom
Rules for Accessing USB devices
Choosing a Branch
Installing Java on the Machine
Here i am using Ubuntu(14.04 LTS) as a Linux machine but it should work for other Linux variant
Open a terminal and type following
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
This command will remove other existing openjdk installation
2. Once java is uninstalled use following command for installing correct version of java
sudo apt-get update
sudo apt-get install openjdk-s8-jdk
Check java version by typing following command
java -version
2. Installing some required packages
Type following in terminal to install some required packages
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip
3. Downloading Repo Tool and setting PATH
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now open the bashrc file and so we can include the repo tool:
sudo nano ~/.bashrc
Add following in the end of the file
export PATH=~/bin:$PATH
Now we need to reload bash variables to include the new path:
source ~/.bashrc
4. Initializing a Repo client
Now we need to create a directory where our source code will be downloaded. I am creating a directory AOSP here
mkdir AOSP
cd AOSP
In the following command insert your name and email address
git config --global user.name "Your_Name"
git config --global user.email "Your_EMail"
Now care fully select your branch whether you are downloading aosp or Cyanogenmod
repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.0_r7
type your desired branch name after the -b. This also applies to Cyanogenmod
5. Downloading source code
Now start downloading source code by typing following
repo sync
Note: this may take some time depending upon your internet speed and also please make sure you have enough storage
6. Configuring USB Access
type your username in following command and type enter
wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules
7. Now building Rom for your device
To build rom we need following
Device tree
Vendor tree
kernel
Finding device tree and Vendor Tree
To find your device tree search on Github or similar sources with your device code name. If you are lucky you will find it there and believe me it is the easiest way to build your rom rather than creating device tree and vendor tree from scratch
Your device tree will go on following location
device/device_manufacturer_name/device_codename
Same for vendor tree
vendor/device_manufacturer_name/device_codename
If you find device tree and vendor tree then how to download it
For device tree
git clone “Github url” -b (branch_tag) device/device_manufacturer_name/device_codename
2. For vendor tree
git clone “Github url” -b (branch_tag) vendor/device_manufacturer_name/device_codename
Note1: You may need to change some files if everything is not working or giving you some error in rom compiling. Look into output to find out error. You can use Google if you can't correct it
Note2: You may be not found your device tree and vendor tree then what to do?. You may need to create them. Please follow my guide
Creating Device tree and vendor tree from scratch
For creating device tree
http://azodik.com/how-to-create-device-tree-for-android-rom-building/
2. For creating Vendor tree
“Coming Soon”
Kernel
For kernel part if you are lucky than you can find your kernel source from Github or similar sources. If not you can use your prebuilt kernel Foolow this to extract your kernel http://azodik.com/how-to-create-device-tree-for-android-rom-building/
Kernel location
/kernel/device_manufacturer_name/device_codename
Downloading your kernel
Manually download it and extract to kernel location or use following command
git clone “Github url” kernel/device_manufacturer_name/device_codename
Note1: You can use your prebuilt kernel. To use your prebuilt kernel edit BoardConfig.mk file in your device tree.
Note2: If you created device tree from scratch following my guide. Use of prebuilt kernel set to default
How to build
Use following command for building your rom
Source build/envsetup.sh
lunch
Now select your device from menu
3. make or mka
I hope you found it usefull. Please follow my website for interesting guide. Please comment here if you face any error.
Thank You
Really a great guide bro!
Can you please post a rom porting guide? easy to understand and effective
sohamsen said:
Really a great guide bro!
Can you please post a rom porting guide? easy to understand and effective
Click to expand...
Click to collapse
Thank you very much. Sure i will post soon.
jai44 said:
Thank you very much. Sure i will post soon.
Click to expand...
Click to collapse
Nice tutor.. But it looks need an enormous data usage to do that. If i wanna porting rom for example slim rom nougat to my device (kenzo) can you give me some info how many data should i provide and how to do that? Thanks
thanks
elanglangit said:
Nice tutor.. But it looks need an enormous data usage to do that. If i wanna porting rom for example slim rom nougat to my device (kenzo) can you give me some info how many data should i provide and how to do that? Thanks
Click to expand...
Click to collapse
You can follow this guide. Read it again and again. I hope soon you will build your own Rom. You can comment here if you face any problem
While compiling pure nexus. I got this error. How to solve thishttp://cloud.tapatalk.com/s/589b479597bc0/tapatalk_1486571095280.jpeg?
@jai44 wow! you make it look so easy! :') I have subscribed to this thread. When I get free time, Ill build my own rom
Thank you so much!
not able to sync rr source...
After i type repo sync it doesnt do anything. I double checked my site direction and it appears to be fine. Any hints??
could you please spare some time and make a post about how to create vendor tree?
can anyone help with this error while porting dotos rom for lenovo a700
/home/ubuntu/android/dotos/out/build-dot_aio_row.ninja is missing, regenerating...
device/lenovo/aio_row/board/ril.mk:4: error: cannot assign to readonly variable: PRODUCT_PROPERTY_OVERRIDES
10:14:07 ckati failed with: exit status 1
and ril.mk script
# RIL
BOARD_PROVIDES_RILD := true
BOARD_RIL_CLASS := ../../../device/lenovo/aio_row/ril
PRODUCT_PROPERTY_OVERRIDES += ro.telephony.sim.count=2
Hy I'm building lineage os 14.1 for SM-J250F
Samsung Galaxy J2 Pro 2018 (SM-J250F) but im not going to giveup .. so I'm started to build roms my self .. fixed some build errors and successfully compiled but it stuck on Samsung logo(no bootanimation) also took pstore logs but it only store recovery logs .. sir can you please help to make it boot? Can u kindly tell me what changes i need to do in sources to make it boot? Or can u fix the issue in my tree? Please I'm hoping your feedback
Source android base : Android 7.1.1
Tried compilation : Lineage OS 14.1
I cant post my tree links due to new account please pm
jai44 said:
How To Compile Rom From Source
We need following things to compile ROM from source
A Computer( Linux or Mac)
Java JDK
Some required Package for building Rom
Rules for Accessing USB devices
Choosing a Branch
Installing Java on the Machine
Here i am using Ubuntu(14.04 LTS) as a Linux machine but it should work for other Linux variant
Open a terminal and type following
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
This command will remove other existing openjdk installation
2. Once java is uninstalled use following command for installing correct version of java
sudo apt-get update
sudo apt-get install openjdk-s8-jdk
Check java version by typing following command
java -version
2. Installing some required packages
Type following in terminal to install some required packages
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip
3. Downloading Repo Tool and setting PATH
mkdir ~/bin
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
Now open the bashrc file and so we can include the repo tool:
sudo nano ~/.bashrc
Add following in the end of the file
export PATH=~/bin:$PATH
Now we need to reload bash variables to include the new path:
source ~/.bashrc
4. Initializing a Repo client
Now we need to create a directory where our source code will be downloaded. I am creating a directory AOSP here
mkdir AOSP
cd AOSP
In the following command insert your name and email address
git config --global user.name "Your_Name"
git config --global user.email "Your_EMail"
Now care fully select your branch whether you are downloading aosp or Cyanogenmod
repo init -u https://android.googlesource.com/platform/manifest -b android-7.1.0_r7
type your desired branch name after the -b. This also applies to Cyanogenmod
5. Downloading source code
Now start downloading source code by typing following
repo sync
Note: this may take some time depending upon your internet speed and also please make sure you have enough storage
6. Configuring USB Access
type your username in following command and type enter
wget -S -O - http://source.android.com/source/51-android.rules | sed "s/<username>/$USER/" | sudo tee >/dev/null /etc/udev/rules.d/51-android.rules; sudo udevadm control --reload-rules
7. Now building Rom for your device
To build rom we need following
Device tree
Vendor tree
kernel
Finding device tree and Vendor Tree
To find your device tree search on Github or similar sources with your device code name. If you are lucky you will find it there and believe me it is the easiest way to build your rom rather than creating device tree and vendor tree from scratch
Your device tree will go on following location
device/device_manufacturer_name/device_codename
Same for vendor tree
vendor/device_manufacturer_name/device_codename
If you find device tree and vendor tree then how to download it
For device tree
git clone “Github url” -b (branch_tag) device/device_manufacturer_name/device_codename
2. For vendor tree
git clone “Github url” -b (branch_tag) vendor/device_manufacturer_name/device_codename
Note1: You may need to change some files if everything is not working or giving you some error in rom compiling. Look into output to find out error. You can use Google if you can't correct it
Note2: You may be not found your device tree and vendor tree then what to do?. You may need to create them. Please follow my guide
Creating Device tree and vendor tree from scratch
For creating device tree
http://azodik.com/how-to-create-device-tree-for-android-rom-building/
2. For creating Vendor tree
“Coming Soon”
Kernel
For kernel part if you are lucky than you can find your kernel source from Github or similar sources. If not you can use your prebuilt kernel Foolow this to extract your kernel http://azodik.com/how-to-create-device-tree-for-android-rom-building/
Kernel location
/kernel/device_manufacturer_name/device_codename
Downloading your kernel
Manually download it and extract to kernel location or use following command
git clone “Github url” kernel/device_manufacturer_name/device_codename
Note1: You can use your prebuilt kernel. To use your prebuilt kernel edit BoardConfig.mk file in your device tree.
Note2: If you created device tree from scratch following my guide. Use of prebuilt kernel set to default
How to build
Use following command for building your rom
Source build/envsetup.sh
lunch
Now select your device from menu
3. make or mka
I hope you found it usefull. Please follow my website for interesting guide. Please comment here if you face any error.
Thank You
Click to expand...
Click to collapse
how much storage is used to sync sir?
BryanHafidz said:
how much storage is used to sync sir?
Click to expand...
Click to collapse
depend on rom for me los17 took almost 70gb
I wanted to enable certain kernel features and in my Android 10 build for Pixel 3. I downloaded and built the correct msm kernel and successfully flashed it on the Pixel. To build the kernel I'm using the build/build.sh from the kernel source. I tried adding a custom defconfig file in private/msm-google/arch/arm64/configs/ and changing the DEFCONFIG variable in build.config to that file. When I compile I get following error:
Code:
++ echo ERROR: savedefconfig does not match private/msm-google/arch/arm64/configs/sdm845_defconfig
ERROR: savedefconfig does not match private/msm-google/arch/arm64/configs/sdm845_defconfig
How can I compile the kernel with a custom defconfig? It doesn't have to be through the build.sh method (although it would be preferable)
gardeimasei said:
I wanted to enable certain kernel features and in my Android 10 build for Pixel 3. I downloaded and built the correct msm kernel and successfully flashed it on the Pixel. To build the kernel I'm using the build/build.sh from the kernel source. I tried adding a custom defconfig file in private/msm-google/arch/arm64/configs/ and changing the DEFCONFIG variable in build.config to that file. When I compile I get following error:
Code:
++ echo ERROR: savedefconfig does not match private/msm-google/arch/arm64/configs/sdm845_defconfig
ERROR: savedefconfig does not match private/msm-google/arch/arm64/configs/sdm845_defconfig
How can I compile the kernel with a custom defconfig? It doesn't have to be through the build.sh method (although it would be preferable)
Click to expand...
Click to collapse
I don't know if it's solved, but I solved the problem removing the "check defconfig" in build.config (the symlink in the root which points to the kernel build.config).
Change
Code:
POST_DEFCONFIG_CMDS="check_defconfig"
to
Code:
POST_DEFCONFIG_CMDS=""
I've been working with a Google engineer who showed me the fix for my savedefconfig problem. Maybe it will fix yours, too.
The key is to set ARCH:
Code:
$ export ARCH=arm64
Here's the context and full procedure. My work is based on the b1c1_defconfig config. Your directory names may vary.
Code:
$ cd private/msm-google
$ export ARCH=arm64 # this is the magic line
$ make b1c1_defconfig # This sets up the config for my hardware. Yours is probably different.
$ make menuconfig
Now edit the kernel configuration and save it as ".config", the default.
When you're done:
Code:
$ make savedefconfig
$ cp defconfig arch/arm64/configs/b1c1_defconfig # or whatever your hardware configuration is
$ make mrproper
With luck, you won't see any savedefconfig problems.
I've been stuck at this for more than a week, so I'd appreciate any help.
What am I trying to do? (you can skip this part if you want)
I'm trying to do android kernel exploitation. That's not my current problem though. To learn kernel exploitation, I need to be able to get a version of android that is vulnerable to a certain vulnerability. So here's what I'm doing:
1. Going here to select a CVE that I want to learn how to exploit
2. After selecting a CVE, I need to select a build that is vulnerable to that CVE from here
3. Now that I have chosen a build (QQ3A.200805.001 in my case), I note its branch name (android-10.0.0_r41 in my case)
4. Now I need to be able to run this build in the android emulator (qemu) once as a production build, and once with KASAN+KCOV+debugging symbols for gdb
Before I begin, I'm following these guides:
1. https://source.android.com/devices/tech/debug/kasan-kcov
2. https://source.android.com/setup/build/building-kernels-deprecated
3. Google
My Setup:
I did this to download everything I need:
Bash:
git clone https://android.googlesource.com/kernel/msm
cd msm
git fetch --all --tags --prune
git checkout remotes/origin/android-msm-coral-4.14-android10
cd ..
mkdir AOSP
cd AOSP
repo init -u https://android.googlesource.com/platform/manifest
repo sync -j`nproc`
repo init -b android-10.0.0_r41
repo sync -j`nproc`
cd ..
When I went to the AOSP directory and tried compiling with:
Bash:
source ./build/envsetup.sh
lunch aosp_flame-userdebug # For the Pixel 4
m
It compiled in 4 hours, but it worked.
My First Issue:
I then created this bash script in the main folder to try to compile the msm kernel normally (without KASAN/KCOV):
Bash:
###########
# Params: #
###########
ARCH=arm64
CONFIG=cuttlefish_defconfig
###########
# Script: #
###########
read -p "Compile with clang instead of gcc? [y/N] " USE_CLANG
if [ $USE_CLANG == y ] || [ $USE_CLANG == Y ]; then
COMPILER=clang
CC_PATH=$(pwd)/AOSP/prebuilts/clang/host/linux-x86/clang-r346389c/bin/
else
COMPILER=gcc
CC_PATH=$(pwd)/AOSP/prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/
export CROSS_COMPILE=aarch64-linux-android-
fi
export ARCH=$ARCH
export PATH=$PATH:$CC_PATH
cd msm
make clean
make distclean
make $CONFIG
make CC=$COMPILER
When I run it with GCC, I get bombarded with depreciation warnings and I get an error:
Code:
Android GCC has been deprecated in favor of Clang, and will be removed from
Android in 2020-01 as per the deprecation plan in:
https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/master/GCC_4_9_DEPRECATION.md
...
Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong not supported by compiler
When I run it with clang, I also get a ton of warnings and this error:
Code:
./arch/arm64/include/asm/stack_pointer.h:8:51: error: register 'sp' unsuitable for global register variables on this target
register unsigned long current_stack_pointer asm ("sp");
...
In file included from ./include/linux/kvm_host.h:14:
./include/linux/signal.h:81:11: warning: array index 3 is past the end of the array (which contains 1 element) [-Warray-bounds]
return (set->sig[3] | set->sig[2] |
Full outputs for the script can be found here (for gcc) and here (for clang). Basically my first issue is that I don't know why I'm getting these compilation errors. So any suggestions would be greatly appreciated.
My Second Issue:
Now, I am checking out the remotes/origin/android-msm-coral-4.14-android10 branch in the msm repo, but I think this isn't the way to go because I need the kernel version that corresponds to a certain build/branch (QQ3A.200805.001 or android-10.0.0_r41 in my case). I think I need to build the exact version that is precompiled in the AOSP repository.
For example, if I go to the AOSP/device/google/coral directory, and run git log, I get something like this:
Code:
commit 62d311ad7cfc3e76a5278634427596462069b44d (HEAD, tag: android-10.0.0_r41, tag: m/android-10.0.0_r41, aosp/android10-qpr3-release)
Merge: 7b91fff 0657c80
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 23:45:11 2020 +0000
Merge cherrypicks of [11827366, 11829660, 11829049, 11829662, 11829647, 11829300, 11826697, 11829719, 11829051, 11829663, 11829664, 11829838, 11829052, 11829472, 11829586] into qt-qpr3-release
Change-Id: Ic126de75c24133f8d43df7c9d8f09059a9ca8089
commit 0657c80f016720f70ed6f9618f928a30e71f2b79
Author: wenchangliu <[email protected]>
Date: Tue Mar 24 18:11:18 2020 +0800
coral: Add seccomp policy for Codec2 process
Add seccomp policy for Codec2 process.
Bug: 149511958
Test: adb shell killall media.hwcodec
Change-Id: Iab64bd42ead0c5a27769a757007282c2dddf911d
(cherry picked from commit 3628a510a808a52c4ebf69958a8343928e5df3f2)
(cherry picked from commit 45a6093f3d085ca2a531c2607bd12dbc1eff6bf9)
commit 7b91fffc14afb41cf14772566272c72b37c36785
Merge: 2e7f1a3 e8c9484
Author: android-build-team Robot <[email protected]>
Date: Wed Jun 10 00:37:23 2020 +0000
...
Link for this exact commit/tag can be found here. However, there is no android-10.0.0_r41 tag in the msm source repo, so I don't know which version of the msm repo corresponds to the prebuilt one in the AOSP directory. And.. I don't know where to start looking tbh.
Any help is greatly appreciated.