[dev][kernel][kexec] - Xperia Z1 Original Android Development

Last Update : August, 19, 2014
Hi,
I'm still try to bypass the MMU protection.
I have fixe a lot of bug, like memory misalignment, bad adresses allocation, dtb correction, etc...
Last sources and binaries here :
kexec-tools V11.zip : http://forum.xda-developers.com/attachment.php?attachmentid=2902912&stc=1&d=1408401794
kexec-tools binaries V11.zip : http://forum.xda-developers.com/attachment.php?attachmentid=2902913&stc=1&d=1408401794
Sorry, i have always 13 sec reboot after new kernel boot.
"cpu_proc_fin" use a "mcr p15" to init cache and proc that cause freeze.
I try to find solution for that.
Last Update : June, 22, 2014
Hi,
My sources are horrible... but i give something new.
This kexec is for stock kernel only (tested on .757). I thinks theses sources work on other kernel too.
In "kexec-tools V10.zip", you have all my sources. It's highly recommended to mod them to have something OK.
In "kexec binaries.zip", you have binaries to install
=> "kexec_load.ko" and "procfs_rw.ko" must be placed in "/system/lib/modules" folder with "chmod 777"
=> "kexec" must be placed in /system/bin" folder with "chmod 777"
=> cd /system/lib/modules
=> insmod kexec_load.ko
For sources :
Mod and adapt all you want, it's free.
You have 2 scripts in Zip : "./compil-kexec" in "kexec-tools" folder to rebuild and send in device directly (install Adbtcp on device and send by tcp with : adb connect xxx.xxx.xxx.xxx) = work perfectly with me.
"scriptZ1" is for compil stock kernel or another kernel (doomlord kernel for eg)
You must rename "custom_final_files" folder after compil to "final_file" manually ; You can have guest kernel in "custom_final_files" and stock kernel in "final_files" for "kexec-tools" path ... Don't mix a guest and host kernel please ^^
I am tired... i let you test and say if it's ok for you...
Thank a lot to munjeni for his help.
kexec-tools V10.zip : http://forum.xda-developers.com/attachment.php?attachmentid=2811994&stc=1&d=1403456181
kexec binaries.zip : http://forum.xda-developers.com/attachment.php?attachmentid=2811995&stc=1&d=1403456181
Last Update : November, 23, 2013
Hi,
For few days now, i haven't no more kernel panic with my kexec.
I have fixed few stuffs into sources, and add a lot.
These adds are, to include a "dt.img" image file into kexec load process.
This image file is a "device_tree" image to match hardware to software.
So, i assume to don't include atags into boot process, but pass bootloader informations by this DT.
I have programmed a little scan memory to found dynamicly all magic tags, because i found 3 device_tree into memory (magic is "0xd00dfeed").
These 2 device_tree are echo from first and nice structure.
The boot process need to have informations from this DT, and need all informations to initialize hardware (no HDW initialisation by the kernel)
I must first fix issues ; Regroup zImage and dt.img into memory to load a solid bloc to kexec_load module to boot into, and second, fix an offset i can't explain, 0x800 in memory causing misalignment memory
Keep tuned..
Last Update : November, 17, 2013
Hi everybody,
My kexec-tools work for Sony Xperia Z1 stock kernel "3.4.0-perf"
This tools can work on all locked bootloader for all locked device, not only Sony or Z1 models.
This kexec-tools add a kexec_load kernel module (LKM) and use a driver to grant a communication between "kexec" user program and kexec_load.ko module
what is for ?
"kexec" user program load in memory a custom kernel in zImage format, but can load ".tar" image too
This user tool load ramdisk in memory if necessary
This tool is for this purpose only, and don't keep in memory the custom kernel at device reboot.
It is a "user" program, not a "kernel" extension... So, to really do the magic, we need the host kernel (stock sony locked kernel) have a kexec_load capability to reboot in a new gest kernel (custom kernel).
Infortuntly, stock kernel don't have kexec_load capability.
Sony have compiled his stock kernel without this option, and "standard" kexec-tools "need" this option to work.
To see all system call capability of kernel, you can run theses command :
Code:
echo 0 > /proc/sys/kernel/dmesg_restrict
echo 0 > /proc/sys/kernel/kptr_restrict
cat /proc/kallsyms
Do all grep you want here.
The "echo 0" "restrict" is here to unmask logical adresses to "system calls"
Like you can see, "__NR_kexec_load" capability isn't here.
To add kexec_load capability in stock locked kernel, we need to add manualy a kernel module wich add this function into the kernel.
Why ? Because the way to keep in memory a custom kernel need to know a lot of parameters, and keep a specific memory range alive at reboot.
Only kernel can do this.
All user program will be terminated at reboot.
"Standard" kexec_load.ko module use a method to implement the "__NR_kexec_load" function in system call table.
Since 2.6.0 kernel, linux for security reason, have locked in memory the "system_call_table" ; No more add or modification is authorized.
If kexec tool try to add a value, "kexec_load" for us, we causes a kernel panic, and reboot device.
For this reason, i have modify kexec user program and kexec_load module to implement a driver to talk to each other.
this driver replace syscall method, and we no more need to use a system call table.
For this reason, this tool is now compatible with modern kernel like our "3.4.0"
For this reason, this tool must work for other device (Xperia X, P, S, etc...) and another brand
For this reason, if kernel is locked, we can bootstrap to run a new kernel.
Installation
First, you can compil your own kexec tool
Here, sources : http://forum.xda-developers.com/attachment.php?attachmentid=2397299&stc=1&d=1384689174
And here, the binaries : http://forum.xda-developers.com/attachment.php?attachmentid=2397305&stc=1&d=1384689406
(it's not a cwm zip, i have no time to create an installer for now ; use "./compil-kexec" if you want an automatic install)
Install *.ko in /system/lib/modules
Install kexec and kdump in /system/bin
Grant with "chmod 777"
Unzip in kexec-tools folder
Install a toolchain (sudo apt-get install gcc-arm-linux-gnueabi)
launch => ./compil-kexec
what's all
This script can do everythinks for you
- Compilation of tools
- Compilation of modules
- installation in device
This script can compil for every brand you have.
Except you must remove or adapt the patch (see below why)
Patch ??
This patch is because a module must be compiled in the same time the kernel himself.
For this reason a "vermagic", an identifier, is used by system to block every module not compil with kernel
Some custom kernel bypass this to authorize every modules.
But for stock kernel, it is not allowed.
You can easely strapp this by busybox.
"busybox modprobe" for help
"-f" to force load without vermagic
To see this vermagic :
Code:
# uname -r
This "uname -r" must be the same that
Code:
# strings kexec_load.ko | grep vermagic
vermagic=3.4.0-perf-g66807d4-02450-g9a218f1 SMP preempt mod_unload modversions ARMv7
If you want use automaticaly this vermagic, you can modify into the custom kernel this file :
Code:
"include/config/kernel.release" and add :
"3.4.0-perf-g66807d4-02450-g9a218f1"
This file will be use at module compil to match the vermagic.
Infortunatly, it is not enought. :silly:
The infamous "no symbol version for module_layout"
When a module compil is created, it use symbols link to system call function, translate by adresses
Theses symbols are not at same physical adresses in stock kernel and modules (compiled from DooMLoRD kernel).
So, theses adresses must be convert into modules itself to match with stock symbols adress.
A patch is needed.
If you use my script, modules are automatically patched.
Here patches :
Code:
sed -i 's/\x32\x76\x86\x29/\x72\xFF\x5E\x20/' procfs_rw.ko
sed -i 's/\x32\x76\x86\x29/\x72\xFF\x5E\x20/' kexec_load.ko
sed -i 's/\xBB\xD0\xF8\x4D/\x0E\x1C\x63\x77/' kexec_load.ko
sed -i 's/\xA6\x26\x81\x1A/\xD4\x56\x02\x7E/' kexec_load.ko
sed -i 's/\xA3\xD1\xEC\x96/\xEC\x43\x28\x1A/' kexec_load.ko
sed -i 's/\x8C\xE6\x6A\x5F/\x3D\xDF\x02\xF2/' kexec_load.ko
sed -i 's/\x3E\xF3\xEF\xE9/\x18\x7F\xA6\x8A/' kexec_load.ko
sed -i 's/\x8B\xD2\x92\x10/\xC8\x19\x08\x9C/' kexec_load.ko
sed -i 's/\x1C\xE8\x18\xE1/\x7C\x71\x9E\xEF/' kexec_load.ko
sed -i 's/\xAB\x2C\x2F\x8B/\x8E\xD7\x63\xC0/' kexec_load.ko
sed -i 's/\xF5\x62\xAA\x4B/\x34\x80\x1B\x74/' kexec_load.ko
sed -i 's/\x00\x52\xD6\xD7/\x6F\x80\x91\x20/' kexec_load.ko
sed -i 's/\x4F\x77\x57\x6A/\x0C\x57\xC7\x63/' kexec_load.ko
sed -i 's/\xCA\x2F\x65\x71/\x92\xB8\x7F\x53/' kexec_load.ko
sed -i 's/\x0F\xD0\xA0\x91/\xFA\x80\x15\xB4/' kexec_load.ko
sed -i 's/\x29\xA0\x6D\x48/\x6C\x6B\x96\x54/' kexec_load.ko
sed -i 's/\x6D\x1F\x1F\x37/\xCC\x5E\x79\x8B/' kexec_load.ko
sed -i 's/\xFD\x23\xD0\xFB/\xE3\xE3\x68\x52/' kexec_load.ko
You can use hexedit or hexdump to see these adresses :
Code:
hexdump kexec_load.ko | grep ff72
0003d50 b0b0 80ac ff72 205e 6f6d 7564 656c 6c5f
how does it work ?
# kexec --help
For kexec help... nothing more to say.
# lsmod
List loaded modules... You must see
kexec_load 31369 0 - Live 0x00000000 (O)
# rmmod kexec_load.ko
Remove kexec_load module from memory.
# grep kexec /proc/device
To see installed driver.
You must see :
100 kexec_driver
First number is "major" number to identify your driver in system.
# mknod /dev/kexec_driver c 100 0
Install driver.
Major number (here 100), is important for module.
This Major must be the same between module and driver.
By default, 100 is used.
# insmod kexec_load.ko
To install "LKM", kexec_load kernel module.
If another Major is needed, you can use "insmod kexec_load.ko 101" for Major 101
You can use "modprob" if you want, but you must configure the module folder.
How kexec and module exchange informations ?
By the driver.
Normal output for a kernel module is to write in "dmsg" file.
To see kernel output, launch this command :
Code:
# dmesg
To see last kernel log, see in :
Code:
# cat /proc/last_kmsg
For kexec module, this normal way still exist, and give a lot of informations, but to speak with, you must use the driver.
/dev/kexec_driver
You can yourself test communication:
Code:
# cat /dev/kexec_driver
You can send kernel by this communication channel.
Type following commands for help
=> echo help >/dev/kexec_driver
=> dmesg | grep Kexec
Code:
# echo help >/dev/kexec_driver
# cat /dev/kexec_driver
Last command : 'help'
Please type following command :
=> dmesg|grep Kexec
Every command send into driver is receive by kexec_load.ko module and running into the kernel.
The answer can by read thru the driver
Here, you can see that normal way to see messages is allway dmesg.
Code:
# dmesg|grep Kexec
<4>[15050.521628] Kexec: Starting kexec_module...
<6>[15050.521656] Kexec: kexec_driver_contener allocation
<6>[15050.521673] Kexec: kexec_memory_buffer allocation
<4>[15050.521691] Kexec:----------------------------------------------------
<4>[15050.521710] Kexec: kexec_driver created with major : '100'
<4>[15050.521728] Kexec: Please, prepare by typing the following commands :
<4>[15050.521746] Kexec: => mknod /dev/kexec_driver c 100 0
<4>[15050.521761] Kexec: => cat /dev/kexec_driver
<4>[15050.521775] Kexec:-----------------------------------------------------
<4>[15050.521791] Kexec: For help
<4>[15050.521803] Kexec: => echo help >/dev/kexec_driver
(...)
I have add a lot of informations to help to configure kexec.
rdtags, atags ??
Not sure for this part of kernel.
"atags" is the most used method to bootloader to parse commands and informations to kernel at boot.
"atags" is a form of structure in memory to organise informations.
At boot, a address chain is created and can be compulse in /proc/atags file.
This file is read only system.
"rdtags" is another way to bootloader to parse information to kernel.
"rdtags" is not stocked in "/proc"
But, as i see, stock kernel can use "atags" from bootloader.
kexec can substitute bootloader function to create fromscratch a atags chain, and parse to new kernel.
I have change this part to stock atags in "/data/atags", and reuse or change if need.
If this don't work, i must create a rdtags chain to replace atags ; It's not a hard work.
Status
For the moment, kexec tools works.
=> Phase one OK.
I can start Phase Two : new kernel patch.
If you want to help me...
Actually, load a custom kernel and boot into with kexec tools work.
But at boot into, a kernel panic occurs.
It seems, a part of kexec patch is missing in custom kernel.

Hi new thread created for kernel kexec development.
Status: not working: wrong values for mem defines under the kernel is giving segmentation fault as its attempting to write to memory areas that are currently being used byyyyy the system
Instructions:
Make kernel compatible?:
1. Download kernel diff patch from below
2. Terminal - diff patch > diff.txt
How to use:
1. Download kexec-tools (kexec binary) from below
2. Copy into system/bin directory and give it executable permission
3. Download compatible kernel
4. Terminal - kexec --load-hardboot zImage --initrd=initrd.img --mem-min=0x20000000 --command-line="$(cat /proc/cmdline)"
kexec -e
Download links:
Kexec tool- https://db.tt/8DZXQ9eV
Ramdisk firmware 1.548 : https://db.tt/8DZXQ9eV
zImage (kernel):
Source code:
Kernel diff patch: https://db.tt/Xi2htT7Q (currently contains wrong values for mem defines)
Kexec-tools: https://db.tt/I22ofr3b
Special thanks: @delewer @krabappel2548

Reserved

Please move this thread to Xda Devdb, then I can also edit first post etc if I find new stuff
Sent from my C6903 using xda app-developers app

krabappel2548 said:
Please move this thread to Xda Devdb, then I can also edit first post etc if I find new stuff
Sent from my C6903 using xda app-developers app
Click to expand...
Click to collapse
Devdb?
Pm me i dont know what Devdb is lol

Recieved segmentation fault with delewers calculated mem values too
We need to write to memory where we have write access to, maybe lockedbootloader is not allowing us to write? Orrr we are just writing to wrong area of memory

If kexec works on the Z1, can it be ported over to Xperia Z/ZL/T/Ultra? I believe they don't all share the same processor.

Shaky156 said:
Devdb?
Pm me i dont know what Devdb is lol
Click to expand...
Click to collapse
Shaky156 said:
Recieved segmentation fault with delewers calculated mem values too
We need to write to memory where we have write access to, maybe lockedbootloader is not allowing us to write? Orrr we are just writing to wrong area of memory
Click to expand...
Click to collapse
I'll discuss with Kali- today if he's available.
Knucklessg1 said:
If kexec works on the Z1, can it be ported over to Xperia Z/ZL/T/Ultra? I believe they don't all share the same processor.
Click to expand...
Click to collapse
Doesn't need to be same processor, can be ported
Sent from my C6903 using xda app-developers app

Knucklessg1 said:
If kexec works on the Z1, can it be ported over to Xperia Z/ZL/T/Ultra? I believe they don't all share the same processor.
Click to expand...
Click to collapse
Yes it wont matter much, since its not s800 it should be easier for you guys , take the kexec-tool use that, implement the patch write to the correct mem addresses which is free, it should boot if you guys have issues let me know,
I need to calculate the correct addresses.
Ive noticed s800 uses a dt.img, might need to modify kexec-tool to support dt.img, not sure what dt.img does yet, only know it holds values

Shaky156 said:
I need to calculate the correct addresses.
Ive noticed s800 uses a dt.img, might need to modify kexec-tool to support dt.img, not sure what dt.img does yet, only know it holds values
Click to expand...
Click to collapse
the dt.img is needed by the kernel to boot, so I guess we need to load that too in kexec.
EDIT: people that wanna try add kexec patch to their kernel, check github: android_kernel_sony_msm8974/commits/kexec

krabappel2548, i have compil your kernel by my script (fromscratch)
My script (instruction in "DoomLord Build kernel thread" : scriptZ1 http://forum.xda-developers.com/attachment.php?attachmentid=2346163&d=1382568778
(for thoses who want to help us...)
You have a little mod to do here (bad compil) :
In "sound/soc/msm/qdsp6v2/rtac.c"
you must change
#include <q6voice.h>
by
#include "q6voice.h"
btw : no more ideas to load kexec for the moment ...

delewer said:
krabappel2548, i have compil your kernel by my script (fromscratch)
My script (instruction in "DoomLord Build kernel thread" : scriptZ1 http://forum.xda-developers.com/attachment.php?attachmentid=2346163&d=1382568778
(for thoses who want to help us...)
You have a little mod to do here (bad compil) :
In "sound/soc/msm/qdsp6v2/rtac.c"
you must change
#include <q6voice.h>
by
#include "q6voice.h"
btw : no more ideas to load kexec for the moment ...
Click to expand...
Click to collapse
Sorry, I'm trying to get caught up on the forum, but what seems to be the current standing issue to get kexec working?

Knucklessg1 said:
Sorry, I'm trying to get caught up on the forum, but what seems to be the current standing issue to get kexec working?
Click to expand...
Click to collapse
Read the OP
Status paragraph

Memory regions
00000000-07afffff : System RAM
00008000-00b79383 : Kernel code
00d04000-00f0cddb : Kernel data
0ff00000-779fffff : System RAM
7ff00000-7ff3ffff : rdtags_mem
7ff80000-7ffa0fff : last_kmsg
7ffa1000-7ffa5fff : last_amsslog
System RAM MEM = 00000000
So --min-mem=0x20000000
Now need to find a free memory area thatll allow us to write and hopefully the mmu/pmu on locked bootloader wont cancel it
@delewer? @DooMLoRD @kali @Bin4ry

I know I shouldn't disturb, but i must ask: if You achieve Your goal, would it be possible to port it to devices like Xperia P, S, T, U and other NXT? It would be great, many ppl are ready to give a prize for it. Thanks in advance, good luck and sorry again.
Sent from my LT22i using xda app-developers app

king960 said:
I know I shouldn't disturb, but i must ask: if You achieve Your goal, would it be possible to port it to devices like Xperia P, S, T, U and other NXT? It would be great, many ppl are ready to give a prize for it. Thanks in advance, good luck and sorry again.
Sent from my LT22i using xda app-developers app
Click to expand...
Click to collapse
These devices are not 2013 devices, they arent s800 socs, so they are much easier to do, simply take the kexec-tools from op, implement the patch in your kernel, write the correct memory values for your specific device and execute in terminal via the command in op, minmem depends on your device too, good luck

I think some1 tried it already, but it works only for unlocked devices... Anyway, thanks for help.
Sent from my LT22i using xda app-developers app

king960 said:
I know I shouldn't disturb, but i must ask: if You achieve Your goal, would it be possible to port it to devices like Xperia P, S, T, U and other NXT? It would be great, many ppl are ready to give a prize for it. Thanks in advance, good luck and sorry again.
Sent from my LT22i using xda app-developers app
Click to expand...
Click to collapse
Does doing this require having an Unlocked Boot loader prior to implementation?
Sent from my C6603 using xda app-developers app

A few informations about kexec-tools debug
in kexec.c
Fonction :
if (file_type.load(argc, argv, kernel_buf,
kernel_size, &info) < 0) {
fprintf(stderr, "Cannot load %s\n", kernel);
return -1;
}
With a forced execution of kexec (bypass error to see...)
--mem-min=0x90000000
kernel: 0xb6b9d008 kernel_size: 3e9340
debug: 1 - after get memory range
debug: 2 - after type test
debug: 3 - after type test
debug: 4 - after info.kexec
debug: Focus 1 - argc '5' ; argv 'be856774' ; kernel_buf 'b6b9d008' ; kernel_size '3e9340' ; info 'be856548' ; i '1' ; file_type.name 'zImage'
Could not find a free area of memory of 3f1340 bytes...
Cannot load zImage
debug: 10 - before trampoline
debug: 11 - after trampoline
debug: 12 - before segment load
debug: 13 - after segment load
debug: 8 - before sort_segment
debug: 9 - after sort_segment
debug: 6 - before purgatory
debug: 7 - after purgatory
kexec_load: entry = (nil) flags = 280004
nr_segments = 0
kexec_load failed: Function not implemented
entry = (nil) flags = 280004
nr_segments = 0
debug: 5 - return result : ffffffff
With a forced bypass on file_type.load , we have this :
--mem-min=0x20000000
debug: Focus 1 - argc '5' ; argv 'bef18774' ; kernel_buf 'b6bc7008' ; kernel_size '3e9340' ; info 'bef18548' ; i '1' ; file_type.name 'zImage'
Segmentation fault

delewer said:
A few informations about kexec-tools debug
in kexec.c
Fonction :
if (file_type.load(argc, argv, kernel_buf,
kernel_size, &info) < 0) {
fprintf(stderr, "Cannot load %s\n", kernel);
return -1;
}
With a forced execution of kexec (bypass error to see...)
--mem-min=0x90000000
kernel: 0xb6b9d008 kernel_size: 3e9340
debug: 1 - after get memory range
debug: 2 - after type test
debug: 3 - after type test
debug: 4 - after info.kexec
debug: Focus 1 - argc '5' ; argv 'be856774' ; kernel_buf 'b6b9d008' ; kernel_size '3e9340' ; info 'be856548' ; i '1' ; file_type.name 'zImage'
Could not find a free area of memory of 3f1340 bytes...
Cannot load zImage
debug: 10 - before trampoline
debug: 11 - after trampoline
debug: 12 - before segment load
debug: 13 - after segment load
debug: 8 - before sort_segment
debug: 9 - after sort_segment
debug: 6 - before purgatory
debug: 7 - after purgatory
kexec_load: entry = (nil) flags = 280004
nr_segments = 0
kexec_load failed: Function not implemented
entry = (nil) flags = 280004
nr_segments = 0
debug: 5 - return result : ffffffff
With a forced bypass on file_type.load , we have this :
--mem-min=0x20000000
debug: Focus 1 - argc '5' ; argv 'bef18774' ; kernel_buf 'b6bc7008' ; kernel_size '3e9340' ; info 'bef18548' ; i '1' ; file_type.name 'zImage'
Segmentation fault
Click to expand...
Click to collapse
Did you compile this kexec yourself? Or did you get this from krapabbel? I issued krapabbel to compile a new debug version have gave him the code but never heard back from him :/
Anywayz so cannot find free memory is the issue

Related

How to reconstruct a binary identical I9000XWJP6 kernel image, and more

The idea of this exercise is (at least) to get a stable starting point for kernel development. The thing which is currently missing is a proper working .config. I have reconstructed it using differential analysis and in the process hoped to find which components have actually been activated and to uncover changes (or Easter eggs) in the sources which have not been advertised. Having a working and identical I9000XWJP6 kernel also means that open development can continue from the current official public release. From there the things possible are only limited by your imagination.
The following is a walk-through on how to build the kernel, description of pitfalls that will cause changes in .config to break, and some annotations on discoveries made in the process.
The things you need are:
Mandatory:
- I9000XWJP6 zImage : from your favorite location
- Source tree : opensource•samsung•com the GT-I9000 OpenSource Froyo Update JPM.zip
- Sourcery G++: www•codesourcery•com/sgpp/lite/arm/portal/release1039
- Tweak-Kit : <attached>
Optional:
- Arm enabled GCC and binutils, including a development libbfd.
- Lots of your favorite beverage
The md5sum of the zImage should be: 26e9d5d206baf1515144c6b8de6f10d2
It is critical that the Sourcery G++ version is 2009q3-67.
The Tweak-Kit contains the following components:
Readme.txt - You're reading it
mkvmlinux.cc - convert zImage to vmlinux and extract the init ramdisk image
I9000XWJP6_defconfig - default .config
stamp.patch - set date/time and such to original
style.patch - fix style related warnings
prototype.patch - fix prototype related warnings
error.patch - Recoverable errors
houston.patch - Unrecoverable errors
shadow.patch - Fixate data structures
I9000XWJP6.h - Fixated macros
I9000XWJP6.c - Entry point stubs
SOME THINGS I ENCOUNTERED IN THE PROCESS:
a) What I absolutely did not expect was that I found two different encodings of the build timestamp. I could deduce that the timezone was central Europe. I had the assumption it would be Asia or America.
b) What was to be expected is that the source tree is incomplete. The directories drivers/fsr and fs/rfs are missing. You can still compile the kernel as the missing files are used to build modules. Problems start when you change the config. Doing so will change entry points and data structures and your kernel might die a horrible death when it loads modules who are unaware on these changes. There is a workaround which I will explain later.
c) The weirdest thing I encountered were the functions enable_hlt() and disable_hlt(). The are located deep in the unwind tables, a section not intended for code. I spent many hours trying to figure out how they got there or why but I still have no clue. I found exactly only one way to reproduce this behaviour and it is certainly not due to a typo, accident or ignorance.
d) The kernel is not a production but a debug version. It has nearly all tracking/tracing/debug bells and whistles switched on. If the energy required to maintain the statistics where to emit light, you could use your Galaxy as a Christmas tree. Function profiling is enabled and has a considerable negative effect on performance, code is not optimized for size but speed, and unwind tables have been enabled which are not used. These have a really bad impact on footprint size. I really hope that the same compiler and settings are not used for the Android layer. Changing the config into a production version will not work (and crash) as the non-native modules expect the debugging hooks which will no longer exist. But the same workaround as above can be used.
e) The functionality of the power management domains have been optimized to oblivion due to the excessive placing of code disabling comments in large parts of the clock, power management and mach-aries.c. Maybe because the Galaxy hardware is too different than the evaluation boards, or the hardware is buggy and disabling the code makes it less unstable, or there was just not enough time to get the code working. Anyway, at this moment I have no oversight into what degree the absence of power domains influence battery usage.
f) When I started examining the binary code I was puzzled by snippets of code I could not reproduce. Even worse, I encountered snippets that were just questionable. Unusual instruction sequences, and resister usage. Thinking I bumped into a GCC bug, I started debugging the compiler and even tweaked instruction scheduling weights but with no satisfying outcome. I know that GCC is very stubborn with regard to saving and clobbering registers in/across function calls and the code I saw was just incorrect. I knew a different compiler was used and I suddenly realized that it may be more different than what first meets the eye. The culprit turned out to be Sourcery G++. It is a private maintained branch of GCC for reasons I have not investigated. Even the Sourcery assembler is tainted as it played a nasty trick on me with the enable_hlt/disable_hlt thing. I do not like the code I see and I am aiming into getting the sources stock GCC friendly with a working kernel. However, GCC and Sourcery generate code which seem difficult to mix, but I'm getting closer.
g) Compiler warnings. Many of the Samsung sources generate warnings, something I really dislike. In my opinion a warning is emitted for a piece of code which can be interpreted in several ways, leaving the compiler to choose which. Usually it will choose the wrong one. Most warnings were related to coding style shortcuts, a couple of incorrect function prototype resulting in functions that should return int to return random or falsely ignoring return values. There were also a couple of nasties like deference of uninitialized pointers, accessing out-of-bound data and mixing clock data-structures of different types. Included are a number of patches to fix them.
h) I looked deeper into why GCC and Sourcery won't mix and discovered that they have different implementations with regard to constant definition within enum declarations. Google points to the staring point "GCC bug 30260" where is written that the behaviour of enumeration constants has changed to becoming signed int. I have noticed that even explicit unsigned values will change to signed.
Here is an example of what is going wrong:
Take following declaration
Code:
enum rt_class_t { RT_TABLE_MAX=0xFFFFFFFF }
. GCC will consider RT_TABLE_MAX to be -1, and Sourcery will consider it 4294967295. Now, in net/ipv4/fib_rules.c there is this code snippet
Code:
for (u32 id = 1; id <= RT_TABLE_MAX; id++)
GCC will skip the loop, and Sourcery will have a hard time doing nothing.
There are more examples like calculating the location of physical memory or signed/unsigned comparisons. The compiler switches -fwrapv and -fstrict-overflow might influence things, but it general the behaviour is hardcoded and both compilers have a different flavour. I think it would be wiser to choose the GCC flavour as it is more widespread and thus better tested (and fixed).
i) GCC. I noticed that early versions of kernels compiled with GCC would not start. At first I thought it was because of Sourcery /GCC code generating differences. After a number of buxfixes (in error.patch) I suddenly noticed that the GCC kernel is working. My phone is running a GCC compiled production configured kernel for nearly a week.
j) "Houston, we've had a problem" with the light sensor. One of the compiler warnings brought me to the file drivers/sensor/optical/gp2a.c. There within are located two routines which read the light and proximity sensor. They seem copy-pasted identical, however the sensor value types are different as the proximity value is a char and the light intensity a double. What is more convenient than to simply change the data type of the supplied buffer in the function prototype. Now headache starts as the semantics of the read (and write) call say that the unit size is byte. So returning "1" indicates that only the first byte of the sensor value is copied. Also, there is no bounds/access checking so supplying an invalid pointer to the call will crash the kernel. So, assuming this is all one big mistake, I redesigned the function to do better (see houston.patch) and built a new kernel with it. To my utter surprise my battery charge extended from <24 hours to 2 days and 20 hours.
However... I also noticed that my backlight intensity level was constant at it's lowest although the setting was set to auto. I needed to know how the caller invokes the call, but after an extensive search of internet and android sources it is still something I have not found. Heuristics show that the reading the light sensor is called with a buffer length of 1, and the returned value is only accepted when returning a 1 and that the sensor value type is a double (8 bytes). This is wrong: read() semantics require that you supply a length of 8, and expect a return value of 8. This may be the base of many light sensor issues I found when Googling.
Anyway, I returned the code to it's original faulty behaviour, and being illuminated I disabled the auto backlight intensity and changed it to it's lowest setting to enjoy a longer life between battery charges.
TO CREATE YOUR KERNEL:
1) Prepare a working environment
1a) Unpack Sourcery G++. No installation needed, unpacking is sufficient
1b) Unpack the Samsung sources and cd to the location of the top-level Makefile.
1c) Unpack the zImage and the contents of the Tweak-Kit to the same location
1d) Make sure the zImage is called zImage.I9000XWJP6
2) The ramdisk image is required and can be extracted from zImage.I9000XWJP6
2a) Create an uncompressed image Image.I9000XWJP6
Code:
gcc scripts/binoffset.c -o scripts/binoffset
ofs=`scripts/binoffset zImage.I9000XWJP6 0x1f 0x8b 0x08 0x00 2>/dev/null`
dd ibs=$ofs skip=1 <zImage.I9000XWJP6 | gzip -c -d >Image.I9000XWJP6
2b) The Tweak-Kit includes mkvmlinux which converts the uncompressed binary image into a bfd object. You need an Arm enabled libbfd to get it working. This does not get installed by default so you need to deeplink into binutils. mkvmlinux locates and decodes the kallsym data and econstructs the symbol table. It then uses the values of __initramfs_start/end to extract the initramfs. If you are not bothered with the hassle, just use dd with hardcoded values.
Code:
g++ mkvmlinux.cc -o mkvmlinux -lbfd -liberty -lz [-I and -L that deeplink into binutils]
./mkvmlinux Image.I9000XWJP6 vmlinux.I9000XWJP6 -r initramfs.cpio
or
Code:
dd if=Image.I9000XWJP6 of=initramfs.cpio bs=1 count=2739712 skip=165568
3) Patch date/time and other environmental issues to the moment of original creation
Code:
patch -p1 <stamp.patch
4) Make your computer happy
Code:
# edit Makefile line 184 and update the macro CROSS_COMPILE=
cp I9000XWJP6_defconfig arch/arm/configs/I9000XWJP6_defconfig
make I9000XWJP6_defconfig
make
5) Verify that the kernel is identical
Code:
diff zImage.I9000XWJP6 arch/arm/boot/zImage
AND NOW FOR SOMETHING COMPLETELY DIFFERENT...
Tweaking the configuration will build you a new kernel but when your Galaxy powers on it will either die silently (hang) or experience a horrible death (reboot). The problem is that there are modules built from sources located in the removed directories drivers/fsr and fs/rfs. These modules were compiled with a specific data structure layout and entry points. These will surely change when re-configuring. The way to keep the non-native modules happy is to keep the structures and entry points intact.
The structure layout is influenced by the CONFIG_ macros. The structures can be fixed to reflect the state of the I9000XWJP6 kernel by replacing the CONFIG_ macro's by something that does not change after reconfiguration. For that I use a collection of 'shadow' macro's which have SHADOW_ as prefix. Because the data structures cannot expand, you cannot (easily) enable configure functionality which require extra fields in the data structures. Reducing functionality is highly seldom a problem.
If changing kernel functionality results in removal of entry points, then stubs are required for those entry points needed by the non-native modules
There are automated methods to verify that a new kernel abides to the above constraints. For the data structures the compiler must generate gstabs debug information. This is human readable and includes detailed structure descriptions. This information should be identical across re-configuration. However, the scripts get confused by anonymous structs which are by product of "typedef struct {" constructions. These need to be named, something shadow.patch also does.
The kernel modules have easily-readable symbol tables containing needed kernel entry points. These should all be present in all re-configured kernels. Validation tests that fail emit enough information to further fix data structures and entry points. The Tweak-Kit contains two files: I9000XWJP6.h containing the SHADOW_ macro's and I9000XWJP6.c for the stubs. Both were constructed in an on-demand basis for the reconfiguration I am currently using and both serve as good examples on what to do when validation fails.
Before reconfiguring, rebuild the kernel for usage as a validation checkpoint.
1) Undo the timestamp patches
Code:
patch -R -p1 <stamp.patch
2) Fix the warnings
Code:
patch -p1 <style.patch # style related issues
patch -p1 <prototype.patch # prototype related issues
patch -p1 <error.patch # bug fixing
3) Apply datastructure fixation, entrypoint stubbing and Makefile tweaking
Code:
patch -p1 <shadow.patch
cp I9000XWJP6.c arch/arm/plat-samsung
4) Before recompiling everything, you need to issue "make clean" first. However, the missing directories will now pose a problem as "make clean" will include their Makefiles and will fail if it can't. Just create empties to keep the build happy.
Code:
mkdir -p drivers/fsr fs/rfs
touch drivers/fsr/Makefile fs/rfs/Makefile
5) Optionally change the Makefile to point to your favorite compiler/toolchain. Please note that I am using GCC 4.4.5. GCC 4.5.1 is bumping into problems I haven't looked into yet.
Code:
# edit Makefile line 184 and update the macro CROSS_COMPILE
6) This build will generate gstab debug information. Unexpectingly, this might bite when combined with function profiling, so disable that. But do not CONFIG_FUNCTION_TRACER yet as that does more.
Code:
# edit Makefile line 553, disable the line containing KBUILD_CFLAGS += -pg
7) Unpack the initramfs image. The directory /lib/modules needs to be examined/updated
Code:
mkdir initramfs.dir
cd initramfs.dir
cpio -i --make-directories --preserve-modification-time --no-absolute-filenames <../initramfs.cpio
cd ..
8) Repack initfs as a tarball, as make clean will erase all the modules
Code:
tar cf initramfs.tar initramfs.dir
9) The initramfs image will contain new kernel modules. Make sure a new version will get generated.
Code:
# in .config line 80 point to the unpacked initram location
CONFIG_INITRAMFS_SOURCE="initramfs.dir"
# in .config lines 86-89, select your favourite compression
CONFIG_INITRAMFS_COMPRESSION_NONE=N
CONFIG_INITRAMFS_COMPRESSION_GZIP=Y
10) Build a new kernel
Code:
# not cleaning will confuse the verification
make clean
make CONFIG_DEBUG_INFO=y
# install the modules
tar xf initramfs.tar
cp `find drivers -name '*.ko'` initramfs.dir/lib/modules
# rebuild with a fresh new ramdisk image
rm usr/initramfs_data.cpio*
make CONFIG_DEBUG_INFO=y
11) Checkpoint structure/entrypoint information. This is architecture independent.
Code:
# extract structures. They are the entries with :T
objdump -G vmlinux | awk '{ print $7 }' | grep :T | sed 's/([^)]*)/()/g' | sed 's/=\*()//g' | sort -u > gstabs.ckp
# extract the entrypoints
nm vmlinux | grep 'r __ksymtab_' | awk '{ print $3 }' | sort > ksymtab.ckp
12) Do a test-run. Pack zImage and flash with Odin. If your Galaxy is up and running, I strongly suggest you make a backup of your environment. If you later change something and it breaks, then this is the best place to restart.
Code:
cp arch/arm/boot/zImage .
tar cf I9000XWJP6-2.6.32.9-test.tar zImage
13) Make your re-configuration. I really suggest you do not make too many changes in one go because it gives more work when the structure/entrypoint verification fails.
Code:
# re-configure. For this exercise, change the kernel to a more production version
CONFIG_CC_OPTIMIZE_FOR_SIZE=Y
CONFIG_DM_DEBUG=N
CONFIG_S3C_KEYPAD_DEBUG=N
CONFIG_DEBUG_FS=N
CONFIG_DEBUG_KERNEL=N
CONFIG_LATENCYTOP=N
CONFIG_FTRACE=N
CONFIG_ARM_UNWIND=N
CONFIG_DEBUG_USER=N
14) Build a new kernel
Code:
# not cleaning will confuse the verification
make clean
make CONFIG_DEBUG_INFO=y
# install the modules
tar xf initramfs.tar
cp `find drivers -name '*.ko'` initramfs.dir/lib/modules
# rebuild with a fresh new ramdisk image
rm usr/initramfs_data.cpio*
make CONFIG_DEBUG_INFO=y
You get "struct has no member named" errors if you have enabled subsystems that require data structures to change which are incompatible with the non-native modules.
15) Verify structure/entrypoint checkpoint
Code:
# extract/verify structures
objdump -G vmlinux | awk '{ print $7 }' | grep :T | sed 's/([^)]*)/()/g' | sed 's/=\*()//g' | sort -u > gstabs.t
# new/changed structures are tagged with '+'. Display only the changed ones
diff -U0 gstabs.ckp gstabs.t | grep '+' | grep ':T' | sed 's/+//' | sed 's/:T.*/:T/' | while read s; do
grep -q "$s" gstabs.ckp
if [ $? -eq 0 ]; then
echo $s;
fi
done
# extract/verify entrypoints
nm vmlinux | grep 'r __ksymtab_' | awk '{ print $3 }' | sort >ksymtab.t
# extract all entrypoints needed by the modules
nm `find initramfs.dir/ -name '*.ko'` >allkosym
# some symbols are referenced in other modules. Cross-reference and remove from list
grep ' U ' allkosym | sort -u | awk '{ print $2 }' | while read s; do
if ! egrep -q "^[0-9a-f]* . $s\$" allkosym; then
echo $s;
fi
done > allusym
# check that kernel has entrypoints for all final undefined symbols
cat allusym | while read s; do
if ! egrep -q "^__ksymtab_$s\$" ksymtab.t; then
echo $s;
fi
done
Both scripts will generate output if you have enabled subsystems that require datastructures to change. These do not necessarily have to be data structures needed by non-native modules. However, missing entrypoints are those used by the modules. If it's about datastructures, your best chance is to lookup the data type and see if there any #ifdef CONFIG_ macros that need to be changed into #ifdef SHADOW_. If it's a missing entry point, you need to add a stub in I9000XWJP6.c.
16) Do a test-run. Pack zImage and flash with Odin.
Code:
cp arch/arm/boot/zImage .
tar cf I9000XWJP6-2.6.32.9-test.tar zImage
17) If you want more, jump to step 13
18) When you are really done, rebuild a final and fresh kernel and initramfs image with debugging stuff removed. The -gstabs compiler switch slightly influences code generation.
Code:
# not cleaning will confuse the verification
make clean
make
# install the modules
tar xf initramfs.tar
cp `find drivers -name '*.ko'` initramfs.dir/lib/modules
# rebuild with a fresh new ramdisk image
rm usr/initramfs_data.cpio*
make
My uncompressed image has now shrunk from 14700623 to 11822559 bytes.
Happy Hacking...
[...and now to find a better workaround for those non-native modules.]
WoW, Nice work !! very good info for beginners like me
thx a lot for this tut and i've learnt a lot
btw, seems there r some typos or something is missing. i did it with (XXJPO):
Hexabit said:
make I9000XWJP6_defconfig
Click to expand...
Click to collapse
make defconfig I9000XWJP6_defconfig
- modified include/linux/a.out.h by removing the 2nd def for SEGMENT
- changed the boolean to lowercase for .config
PS i use the cpio extracted by myself coz i couldnt enable libbfd on my ubuntu x64
Good tips. Thanks.
Really insightful i hope the dev take all the tweaks into consideration and make a new optimized kernel
good job here!
I think it's the most amazing first post ever! It should be sticked or kept somewhere safe.
Awesome first post. Will have to work through this.
Great post with very interesting findings!
I'm no expert, so maybe my question is a bit silly:
Is Samsung's published code just a buggy and incomplete pre-release debug version? Then how can e.g. Voodoo get a good working kernel?
Or is the official firmware really built of this, so possibly full of strange bugs and missing optimizations?

[MOD] SHW-M110S Development (with lagfix/root/voodoo sound kernel)

For SHW-M110s development/discussion. (Korean Anycall SGS ONLY yes for any who don't know, we are officially part of the I9000 forum.
Koe1974 suggested this thread and will I think act as a co-OP on this discussion. Look for front page updates, links, whatever from him 3 posts down, (below the lost guy from China) in the future too.
Version 4 released
Version 4.0r1 released to fix Odin flashing problem
link to kernel
with tegrak_voodoo sound (v2) module, tegrak ext4 module, root (superuser.apk) and busybox 1.17.1 optional, safe mount option overides by default, auto detect lag fixed partitions (improves upgradeability and interchageability) [/B][/size] Compatible with previously z4modded ext2 setups. All ROM versions, SK05 through TA13 tested and released (link is below).
안녕하세요 to any of the Korean developers who find this. Please update us in English about what you are doing. Your English is probably MUCH better than my korean, and I live in Korea.. There are some people in China, Iran, Philippines, etc using this device who might be helped.
-------------------------------------------------------------------------------------------------------------------------
Ext4 (tegrak modules) z4build rooted voodoo sounds kernel link
A stock z4moded kernel with added ext4 support ( presently by "stealing" tegrak kernel modules.) and many tweaks to make it actually work.
This is now working with z4control to get an easy to apply ext4 lag fix!
------------------------------------------------------------------------------------------------------------------------------------
Bug discussion here please, usage discussion (how do get the file into odin?) .. maybe the general thread is better.
For now, our rooting guide is linked from my sig also, although the above linked kernel can also be made to provide root with no effort.
This type of initramfs modification can be done by unpacking a stock kernel making customizations and then applying z4build to it. But I used a z4modded kernel and then applied customizations and repacked. I did this because I set up to repack by hand anyway before knowing I wanted to use z4mod and even then, when I thought I needed to pack into a tegrak kernel (which z4build can't do). It turned out to cause complications, but also taught me a good bit about the process and about z4mod, and probably helped me find bugs.
Some other related useful links for Reference:
kernel extraction (commented by me specifically for tegrak lzma compressed initramfs and z4build split initramfs)
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
kernel repacking
http://forum.xda-developers.com/showthread.php?t=789712
It needs the initramfs to be cpio'd already something like this:
Code:
cd $initram
find ./ | cpio -H newc -o > $repackdir/newramfs.cpio
It also needs the editor.sh script modified to point to the cross-compiler.
By default it can only pack you initramfs into an image which previously had an uncompressed initramfs. This can be modified though easily.
kernel compiling
This old thread probably isn't too useful now..
http://forum.xda-developers.com/showthread.php?t=740740&page=2
We have much better info 3 posts down by koe1974.
Kernel sources here:
http://opensource.samsung.com/
search SHW-M110S.
The first froyo update has a nice readme with a link to the compiler (I don't have the link right this moment)
Not sure if we need to figure/find .configs, or if the ones included are ok to start. Just need to compile one once and see.
I got my compiler toolchain here:
http://www.codesourcery.com/sgpp/li...1-188-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
I thought it's the one recommended is the original froyo source from samsung, but Koe says they point to 2009 version, so I don't know now.
............
I flashed the korean voodoo sk22 kernel just to boot it into recovery. It has CW mod recovery. Might be useful. (BTW I don't recommend flashing unfamiliar kernels haphazardly, ex: this one injected a file into my ROM that interefered with z4mod until I realized it ) Mine BTW injects only one empty directory (/etc/init.d) and nothing else. Remove the kernel and all other changes dissappear. (z4control adds a tad more, but very little, most of its additions self destruct after use.)
Post reserved.
Post Removed, as requested.
Sent from my GT-I9000 using XDA App
Links:
Korea's equivalent to XDA
Lilinser's GitHub - kernel repack, deodexer, etc.
Project-Voodoo - initramfs (SK05)
Just for hobbies - Voodoo for SL28
Tegrak Kernel
SHW-M110S intramfs Requires further research.
Older M110S from someone at MIT working on the M110S potential resource
bml7 & initramfs possible resource
more initramfs
initramfs SK05 Tested .. OK
How-Tos:
Basic How-To Build Environment with built kernel test
First this diff is from a z4modded stock SL28 image to the custom kernel image. It's not against stock. So it includes tegrak files and scripts I changed. Also note the -N option. It pretends like files that don't exist do.. Any binary files that "differ" are actually added from tegrak.
Code:
diff -rbpN z4mod_sl28/initramfs/init.rc z4grak-construction-sl28/initramfs/init.rc
*** z4mod_sl28/initramfs/init.rc 2011-01-13 02:20:12.000000000 -0500
--- z4grak-construction-sl28/initramfs/init.rc 2011-01-11 07:43:34.000000000 -0500
*************** loglevel 3
*** 58,63 ****
--- 58,72 ----
mount j4fs /dev/block/stl6 /mnt/.lfs
insmod /lib/modules/param.ko
+ #ext4 modules by woo
+ insmod /tegrak/lib/modules/mbcache.ko
+ insmod /tegrak/lib/modules/jbd2.ko
+ insmod /tegrak/lib/modules/ext4.ko
+
+ # tegrak system lagfix by woo
+ #
+ insmod /tegrak/lib/modules/tegrak_module.ko
+
# Backwards Compat - XXX: Going away in G*
symlink /mnt/sdcard /sdcard
*************** service vt /system/bin/vtserver
*** 728,734 ****
#user system
#group system
-
service dumpstate /system/bin/dumpstate -s
socket dumpstate stream 0660 shell log
disabled
--- 737,742 ----
*************** service dumpstate /system/bin/dumpstate
*** 739,747 ****
# oneshot
-
# Added by z4mod
service z4postinit /init
oneshot
--- 747,761 ----
# oneshot
# Added by z4mod
service z4postinit /init
oneshot
+ #install root ingore the mount type, it doesn't matter
+ # syntax looks a little strange to me.. we'll see if it works
+ mount rfs /dev/block/stl9 /system rw remount
+ cat /sbin/su > /system/bin/su
+ chown root /system/bin/su
+ chmod 4755 /system/bin/su
+ mount rfs /dev/block/stl9 /system ro remount
\ No newline at end of file
diff -rbpN z4mod_sl28/initramfs/lpm.rc z4grak-construction-sl28/initramfs/lpm.rc
*** z4mod_sl28/initramfs/lpm.rc 2011-01-13 02:20:12.000000000 -0500
--- z4grak-construction-sl28/initramfs/lpm.rc 2011-01-11 06:37:28.000000000 -0500
*************** on init
*** 16,21 ****
--- 16,26 ----
insmod /lib/modules/param.ko
insmod /lib/modules/vibrator.ko
+ #ext4 modules by woo
+ insmod /tegrak/lib/modules/mbcache.ko
+ insmod /tegrak/lib/modules/jbd2.ko
+ insmod /tegrak/lib/modules/ext4.ko
+
mount rfs /dev/block/stl9 /system check=no
mount rfs /dev/block/mmcblk0p2 /data nosuid nodev check=no
Binary files z4mod_sl28/initramfs/sbin/sslvpn and z4grak-construction-sl28/initramfs/sbin/sslvpn differ
Binary files z4mod_sl28/initramfs/tegrak/bin/mkfs.ext4 and z4grak-construction-sl28/initramfs/tegrak/bin/mkfs.ext4 differ
Binary files z4mod_sl28/initramfs/tegrak/bin/tune2fs and z4grak-construction-sl28/initramfs/tegrak/bin/tune2fs differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/ext4.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/ext4.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/jbd2.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/jbd2.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/mbcache.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/mbcache.ko differ
Binary files z4mod_sl28/initramfs/tegrak/lib/modules/tegrak_module.ko and z4grak-construction-sl28/initramfs/tegrak/lib/modules/tegrak_module.ko differ
I'm a bit confused about sslvpn It's in my SL28 , it's not in my z4moded SL28. everything else diff as expected. Maybe I just lost it, maybe z4mod removed it. It's a small unimportant mystery.
BTW it looks like what I believe are the recovery keys have changed from SK22 to SL28, so maybe using the wrong kernel breaks something.
and my slightly modified version of the extraction script with commented lines to deal with lzma.
it's much faster (well.. why not), and it handles direcories a little better. It need a "/" somewhere in the file name though so use "./zImage".
Code:
#!/bin/bash
#MUCH faster than dd bs=1 skip=blah
#
# syntas is fastdd file skip <length_in_bytes_optional>
# skip is NOT optional and should be set to 0 read from begining.
#
fastdd () {
#dd with a skip is crazy slower cause it forces bs=1
#credit goes to somebody on the internet.
local bs=1024
local file=$1
local skip=$2
local count=$3
(
dd bs=1 skip=$skip count=0 2>/dev/null
if [[ "$count" != "" ]]; then
dd bs=$bs count=$(($count / $bs))
dd bs=$(($count % $bs)) count=1
else
dd bs=1024 2> /dev/null
fi
) < "$file"
}
zImage=$1
basedir=${1%/*}
echo working directory $basedir
mkdir $basedir/initramfs
outdir=$basedir/initramfs/
#========================================================
# find start of gziped kernel object in the zImage file:
#========================================================
pos=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' $zImage | cut -f 1 -d :`
echo "-I- Extracting kernel image from $zImage (start = $pos)"
echo
echo "*** Start of compressed kernel image:" $pos
#========================================================================
# the cpio archive might be gzipped too, so two gunzips could be needed:
#========================================================================
fastdd $zImage $pos | gunzip > /tmp/kernel.img
pos=`grep -P -a -b -m 1 --only-matching $'\x1F\x8B\x08' /tmp/kernel.img | cut -f 1 -d :`
#
# Use next one for tegrak secuere 11 SL28
# It's an lzma header
# It's found by looking for 5D 00 in the exact same place as cpio (070701) is found in stock.
# The long string of FF's is the real give away since 5D 00 is too vague.
# pos=`grep -P -a -b -m 1 --only-matching '\x{5D}\x{00}\x..\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}\x{FF}' /tmp/kernel.img| cut -f 1 -d :`
echo
echo "*** gzip position in kernel.img :" $pos "(start of gzipped cpio)"
#===========================================================================
# find start and end of the "cpio" initramfs image inside the kernel object:
# ASCII cpio header starts with '070701'
# The end of the cpio archive is marked with an empty file named TRAILER!!!
#===========================================================================
if [ ! $pos = "" ]; then
echo "-I- Extracting compressed cpio image from kernel image (start = $pos)"
# use either one of the next two lines for gzip
# dd if=/tmp/kernel.img bs=1 skip=$pos | gunzip > /tmp/cpio.img
fastdd /tmp/kernel.img $pos |gunzip > /tmp/cpio.img
# comment above and uncomment one of next two lines for lzma, if decompressing tegrak image.
# dd if=/tmp/kernel.img bs=1 skip=$pos | unlzma > /tmp/cpio.img
# fastdd /tmp/kernel.img $pos | unlzma > /tmp/cpio.img
start=`grep -a -b -m 1 --only-matching '070701' /tmp/cpio.img | head -1 | cut -f 1 -d :`
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' /tmp/cpio.img | head -1 | cut -f 1 -d :`
inputfile=/tmp/cpio.img
else
echo "-I- Already uncompressed cpio.img, not decompressing"
start=`grep -a -b -m 1 --only-matching '070701' /tmp/kernel.img | head -1 | cut -f 1 -d :`
echo start $start
end=`grep -a -b -m 1 --only-matching 'TRAILER!!!' /tmp/kernel.img | head -1 | cut -f 1 -d :`
echo end $end
inputfile=/tmp/kernel.img
fi
end=$((end + 10))
count=$((end - start))
if (($count < 0)); then
echo "-E- Couldn't match start/end of the initramfs image."
exit
fi
echo "-I- Extracting initramfs image from $inputfile (start = $start, end = $end)"
echo inputfile: $inputfile
echo start $start
echo count $count
echo outdir $outdir
# dd if=$inputfile bs=1 skip=$start count=$count > $outdir/initramfs.cpio
fastdd $inputfile $start $count > $basedir/initramfs.cpio
cd $basedir
basedir=`pwd`
cd $outdir; cpio -v -i --no-absolute-filenames < $basedir/initramfs.cpio
cp /tmp/kernel.img $basedir/
More to come.
I like the way this is going, appagom, please put [MOD] in the title.
GL on the new thread, if you hope to have Koreans stumbled upon the thread it might be good to add more phrases like:
루팅
갤럭시s
안드로이드
프로요
업그레이드
업데이트
I never really fully utilized it myself. I hope you get more done here or I'll just take the move personally. Actually, now that you guys were moving into compiling and building I thought this would come. Also, you should look to get some Soju out of this with some donate links or something, even if you aren't looking to take in any cash perhaps you could use it as a seed pot for bounties.
Most importantly, I need to know what "the lost guy from China" said...ㅋㅋㅋ
@Koe, don't waste your time on Gingerbread, get us Honeycomb
Compile a Kernel in 13 Lucky Steps
If you are not familiar with Linux, you might have a hard time following this. Just as I am writing how to do get setup to compile a kernel and compile Android apps, others have written how to setup VirtualBox, Ubuntu, AndroidSDK, etc. Please see documentation provided by Oracle, Google, Ubuntu, etc. before you ask for help about VirtualBox, Ubuntu and the SDK. Thanks.
This is written for people who have used Linux but have not compiled much. Or for the brave at heart who are looking for a nice weekend project. This will tell/guide you through getting a system setup that will not destroy your existing OS.
My host OS is Ubuntu 10.10 64-bit. I wanted had to make an Ubuntu 10.04 32-bit 64-bit system for development because I didn't want to deal with 64-bit vs. 32-bit issues but since Gingerbread requires a 64-bit compiler, I had to. Might as well just use my host system, but since we're here let's keep going!
So you're about to begin. Let's just get one thing straight. No! This will not result in a kernel you can flash. “Then why do this?, you ask. Ask yourself that!
1. Install VirtualBox and the Oracle VM VirtualBox Extension Pack (Currently 4.0.0 r69151)
http://www.virtualbox.org/wiki/Downloads
2. Download an Ubuntu ISO (I suggest Ubuntu Desktop 10.04 64-bit)
http://www.ubuntu.com/desktop/get-ubuntu/download
3. Create a new VM in VirtualBox (You may/have to modify the settings)
Operating System: Linux
Version: Ubuntu64
Extended Features: IO APIC
Processors: 2
RAM: 2048MB
Video Mem: 128MB
HDD: 32GB
Enable PAE/NX
Shared Drive: (I use a shared folder, more detail later)
Click to expand...
Click to collapse
4. Install VirtualBox Guest Additions
5. Install Ubuntu and Update Ubuntu
TIP: Mount your Shared Folder with fstab (Optional but helpful)
If you chose to use a shared folder you can auto-mount it via /etc/fstab.
NOTE: I use a shared folder named andDEV and I mount it on my desktop (~/Desktop). Below is what I add to my /etc/fstab (You may/have to change it)
Code:
andDev /home/koe/Desktop/andDev vboxsf uid=1000,gid=1000 0 0
Click to expand...
Click to collapse
6. Enable multiverse and partner "Software Sources"
7. Install additional software: NOTE: I would also recommend installing preload, but it is not required.
Code:
sudo apt-get install qt3-dev-tools texinfo git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.6-dev build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk eclipse ia32-libs
8. Get and Setup the AndroidSDK (Everything you need to know is there or just Google for help)
http://developer.android.com/sdk/index.html
NOTE: Ubuntu 10.04 does not have Java 5 in it's repositories. Follow this link to setup to Java 5
9. Get and Setup ADT Plugin for Eclipse (Everything you need to know is there or just Google for help)
http://developer.android.com/sdk/eclipse-adt.html#installing
TIP: At this point you might want to try Google's “Hello, Android” tutorial.
Click to expand...
Click to collapse
10. Download and Install the Sourcery G++ Lite for ARM EABI Toolchain (Currently arm-2010.09)
http://www.codesourcery.com/sgpp/lite/arm/portal/subscription3053
Look for and click the link for Recommended Release
Look for and click the link for IA32 GNU/Linux TAR
Extract the archive. You will have a folder named arm-2010.09
Make a directory in your home directory named CodeSourcery
Ex. mkdir ~/CodeSourcery
copy the entire arm-2010.09 folder into CodeSourcery
Click to expand...
Click to collapse
11. Update your $PATH
You should be familiar with this because you had to do it to setup the AndroidSDK
Append the following to your PATH in .bashrc
Code:
~/CodeSourcery/arm-2010.09/bin
12 Download and Prepare the Samsung Source Code (Currently SHW-M110S_Opensource_Froyo_update2.zip)
http://opensource.samsung.com/
Click Mobile - Mobile Phones
Look for and download SHW-M110S_Opensource_Froyo_update2.zip
Extract the archive. Inside the new folder are two more archives.
Extract SHW-M110S_Kernel.tar.gz Inside there is a new folder Kernel
You can copy this to a more convenient location. I copy it to my desktop.
In the Kernel folder is a file named Makefile. Open it with your editor of choice.
Go to line 184. You will see ...
CROSS_COMPILE ?= /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-
You have to change it to something like below, but see the koe? That is my username so you have to change it to your username.
CROSS_COMPILE ?= /home/koe/CodeSourcery/arm-2010.09/bin/arm-none-eabi-
Save Makefile.
Click to expand...
Click to collapse
13. Compile a Kernel
NOTES:
1. Do not try to compile the code in your Shared Folder. It will fail.
2. When issuing these commands you will see lots of output during this part, most of which is not useful to you at this point.
3. The amount of time it takes for the final make command to run will depend on your computer.
Click to expand...
Click to collapse
Open a terminal window and move into the Kernel directory. Issue the following commands.
Code:
$ make shw-m110s_defconfig
$ make menuconfig
When the config editor opens do the following:
DOWN ARROW to Userspace binary formats and press ENTER
DOWN ARROW to Kernel support for a.out and ECOFF binaries and press SPACE
RIGHT ARROW to Exit and press ENTER
RIGHT ARROW to Exit and press ENTER
Press ENTER again and it will exit back to the command line
NOTE: If you have a powerful computer and you want to speed up the build time, make can be run as, make -j# The # represents how much it will try to do at once. $ make does 1 operation, make -j3 tries to do 3. I have a 2.66 Ghz dual-core CPU and I allow the VirtualBox guest OS access to both cores, so I use make -j3 The compile finishes in about 12 minutes and allows me to still use my host OS. For now, you might just want to run make without the -j option to get a full understanding of how long it takes. Later you can test with values.
Click to expand...
Click to collapse
WARNING: Time is relative. This will take some time ... go make a sandwich or maybe even watch a movie.
Code:
$ make
When you see $ again check the last couple of lines of output. You want to see …
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Click to expand...
Click to collapse
Congratulation! You just built a kernel for the m110s!
good write up.. Glad to see you hit the same a.out snag as me. Just makes me think it's not configured right and so I have low hopes. Will be fun to see what happens when you put an initramfs in it. I'd just unpack the stock one and try that first.
As for z4control.. I'm pretty interested in getting this working as something like this was the real reason I started messing with this. It seems there may be some issue with the z4mod's init wrapper not doing things it should but anyway.. just now seeing issues. flashed one kernel where I added some debug output added.. trying to understand it (not understanding it yet). I'm optimistic that I can track it down. edit:... definitely making progress, not quite there yet but getting closer.
appagom said:
good write up.. Glad to see you hit the same a.out snag as me. Just makes me think it's not configured right and so I have low hopes. Will be fun to see what happens when you put an initramfs in it. I'd just unpack the stock one and try that first.
Click to expand...
Click to collapse
Strictly to see if it would build completely and to get more info on how to do it, I did do an initramfs & kernel test build.
used the update2 kernel source
used the initramfs linked above (SHW-M110S intramfs Requires further research.)
ran find ./ | cpio -H newc -o > ~/Desktop/newramfs.cpio
added the cpio via menuconfig with no compression
It did build successfully and I ended up with a 7mb zImage vs. a 2.5mb.
There is no way in hell I am going to flash it because I do not know which initramfs (maybe from sk05) it is or what it contains but it did complete.
Now isn't this a kick in the nuts!
Since I got the toolchain all set I decided to focus on the Android source code. Following these directions .. http://source.android.com/source/download.html I got to "Building the code"
Code:
[email protected]:~/Desktop/myAnd$ source build/envsetup.sh
including device/htc/passion/vendorsetup.sh
including device/samsung/crespo/vendorsetup.sh
[email protected]:~/Desktop/myAnd$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. full-eng
2. full_x86-eng
3. simulator
4. full_passion-userdebug
5. full_crespo-userdebug
Which would you like? [full-eng] 1
============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv5te
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
[email protected]:~/Desktop/myAnd$ make
============================================
PLATFORM_VERSION_CODENAME=AOSP
PLATFORM_VERSION=AOSP
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=false
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv5te
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=OPENMASTER
============================================
Checking build tools versions...
build/core/main.mk:76: ************************************************************
build/core/main.mk:77: You are attempting to build on a 32-bit system.
build/core/main.mk:78: Only 64-bit build environments are supported beyond froyo/2.2.
build/core/main.mk:79: ************************************************************
build/core/main.mk:80: *** stop. Stop.
Well, 32-bit will do for now seeing how ::cough:: I'm not the one building gingerbread.
I guess my next how-to is going to be how to go out and buy a PC and setup a 64-bit development environment.
Well, 32-bit will do fro now see how ::cough:: I'm not the one building gingerbread.
I guess my next how-to is going to be how to go out and buy a PC and setup a 64-bit development environment.
Click to expand...
Click to collapse
Could try the gnu cross compiler I suppose maybe it's clever enough to work around it. Your computer really isn't 64 bit though? You could just install a 64 bit VM assuming it is.
koe1974 said:
added the cpio via menuconfig with no compression
Click to expand...
Click to collapse
Ok, that procedure is easier than it used to be, or than what I read it used to be. I'm not afraid to add one and flash it. Just busy with making one I like right now though.. then again.. sounds like a 10 minute interruption.. so.. we'll see... oh and I don't remember what was stopping xconfig from working, but something annoying.. it's quite a bit nicer than menuconfig. I need to learn how that works though.. cause really you should add modules from the compilation itself right.. so you cant have the initramfs already before you compile, unless make opens it and add the modules and re-cpio's it. Anyway.. I'll shoot first, ask later.
edit: just flashed.. it gave about 1 tenth of a blue bar and froze. Ok, that was fun, back to fixing and ext4 kernel up.
appagom said:
Could try the gnu cross compiler I suppose maybe it's clever enough to work around it. Your computer really isn't 64 bit though? You could just install a 64 bit VM assuming it is.
Click to expand...
Click to collapse
The VM I setup was 32bit, but it's 64bit now. I will just modify the How-To for a 64bit system.
4 bugs related z4control issues solved(ok 2 were probably the same as well as a fifth, so really 3)..
one, it's failing to create a directory it needs (/system/etc/init.d), reported, work around create by hand.
2) It's rfs formatting wrapper script which checked for voodoo, failed. Strange bug in sh actually.. workaround in script found and reported
bugs 3 and 4 details unimportant, were related to the mystery of where sslvpn went. z4build was splitting the initramfs by tacking it some of it brute force on to the end of the zImage. The init script found it again and unpacked the files before continuing. Oddly, it seems an uneeded because I fit the only big displaced file in just fine without splitting and I didn't even use heavy compression. Anyway, needed or not it caused two files to go missing, this one, and a small text file that reported the version of z4mod. this file prevented z4control from working.
I will not fix this tonight, but I mostly understand it (altough not in exact detail of precisely understanding some of the odd symptoms, but I think dealing with this will likely solve it all) My diffs could never find the version file, cuase I never unpacked it to know it even existed in the first place. Waaaah.. bug tracking is tiring. We should have this all running very shortly.
update: my first attempt at fixing the repacking bug.. resulted (I already feared this but hoped it would just go away) in a kernel that seems totaly complete, but where it seems something in the init wrapper isn't working... getting closer to finding it.
update: LAST BUG FIXED
The last bug(which I previously assumed was part of the repack bug) was actually aslo part of z4build, now documented here:
http://forum.xda-developers.com/showpost.php?p=10638535&postcount=1062
I'm pretty sure that one should really get it all going now. there are no lines of code left to break. I've tested almost every line now. I'll get a new kernel out, but will need to wait for an updated z4control. z4ziggy seems busy right now maybe (no complaint obviously).
I can fix this last bug in my roll out of the kernel. The other remaining ones can be worked around pretty easily, but not pretty for user instructions, better to wait probably.
SK05 Rebuild test (PASS)
We have doubts about if the shw-m110s_defconfig is what is used by samsung so I decided to try to make a working kernel from an initramfs and froyo_update source code.
General idea of what I did...
sk05 source code froyo_update (from samsung)
sk05 initramfs (link in post 4 "initramfs SK05 Tested .. OK")
cd initramfs_dir
find . -print0 | cpio -o0 -H newc | gzip -9 -f > some/path/initramfs.cpio.gz
cd kernel source code root directory
modify Makefile ln. 184
make aries_android_rfs_defconfig
make menuconfig
disable a.out
add path to initramfs archive
compression gzip
make
tar --format=ustar SK05rebuilt.tar zImage
Click to expand...
Click to collapse
Results in a zImage the same size (4.6mb) as samsung's, and it boots.
awesome..
I GOT IT
That was big fat B to solve. Debugging self destructing scripts that run in a startup environment with different mounts and different PATH variable is no fun and requires some imagination. I had to work around 2 more bugs in z4build but now I have user transparent workarounds to all of them.. plug and play. Unfortunately I have about 30 minutes more free time today so I probably wont post it today. I should clean up some comments and such in it first probably. We'll see.
appagom said:
awesome..
I GOT IT
Click to expand...
Click to collapse
Very nice!
Sent from my SHW-M110S using XDA App
the "awesome" comment was referring to you. Should be able to take the grak of z4grak with some compiling , but I'm happy with it in too.. doesn't matter.
Anyway.. I updated the kernel page (from the link on OP). The new kernel is there, but I pushed it out very fast. Didn't flash last repack myself yet after changing comments.. but I only changed comments. (I am running the posted copy now) It needs testing since my system has gotten a been used and non-pristine. Get z4control, you can use it to flash it if you want. the rest is all push button I hope.
Oh and default settings are less safe than Tegrak, not much if any better than ext2 actually. I think.. can't confirm right now. I recommend modifying etc/fstab to data=ordered,barrier=1 personally.. but that's what I like about z4.. you can decide for yourself.
Sent from my SHW-M110S using XDA App

[KERNEL] is Tiny-shmem good for android?

Hi fellows,
I have made a patch to enable the use of Tiny-SHMEM instead the full SHMEM filesystem in android kernels. I think we can gain some performance here. It seems to be working, but I have some thoughts to share with you.
1) It seems that android uses /dev/ashmem rather than /dev/shm, and the only two functions of mm/shmem.c needed by mm/ashmem.c is available on tiny-shmem.
2) Android also needs to mount filesystem as tmpfs. If we use tiny-shmem, than tmpfs will use ramfs code. So, we will support online growing, but we can not limit sizes. I have just one partition (/app-cache) that has size limits. The question is: we actually need size limits?
If anyone like, I can release the patch after some testing I'm doing.
Thanks,
Ronan
I can help u test on, well you know!
Hi diz!
So, I'm attaching a patch for GT-P1000 kernels. It should be fine on every version.
It just modify the Init/Kconfig file since the tiny-shmem is already on source code and you just need to adjust the configuration to define CONFIG_TINY_SHMEM.
If you want to test, apply this patch into your kernel tree, execute 'make menuconfig', go to section:
General Setup -> Configure standard kernel features (for small systems) -> Default shmem filesystem implementation -> Tiny shmem filesystem
and then compile.
Any updates in this project??
Sent from my GT-P1000 using XDA App
jadmask3rlm said:
Any updates in this project??
Sent from my GT-P1000 using XDA App
Click to expand...
Click to collapse
Still need people to test it... RAMFS could induce some problems...
My latest unstable kernel version has this patch applied and tiny-shmem is selected. If anyone wants to test: http://forum.xda-developers.com/showthread.php?t=1274855
But, it is just for LATIN models!
Ronis_BR said:
Hi diz!
So, I'm attaching a patch for GT-P1000 kernels. It should be fine on every version.
It just modify the Init/Kconfig file since the tiny-shmem is already on source code and you just need to adjust the configuration to define CONFIG_TINY_SHMEM.
If you want to test, apply this patch into your kernel tree, execute 'make menuconfig', go to section:
General Setup -> Configure standard kernel features (for small systems) -> Default shmem filesystem implementation -> Tiny shmem filesystem
and then compile.
Click to expand...
Click to collapse
Hello
I have, and then someone else (just to make sure) applied the patch, but the "default shmem filesystem implementation" option is not available in general setup, after running 'make menuconfig'
dizgustipated said:
Hello
I have, and then someone else (just to make sure) applied the patch, but the "default shmem filesystem implementation" option is not available in general setup, after running 'make menuconfig'
Click to expand...
Click to collapse
yea the same happened with me too(on another device too)
so what i did
in .config
add this:
CONFIG_TINY_SHMEM=y (it should be 'is not set')
Hi diz,
This option is under Configure kernel features (for small systems). It is the last option in the menu and you can select two values. Yesterday I applied the patch in my kernel tree and it works properly.
Sent from my GT-P1000L using xda premium
AH! Btw, you must enable:
CONFIG_MMU (System type)
CONFIG_EMBEDDED (General setup)
to see the option. So, if you haven't enabled CONFIG_SWAP, than you can choose CONFIG_TINY_SHMEM, otherwise just CONFIG_SHMEM will be available.
FYI, I'm using this with tiny-shmem for 8h and nothing weird happened yet
Thanks,
Ronan
working on it now,
up to the compile part,
its a little different working with my source, than stock
quick q
how do we show users this is working or even added in their kernels?
Well, you can execute:
busybox zcat /proc/config.gz | grep SHMEM
If you see:
CONFIG_TINY_SHMEM=y
Then tiny shmem was selected and is activated.
I'll wait your results! Thanks for the help!!!!
Ronan
Sent from my GT-P1000L using xda premium
Now, when trying to compile (mine and teks way)
It says, kernel tree not clean, please run make mrproper in kernel directory.
So I do, and it erases the tiny shmem, and goes back to default p1cm7 configuration.
Lol, kernel work makes porting a rom from basecode a walk in the park!
When typing make, or make zimage, in same directory as make menuconfig, it errors and says /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-gcc: Command not found
and
make
make: /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-gcc: Command not found
scripts/kconfig/conf -s arch/arm/Kconfig
init/Kconfig:957:warning: choice value used outside its choice group
init/Kconfig:958:warning: defaults for choice values not supported
make: /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-gcc: Command not found
CHK include/linux/version.h
UPD include/linux/version.h
CHK include/generated/utsrelease.h
UPD include/generated/utsrelease.h
Generating include/generated/mach-types.h
CC kernel/bounds.s
/bin/sh: /opt/toolchains/arm-2009q3/bin/arm-none-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
below is my .config file, zipped because xda cant load hidden files
Hi diz,
First,
kernel tree not clean, please run make mrproper in kernel directory.
It is because the kernel directory has a git repo and it is not clean. When you use 'make mrproper' it will remove the patch because it probably wasn't commited yet.
The easiest way to solve it is:
mv .git .gitold
<Compile the kernel>
mv .gitold .git
If you do this, this problem should be gone.
The second error seems that you are pointing the gcc cross-compiler to a wrong path in Makefile. Check where you installed the compiler and set it accordingly in Makefile by changing the value of this variable:
CROSS_COMPILE ?=
Hope it helps!
Thanks,
Ronan
By the way, your config file seems to be ok!
Change the tool chain prefix to arm-none-eabi- and compile (after doing the steps ron told)
SUCCESS!!!!!!!!
I've posted it here,
http://forum.xda-developers.com/showpost.php?p=19128294&postcount=2205
Good! Let's see what will happen now
Thanks!
Cyanogen 7 tiny_shmem kernel
I have decided to move the kernel here.
So as not to "invade" another's thread
This is only for unofficial beta cm7 port
* FILE SYSTEM
TINY_SHMEM enabled
* LCD Voltage
down to 260000 from 300000
* I/O scheduler default
"no-op"
type: busybox zcat /proc/config.gz | grep SHMEM
in your terminal emulator
you will see:
CONFIG_TINY_SHMEM=y
(means tiny shmem is activated."
dizgustipated said:
I have decided to move the kernel here.
So as not to "invade" another's thread
* FILE SYSTEM
TINY_SHMEM enabled
* LCD Voltage
down to 260000 from 300000
* I/O scheduler default
"no-op"
type: busybox zcat /proc/config.gz | grep SHMEM
in your terminal emulator
you will see:
CONFIG_TINY_SHMEM=y
(means tiny shmem is activated."
Click to expand...
Click to collapse
THIS KERNEL IS Making my WIFI Hotspot activate on MIUI for SGT
- I just have issue with the Mobile Network being broken?
- The touchscreen also broken but i'ved fixed that one
- usb tethering error = ive'd fixed it too
Can you do something on the mobile data being broken on the kernel side?
Because if i use angel666 zimage , cm modded, mobile data work but hotspot broken
If i use this its the other way around. Lol

[DEV] Building a custom kernel and kernel modules for stock kernel

Since fire phone doesn't have a bootloader unlock at the moment. There is no point in building a custom kernel. But By building a kernel we can build kernel modules which work on the stock kernel. And yes you can load unsigned kernel modules without a problem since fire phone doesn't use tz apps to verify kernel modules like Samsung does.
Setup
Source
Download the fire phone sources for firmware 4.6.1 from here. And extract the platfrom.tar inside the archive to somewhere(KERNEL_DIR).
toolchain
You can use the android ndk from google, But it requires some setup. I'm using linaro toolchain from here. You can use compiler version 4.7, 4.8 or 4.9. Kernel I'm using (Firmware 4.6.3 - Linux 3.4-perf-g280c96c) is built with gcc-4.7. But I'm using this gcc-4.9. Download it, extract is somewhere(TOOLCHAIN_DIR) and add the $TOOLCHAIN_DIR/bin to your PATH. Theoretically you would be able to build the kernel on windows using Cygwin or MSYS tools but using Linux is better.
config
Connect your phone trough adb and run
Code:
adb pull /proc/config.gz
zcat config.gz > $KERNEL_DIR/kernel/qcom/3.4/.config
With this config you will run into some problems because of a missing "trapz_generated_kernel.h". I don't know if this is an auto generated file when they build android as a whole or amazon removed this explicitly(can they do that without violating GPL?). Anyway It looks trapz is some low level kernel debugging function(comment here if you know more about it). We can safely disable it. Open $KERNEL_DIR/kernel/qcom/3.4/.config in a text editor and change the lines
Code:
CONFIG_TRAPZ=y
CONFIG_TRAPZ_TP=y
CONFIG_TRAPZ_TRIGGER=y
CONFIG_HAVOK=y
to
Code:
#CONFIG_TRAPZ=y
#CONFIG_TRAPZ_TP=y
#CONFIG_TRAPZ_TRIGGER=y
#CONFIG_HAVOK=y
building
Now edit the $KERNEL_DIR/kernel/qcom/3.4/Makefile and add this changes
Code:
EXTRAVERSION = -perf-g280c96c
This is at the top of the makefile. If we don't add this, vermagic for the modules will differ from stock kernel and they won't load.
ARCH=arm
CROSS_COMPILE=arm-linux-gnueabihf-
Click to expand...
Click to collapse
Here arm-linux-gnueabihf- is my cross compiler frefix. Look in $TOOLCHAIN_DIR/bin/ to find it.
Now cd into $KERNEL_DIR/kernel/qcom/3.4/ and do
Code:
make
The build will fail a few times complaining about missing headers. Most of the time it's just
Code:
#include <myheader.h>
instead of
Code:
#include "myheader.h"
Edit the source file where the build fails and change <>s to ""s. (maybe android ndk ignores the difference and include the headers anyway)
After kernel compiles, we are good to go. We can use this kernel sources to build kernel modules for stock kernel.
Kernel modules
To build the kernel modules, we basically need two things. An approximate kernel source and the Module.symvers file from the original kernel. We can get the Module.symvers file by building the complete kernel as explained above or Just extract it from our stock kernel.
To extract the Module.symvers from the stock kernel, extract the boot.img file from firmware update image. Get mkbootimg tools from here compile it and run
Code:
unmkbootimg --kernel zImage ---ramdisk ramdisk.cpio.gz -i boot.img
After you get the zImage. Download extract-symvers script from here and run
Code:
python2 extract-symvers.py -B 0xc0008000 zImage > Module.symvers
place this file in $KERNEL_DIR/kernel/qcom/3.4/ (You still have to do the changes mentioned above in kernel config and building section run make in the $KERNEL_DIR/kernel/qcom/3.4 and intrupt it after few seconds)
Now you can build loadable modules against this source. Here is a hello world kernel module.
Code:
//hello.c
#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
static int __init hello_start(void)
{
printk("hello to the world from module");
return 0;
}
static void __exit hello_end(void)
{
printk("heloo exit");
}
module_init(hello_start);
module_exit(hello_end);
Code:
#Makefile
KERNEL_DIR=<your kernel dir>/kernel/qcom/3.4
obj-m := hello.o
PWD := $(shell pwd)
default:
$(MAKE) ARCH=arm CROSS_COMPILE=armeb-linux-gnueabi- -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
Put this files in a folder and run make in it. Change the paths and cross compiler prefix according to your setup. and run make.
After the build push the hello.ko to the phone.
Code:
adb push hello.ko /sdcard/
adb shell
su
cd sdcard
insmod hello.ko
run dmesg and you'll see the message.
I'm currently trying to build kexec module from hashcode's sources and USB OTG modules.
I'm attaching a few thing helped me do this.
since they have released this version of the fire os they have to provide the source code
see
http://www.gnu.org/licenses/gpl-faq.html#GPLRequireSourcePostedPublic
you have just shown that the source code they releases for the kernel does not match the one used to build the kernel. This means it is a clear violation of the gpl and amazon is in breach and can be sued.
on another note.
are the drivers for the nfc and camera compiled as a module or into the kernel?
They have yet to provide 4.6.3 and 4.6.4 kernel sources too.
I don't know exactly but in order for NFC and camera to work drivers are required and they are in fact compiled into the kernel.
The problem we currently have with NFC and camera is proprietary hal (hardware abstraction libraries) They are a part of Android and does not subject to GPL. Amazon changed the original android way how hal works and didn't release the sources!
by looking at the kernel drivers maybe we would be able to implement hal from scratch. But I don't see that intense dev support for fire phone. If you are up for it camera sources are at $KERNEL_DIR/kernel/qcom/3.4/drivers/media/platform/msm/camera_v2/
Major MAJOR respect for all of you making the Fire Phone even better!
@madushan1000
Could we do something like this to install a custom boot.img?
http://forum.xda-developers.com/optimus-l9/general/guide-install-custom-roms-locked-t3249828
I don't own this device but has anyone tried to see if kexec works?
spudowiar said:
I don't own this device but has anyone tried to see if kexec works?
Click to expand...
Click to collapse
Nope, I was working on it. But then I got a job. It will be sometime before I can start working on it again.
Could someone please provide the config extracted from /proc/config.gz?
I can't find this on CM11 rom for some reason.
Building the kernel now.
Some bugs are in the code and -Wall and gcc-wrapper.py escalate the warnings.
I wonder if those errors are there on purpose XD
helloworld.ko loaded successfully
I was able to execute kexec without anything. Just the binary.
Will keep you posted - this hacking might take a while to figure it all out.
I already have 3.4 kernel from the amazon sources.
I have the kexec userland program.
What is left is a loadable kexec kernel module (if that is possible at all).
removed
Okarin said:
Are we even sure those Amazon Kernel Sources are correct?
Those errors caught by the wrapper scripts are giving me the creeps.
Git the kexec_load.ko build.
Currently hands on insmod.
Phone doesn't do a reboot any longer:
insmod kexec_load.ko
init_module(0xb6e6c008, 408241, "") = -1 ENOENT (No such file or directory)
write(2, "insmod: init_module '/sdcard/kex"..., 79insmod: init_module '/sdcard/kexec_load.ko' failed (No such file or directory)
) = 79
munmap(0xb6e6c000, 409600) = 0
mprotect(0xb6f8c000, 4096, PROT_READ|PROT_WRITE) = 0
mprotect(0xb6f8c000, 4096, PROT_READ) = 0
close(0) = 0
close(1) = 0
close(2) = 0
futex(0xb6f6cd74, FUTEX_WAKE_PRIVATE, 2147483647) = 0
munmap(0xb6f8c000, 4096) = 0
exit_group(-1) = ?
First goal is to get module loaded.
Goal reached:
kexec_load 27813 0 - Live 0x00000000 (O)
procfs_rw 12770 0 - Live 0x00000000 (O)
wlan 3793980 0 - Live 0x00000000 (O)
Shouldn't be functional at all..
I disabled some function calls just to get the module loaded.
The missing symbols are:
soft_restart
arch_kexec
machine_shutdown
And the version I use does some insane function hooking ..
More rework is needed.
[email protected]:/data/local # ./kexec /sdcard/vmlinux
kernel: 0xaf12d008 kernel_size: 7e1354c
unrecoverable error: could not scan "/proc/device-tree/": No such file or directory
<6>[ 97.681256] Kexec_load: Replacement... :
<6>[ 97.681344] kexec_load : my_syscall_table : c0106244
<6>[ 97.681405] kexec_load : kexec_load before replacement : c01b346c
<6>[ 97.681480] kexec_load : kexec_load after replacement : bf3a5650
<6>[ 97.681546] kexec_load : reboot before replacement : c01a83f0
<6>[ 97.681616] kexec_load : reboot after replacement : bf3a6348
<6>[ 97.681675] Kexec_load: End replacement... :
<6>[ 202.694691] Kexec: - Starting kexec_load...
<6>[ 202.694849] Kexec: - ---- kexec_load - result : '0'
It gets better:
255|[email protected]:/data/local # ./kexec --dtb=/sdcard/zImage-dtb /sdcard/vmlinux
kernel: 0xaf1b1008 kernel_size: 7e1354c
kexec-zImage-arm : dtb.img BEFORE CUT : Start : '0xae66f008' - Length : '0xb411e9' - End : '0xaf1b01f1'
Segmentation fault
More tomorrow.
Click to expand...
Click to collapse
Where are you getting your kexec module sources from? BTW try using the original amazon kernal binary the phone is shipped with (we are sure it works). Don't use the custom kernel for the kexec tests (We don't know the custom kernel actually works)
madushan1000 said:
Where are you getting your kexec module sources from? BTW try using the original amazon kernal binary the phone is shipped with (we are sure it works). Don't use the custom kernel for the kexec tests (We don't know the custom kernel actually works)
Click to expand...
Click to collapse
Here is the thread I used as a starting point.
I will put up my "fork" on github after I get permission to do that
The userland part build like a charm once I took the compiler you recommended.
The kernel-module was tricky because the whole thing is modded like hell.
To be able to load I had to comment out some hard coded addresses and the calls to unresolvable symbols.
removed
Okay the kernel gets loaded.
But
kexec -e shuts off the device.
strace doesn't help.
On the plus side:
Devices are shutdown
Look promising
I need a way to tail dmesg ...
Okay a lot of digging around and I found out that the reboot syscall doesn't work properly..
It doesn't look like it hits the kexec_module it looks more like it hits the actualy sys_reboot
Okay reboot syscall hits my reboot-hook.
But the softreboot doesn't work now.
Okay there is some kind of watchdog runnig which doesn't like my kexec.
I need to kill it - that should happen tomorrow.
removed
I hit the same wall when I tried to isolate the kexec code from the kernel itself to a module. I stopped working on it because I lacked the time. BTW the error you are facing now
<3>[ 80.580644] BUG: scheduling while atomic: kexec/4067/0x00000002
Click to expand...
Click to collapse
is because memory allocator is trying to switch threads while you are in a syscall. it's because of lines like this
image = kzalloc(sizeof(*image), GFP_KERNEL);
Click to expand...
Click to collapse
Try changing GFP_KERNEL to GFP_ATOMIC. Other than that, I have another suggestion. Try to get the kernel to run in a single core mode before running kexec code. This might simplify things. I don't know how to do this though.
madushan1000 said:
I hit the same wall when I tried to isolate the kexec code from the kernel itself to a module. I stopped working on it because I lacked the time. BTW the error you are facing now
is because memory allocator is trying to switch threads while you are in a syscall. it's because of lines like this
Try changing GFP_KERNEL to GFP_ATOMIC. Other than that, I have another suggestion. Try to get the kernel to run in a single core mode before running kexec code. This might simplify things. I don't know how to do this though.
Click to expand...
Click to collapse
The atmic error is gone now. It went away after I disabled the watchtog.
smp_disable() is what you are looking for - but this causes the system to hard_reboot ATM XD
what happens if you kill every userlevel program before smp_disable()?
removed
#define tomorrow
Okay .. I worked out the preemption thing.
At least it does something.
Still a black screen and the MSM_WATCHDOG is a ***** again.
It needs to be suspended .. at least that what I get from the code I read here.
If I remove the driver too early the output in /proc/kmsg stops ..
If I try to remove it too late ... well it causes a resched while atomic.

Fixing stock kernel sources for H30-U10

Github repo: https://github.com/kernel-killer/android_kernel_huawei_h30u10
All changes I made since last commit are in my private repo.
Install packages (Not sure if it's right):
Code:
sudo apt-get install build-essential
Note: Please run ./mk ckeck-env to verify your build enviroment (Newer GNU MAKE will fail but the code compiles the same with new or older version)
Build:
Code:
./mk bm_new k
Testing your new kernel:
Download both attachments (KernelSwapper and BootimgRestore).
Append headers from stock kernel to zImage (which can be found at ./out/target/product/huawei82_cwet_kk/obj/KERNEL_OBJ/arch/arm/boot/zImage)
In KernelSwapper update 'kernel' with your own generated zImage rename it to 'kernel' and replace it inside zip.
In BootimgRestore replace 'boot.img' with your current ROM's boot.img in case that something goes wrong (e.g.: Phone not booting).
Copy the two new zips into phone's memory (or SD card) and flash KernelSwapper.
===== Reserved #1 =====
Thanks for the awesome work KK. I am on CM 13 3.4.67 kernel. Can i use this or do i have to be in stock rom for testing the kernal?
Sent from my Honor 3C using Tapatalk
---------- Post added at 06:12 AM ---------- Previous post was at 06:02 AM ----------
Update : Flashed the kernel, phone booted but felt laggish while using. I am still testing, will let you know what happens
Sent from my Honor 3C using Tapatalk
karkeankit said:
Thanks for the awesome work KK. I am on CM 13 3.4.67 kernel. Can i use this or do i have to be in stock rom for testing the kernal?
Sent from my Honor 3C using Tapatalk
---------- Post added at 06:12 AM ---------- Previous post was at 06:02 AM ----------
Update : Flashed the kernel, phone booted but felt laggish while using. I am still testing, will let you know what happens
Sent from my Honor 3C using Tapatalk
Click to expand...
Click to collapse
Yes, I'm sure that the kernel has multiple bugs. The phone may feel laggish because there is enabled low-level kernel debugging over UART.
Thank you for testing...
kernel.killer said:
Yes, I'm sure that the kernel has multiple bugs. The phone may feel laggish because there is enabled low-level kernel debugging over UART.
Thank you for testing...
Click to expand...
Click to collapse
You are welcome, wishint you good luck for further development
Sent from my Honor 3C using Tapatalk
Hi, tnx for The kernel
if i Update my kernel VPN bug in CM12.1 will fix?
hamadk said:
Hi, tnx for The kernel
if i Update my kernel VPN bug in CM12.1 will fix?
Click to expand...
Click to collapse
Nope, it's ROM bug not a kernel bug plus I have released only development preview version which has enabled many debugging options and it may be quite buggy.
Thanks, but can this process led to a suitable kernel for CM13?
Does this kernel fixes the video playback problem and the recording problem?(Can't play or capture 720p videos, screen recorder works fine, just the camera.)
Sent from my Huawei Honor 3C using XDA Labs
Lumpbloom7 said:
Does this kernel fixes the video playback problem and the recording problem?(Can't play or capture 720p videos, screen recorder works fine, just the camera.)
Sent from my Huawei Honor 3C using XDA Labs
Click to expand...
Click to collapse
http://forum.xda-developers.com/showpost.php?p=67848925&postcount=8
mhxygh said:
Thanks, but can it this process led to a suitable kernel for CM13?
Click to expand...
Click to collapse
Aim of this project is to make stock kernel sources stable for KitKat ROMs (It is originally for KK) but somebody else may patch them for CM 13. I am not working on this nor I'll do.
Will you be adding extra CPU governors and IO schedulers along with kernel level wakeups for double tap waking?
I was wondering who else is developing kernel 3.10.XX for this device ?
Ms_Julia said:
I was wondering who else is developing kernel 3.10.XX for this device ?
Click to expand...
Click to collapse
Actually, nobody is working on 3.10.X kernel. And I'm rather focusing on LineageOS for now.
What is the defconf for our device in kernel source
imranpopz said:
What is the defconf for our device in kernel source
Click to expand...
Click to collapse
This should include most configs
Code:
/* Mediatek common */
./mediatek/config/common/autoconfig/kconfig/AEE
./mediatek/config/common/autoconfig/kconfig/USER
./mediatek/config/common/ProjectConfig.mk
/* MT6582 common */
./mediatek/config/mt6582/autoconfig/kconfig/platform
./mediatek/config/mt6582/ProjectConfig.mk
/* h30u10 device specific */
./mediatek/config/huawei82_cwet_kk/autoconfig/kconfig/project
./mediatek/config/huawei82_cwet_kk/ProjectConfig.mk
kernel.killer said:
This should include most configs
Code:
/* Mediatek common */
./mediatek/config/common/autoconfig/kconfig/AEE
./mediatek/config/common/autoconfig/kconfig/USER
./mediatek/config/common/ProjectConfig.mk
/* MT6582 common */
./mediatek/config/mt6582/autoconfig/kconfig/platform
./mediatek/config/mt6582/ProjectConfig.mk
/* h30u10 device specific */
./mediatek/config/huawei82_cwet_kk/autoconfig/kconfig/project
./mediatek/config/huawei82_cwet_kk/ProjectConfig.mk
Click to expand...
Click to collapse
Replace Device Name with the configuration file found at:
Source/arch/arm/configs
It's written in this way something_DeviceCodename_user_defconfig
I need for the above step.. ☝☝☝
imranpopz said:
Replace Device Name with the configuration file found at:
Source/arch/arm/configs
It's written in this way something_DeviceCodename_user_defconfig
I need for the above step.. ☝☝☝
Click to expand...
Click to collapse
Well... This is Mediatek, DO NOT expect the sources to look nice. The configs are scattered through ./mediatek subdirectories, *.mk files are parsed and configs are assembled during build. Unfortunatelly, even if you manually assemble .config you will NOT be able to build the kernel. It is full of dirty hacks (Mediatek) and just typing "make" won't work, build will break.
Build:
Code:
$ git clone https://github.com/kernel-killer/android_kernel_huawei_h30u10.git
$ cd android_kernel_huawei_h30u10
$ export ARCH=arm && export ARCH_MTK_PLATFORM=mt6582 && export TARGET_PRODUCT=huawei82_cwet_kk
$ export CROSS_COMPILE=/path-to-your-toolchain/.../bin/arm-linux-androideabi-
$ ./mk n k
Code:
$ ./mk -h
Usage: (makeMtk|mk) [options] project actions [modules]
Options:
-t, -tee : Print log information on the standard-out.
-o, -opt=bypass_argument_to_make
: Pass extra arguments to make.
-h, -help : Print this message and exit.
Projects:
one of available projects.
Actions:
listp, listproject
: List all available projects.
check-env : Check if build environment is ready.
check-dep : Check feature dependency.
n, new : Clean and perform a full build.
c, clean : Clean the immediate files(such as, objects, libraries etc.).
r, remake : Rebuild(target will be updated if any dependency updats).
mrproper : Remove all generated files + config + various backup files in Kbuild process.
bm_new : "new" + GNU make's "-k"(keep going when encounter error) feature.
bm_remake : "remake" + GNU make's "-k"(keep going when encounter error) feature.
mm : Build module through Android native command "mm"
mma : Build module through Android native command "mma"
emigen : Generate EMI setting source code.
nandgen : Generate supported NAND flash device list.
codegen : Generate trace DB(for META/Cather etc. tools used).
drvgen : Generate driver customization source.
custgen : Generate customization source.
javaoptgen : Generate the global java options.
ptgen : Generate partition setting header & scatter file.
bindergen : Generate binder related information
sign-image : Sign all the image generated.
encrypt-image : Encrypt all the image generated.
update-api : Android default build action
(be executed if system setting or anything removed from API).
check-modem : Check modem image consistency.
upadte-modem : Update modem image located in system.img.
modem-info : Show modem version
gen-relkey : Generate releasekey for application signing.
check-appres : Check unused application resource.
sdk : Build sdk package.
win_sdk : Build sdk package with a few Windows tools.
banyan_addon : Build MTK sdk addon.
banyan_addon_x86 :Build MTK sdk x86 addon.
cts : Build cts package.
bootimage : Build boot image(boot.img).
cacheimage : Build cache image(cache.img).
systemimage : Build system image(system.img).
snod : Build system image without dependency.
(that is, ONLY pack the system image, NOT checking its dependencies.)
recoveryimage : Build recovery image(recovery.img).
secroimage : Build secro image(secro.img).
factoryimage : Build factory image(factory.img).
userdataimage : Build userdata image(userdata.img).
userdataimage-nodeps
: Build userdata image without dependency.
(that is, ONLY pack the userdata image, NOT checking its dependencies.)
dump-products : Dump products related configuration(PRODUCT_PACKAGE,PRODUCT_NAME ect.)
target-files-package
: Build the target files package.
(A zip of the directories that map to the target filesystem.
This zip can be used to create an OTA package or filesystem image
as a post-build step.)
updatepackage : Build the update package.
dist : Build distribution package.
Modules:
pl, preloader : Specify to build preloader.
lk : Specify to build little kernel.
md32 : Specify to build DSP md32.
tz, trustzone : Specify to build trusted execution environment.
k, kernel : Specify to build kernel.
dr, android : Specify to build android.
NULL : Specify to build all components/modules in default.
k <module path>
: Specify to build kernel component/module with the source path.
dr <module name>
: Specify to build android component/module with module name.
Other tools:
prebuilts/misc/linux-x86/ccache/ccache -M 10G
: Set CCACHE pool size to 10GB
Example:
./mk -t e1k emigen
: Generate EMI setting source code.
./mk -o=TARGET_BUILD_VARIANT=user e1k n
: Start a user mode full build.
./mk listp : List all available projects.
./mk e1k bootimage
: Build bootimage for e1k project.
./mk e1k bm_new k
: Build kernel for e1k project.
./makeMtk e1k c,bm_remake pl k
: Clean & Build preloader and kernel for e1k project.
./makeMtk e1k n k kernel/xxx/xxx
: Build(full build) kernel component/module
under the path "kernel/xxx/xxx" for e1k project.
./makeMtk e1k r dr Gallery
: Rebuild android module named Gallery for e1k project.
./makeMtk e1k mm packages/apps/Settings
: Change Directory to packages/apps/Settings and execute "mm"
./makeMtk e1k mma packages/apps/Settings
: Change Directory to packages/apps/Settings and execute "mma"
Edit:
I fixed the sources, so menuconfig can be used.
Apply patch:
Code:
$ git am 0001-Fix-build-using-make-command.patch
Build:
Code:
$ cd kernel && export ARCH=arm && export ARCH_MTK_PLATFORM=mt6582 && export TARGET_PRODUCT=huawei82_cwet_kk
$ export CROSS_COMPILE=/path-to-your-toolchain/.../bin/arm-linux-androideabi-
$ make -C $(pwd) O=output h30u10_defconfig menuconfig
$ make -C $(pwd) O=output
Append MTK headers:
Code:
$ ../mediatek/build/tools/mkimage output/arch/arm/boot/zImage KERNEL > output/zImage
*Note: I recommend using AOSP arm-linux-androideabi-4.9 toolchain.
Getting cp: cannot stat 'out/target/product/huawei82_cwet_kk_kernel.log
Make [1]: [kernel ] error 1
Make: *** [remake] error 2

Categories

Resources