[DEV ONLY]Xperia Z1 kernel building instructions - Xperia Z1 Original Android Development

I think the time has come to share the info about kernel development we've been keeping for ourselves until now. just be sure to ready the complete thread and not just execute everything without thinking. I won't be responsible for any bricks etc.
Warnings!!
- Only start with a kernel if you are a developer with knowledge about kernel developping.
- Always use the specific dt.img build for your kernel!!!!! Very important!
- Don't complain if it doesn't work when you do something wrong!
== Information ==
Let's start with some info first.
MSM8974 needs something new to build a kernel, this is called a dt.img. This basically is an img file which holds information about the board pagesize, kernel version and some other kernel related things. You can only use a specific dt.img with a kernel, this file needs to be generated by a binary called dtbTool. This bin4ry can be found in the Cyanogen repo's or you can download a prebuild one in this thread.
== Compiling a kernel ==
I'll skip this part for now, every kernel dev should know this part maybe I'll add it later.
== Generating a dt.img ==
Basically you will only need your kernel sources and the dtbTool binary, then you need to generate it using a command like this:
Code:
./dtbTool -o ~/dt_files/dt.img -s 2048 -p ./scripts/dtc/ ./arch/arm/boot/
This seems very simple but it's quite important when building a kernel for MSM8974, or other S800 boards.
After this step has been completed you will find your dt.img in a folder callled dt_files, this folder should be in your home of linux now.
== Making the actual boot.img ==
After making the zImage and dt.img you need to have your ramdisk and an mkbootimg adapted for the dt.img to make a booting/working kernel for our rhine board.
be sure the naming of your files is correct:
- zImage
- dt.img
- intrd.img for your ramdisk
You can generate it by using the following command:
Code:
./mkbootimg --base 0x00000000 --kernel zImage --ramdisk_offset 0x02000000 --tags_offset 0x01E00000 --pagesize 2048 --cmdline "androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x3F ehci-hcd.park=3 msm_rtb.enable=0 lpj=192598 dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y" --ramdisk initrd.img --dt dt.img -o boot.img
Let's get kernel development started for everyone!
== Extra ==
If you like my work consider donating me a beer

binary files attached

krabappel2548 said:
binary files attached
Click to expand...
Click to collapse
Awesome! Thanks! Will tinker around with it tonight!

@krabappel2548 : Thanks for the tutorial
I've been trying to compile the kernel using Linaro, and I'm constantly getting this error :
Code:
scripts/mod/empty.c:1: error: bad value (cortex-a15) for -mcpu= switch
kernel/bounds.c:1: error: bad value (cortex-a15) for -mcpu= switch
Could you please tell me what I am missing out on here?
Thanks

Pwng3 said:
@krabappel2548 : Thanks for the tutorial
I've been trying to compile the kernel using Linaro, and I'm constantly getting this error :
Code:
scripts/mod/empty.c:1: error: bad value (cortex-a15) for -mcpu= switch
kernel/bounds.c:1: error: bad value (cortex-a15) for -mcpu= switch
Could you please tell me what I am missing out on here?
Thanks
Click to expand...
Click to collapse
try this
https://github.com/faux123/Galaxy_Note_3/commit/8ad5dd6f969bb76ef970cbf101a255bb093efe5f

If you want to compil kernel, but with a full automation, you can use this script
"scriptZ1" : http://forum.xda-developers.com/attachment.php?attachmentid=2346163&stc=1&d=1382568778
With this script you have an automatic download/configuration (Toolchain, dtbTool, etc...)
You must go to $HOME, and "mkdir kernel"
cd kernel
unzip file (only 1 script) => scriptZ1
chmod 777 scriptZ1
./scriptZ1
Follow instructions
that's all

DooMLoRD said:
try this
https://github.com/faux123/Galaxy_Note_3/commit/8ad5dd6f969bb76ef970cbf101a255bb093efe5f
Click to expand...
Click to collapse
That resolved the issue. Thanks
Update :
I was getting this error :
Code:
ERROR: modpost: Found 2 section mismatch(es).
To see full details build your kernel with:
'make CONFIG_DEBUG_SECTION_MISMATCH=y'
To build the kernel despite the mismatches, build with:
'make CONFIG_NO_ERROR_ON_MISMATCH=y'
(NOTE: This is not recommended)
make[1]: *** [vmlinux.o] Error 1
make: *** [vmlinux.o] Error 2
So I went on to make the build with make CONFIG_DEBUG_SECTION_MISMATCH=y.
After which, when I tried generating the dt.img, I'm stuck up on this error that says :
Code:
Generating master DTB... error writing output file, please rerun: size mismatch 530432 vs -566
Could someone help please?

@krabappel2548
Hey,after repacking whole kernel I'm getting this error when I try to boot it:
Code:
fastboot boot boot.img
downloading 'boot.img'...
OKAY [ 0.319s]
booting...
FAILED (remote: dtb not found)

How do I create a dt.img? I always get Found 0 Unique dtbs.

Shoaib05 said:
How do I create a dt.img? I always get Found 0 Unique dtbs.
Click to expand...
Click to collapse
first download Doom-Lords kernel build tools
then copy dtbtool from msm8978aa folder in to you kernel source directory
then open terminal and cd to your kernel directory and enter these codes:
Code:
./dtbTool -o dt.img -s 2048 -p scripts/dtc/ arch/arm/boot/
instruction by DoomLord

Red-code said:
first download Doom-Lords kernel build tools
then copy dtbtool from msm8978aa folder in to you kernel source directory
then open terminal and cd to your kernel directory and enter these codes:
Code:
./dtbTool -o dt.img -s 2048 -p scripts/dtc/ arch/arm/boot/
instruction by DoomLord
Click to expand...
Click to collapse
Managed to get past it but now it is giving a size-mismatch error. :/

Shoaib05 said:
Managed to get past it but now it is giving a size-mismatch error. :/
Click to expand...
Click to collapse
Does this work? binary is x86_64
dt_dir is arch/arm/boot/ on 3.4 - arch/arm/boot/dts on 3.10
Code:
mkqcdtbootimg --kernel arch/arm/boot/zImage --ramdisk ramdisk.bz2 --base 0x00000000 --ramdisk_offset 0x02000000 --tags_offset 0x01E00000 --pagesize 2048 --cmdline "androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x3F ehci-hcd.park=3 msm_rtb.enable=0 lpj=192598 dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y" --dt_dir arch/arm/boot/ -o boot-.img

Related

[REF] zImage Initramfs

Very basic guide to extract the initramfs from the zImage, as well as a dump of the initramfs inside I9100XEKDB firmware.
Q: Why? This is simple!
A: Might help someone out!
Linux Bash script follows (standard initramfs extract script) :
Code:
pos=`grep -F -a -b -m 1 --only-matching $'\x1F\x8B\x08' zImage | cut -f 1 -d :`
dd status=noxfer if=zImage bs=$pos skip=1 2>/dev/null| gunzip -q > kernel.img
start=`grep -F -a -b -m 1 --only-matching '070701' kernel.img | head -1 | cut -f 1 -d :`
dd status=noxfer if=kernel.img bs=$start skip=1 > initramfs.img 2>/dev/null
mkdir initramfshere
cd initramfshere
cpio -i --no-absolute-filenames < ../initramfs.img
ls -l
I9100XEKDB initramfs: http://www.sgscompilebox.dreamhosters.com/initramfs.tar.gz
Repacking should be easy as well, but I haven't tried to boot a kernel I have repacked myself yet. Since Chainfire has a root kernel posted, it should work without issue though -- and these are standard linux kernels after all.
Grab the kernel repacker from http://www.sgscompilebox.dreamhosters.com/repacker.tar.gz
Following bash script to use it:
Code:
end=`repacker/findcpio.pl kernel.img | cut -f 2`
(cd initramfshere/; find . | cpio --quiet -R 0:0 -H newc -o > ../newinitramfs.img)
gzip -f9c newinitramfs.img > newinitramfs.img.gz
repacker/kernel_repacker.sh zImage newinitramfs.img.gz
Might need some tweaking depending on your system, but this will hopefully get you started. You can use this to create your own root kernels as Chainfire has done, or modify as you want. Refer to the Q&A above!
Hi,
You can also find Samsung unmodified Galaxy S II initramfs on github, contributions welcome for missing ones:
https://github.com/GalaxySII/initramfs-galaxysii
Its repository collections is for every developer, and is not project/people specific: https://github.com/GalaxySII/
This is what Samsung should give us directly.
Related post, with reference Kernel source repository: http://forum.xda-developers.com/showthread.php?t=1054738
RyanZA said:
Very basic guide to extract the initramfs from the zImage, as well as a dump of the initramfs inside I9100XEKDB firmware.
Q: Why? This is simple!
A: Might help someone out!
Linux Bash script follows (standard initramfs extract script) :
Code:
pos=`grep -F -a -b -m 1 --only-matching $'\x1F\x8B\x08' zImage | cut -f 1 -d :`
dd status=noxfer if=zImage bs=$pos skip=1 2>/dev/null| gunzip -q > kernel.img
start=`grep -F -a -b -m 1 --only-matching '070701' kernel.img | head -1 | cut -f 1 -d :`
dd status=noxfer if=kernel.img bs=$start skip=1 > initramfs.img 2>/dev/null
mkdir initramfshere
cd initramfshere
cpio -i --no-absolute-filenames < ../initramfs.img
ls -l
I9100XEKDB initramfs: http://www.sgscompilebox.dreamhosters.com/initramfs.tar.gz
Repacking should be easy as well, but I haven't tried to boot a kernel I have repacked myself yet. Since Chainfire has a root kernel posted, it should work without issue though -- and these are standard linux kernels after all.
Grab the kernel repacker from http://www.sgscompilebox.dreamhosters.com/repacker.tar.gz
Following bash script to use it:
Code:
end=`repacker/findcpio.pl kernel.img | cut -f 2`
(cd initramfshere/; find . | cpio --quiet -R 0:0 -H newc -o > ../newinitramfs.img)
gzip -f9c newinitramfs.img > newinitramfs.img.gz
repacker/kernel_repacker.sh zImage newinitramfs.img.gz
Might need some tweaking depending on your system, but this will hopefully get you started. You can use this to create your own root kernels as Chainfire has done, or modify as you want. Refer to the Q&A above!
Click to expand...
Click to collapse
Hi..I notice there's an embedded kernel in the packer directory, but the path is an older version than the actual one in zimage. Is third just for pearl script purposes? Thanks
Sent from my GT-I9100
Hey RyanZA,
Following your script
> cpio -i --no-absolute-filenames < ../initramfs.img
extracts initramfs but gives me the error:
cpio: ../init: Cannot symlink to 'sbin-ueventd': Operation not permitted
Can you help a linux newbie here ? Do I need to be root?
EDIT: Ah! I think I know now... FAT does not support symlinks Going to ext...
Ok got the initramfs extracted from a zImage. Used repacker to create the zImage again. Did not change anything in initramfs. Filesize 5mb vs 8mb for the original. After a closer look I see that original contains lots of zeros. Ok appended zeros to match filesize and flashed the 'new' kernel. No go. Yellow triangle and no boot. Waited a long time.
Can anyone help? Maybe the repacker does something wrong? Maybe it should not compress?
Sent from my GT-I9100 using XDA Premium App
Anybody had any luck with this?
After said tweaking to get the repacker script running I got it to build a new zImage.
But mine was even only ~2MB small.... (seeing that the extracted initramfs summs up to about 3MB it makes at least a bit of sense, but still wondering).
Also the older kernel used (.29 against .35 that's actually running on my phone) makes me ....
Well, flashed it anyway but (as expected) it didn't work, phone showed the bootlogo and that's it, not even recovery worked.
So, is it the older kernel? Or is it forking up the initramfs image creation?
Or is there another way to rebuilt the kernel image with a new initramfs image?
I'd really like to get rebuilding the zImage working so I toy around with that a bit, try to make my own root kernel and all that funstuff
HellcatDroid said:
Anybody had any luck with this?
After said tweaking to get the repacker script running I got it to build a new zImage.
But mine was even only ~2MB small.... (seeing that the extracted initramfs summs up to about 3MB it makes at least a bit of sense, but still wondering).
Also the older kernel used (.29 against .35 that's actually running on my phone) makes me ....
Well, flashed it anyway but (as expected) it didn't work, phone showed the bootlogo and that's it, not even recovery worked.
So, is it the older kernel? Or is it forking up the initramfs image creation?
Or is there another way to rebuilt the kernel image with a new initramfs image?
I'd really like to get rebuilding the zImage working so I toy around with that a bit, try to make my own root kernel and all that funstuff
Click to expand...
Click to collapse
the fist script actually works good to pull initramfs. but I don't know about the repacker...better to build new
Yeah, trying to build a new kernel from sources at the moment (make is running as I type this).
Here's an idea why the rebuilder fails:
.29 kernel (that the rebuild script brings in and uses) but the initramfs has .35 version kernel modules (as it's for/from the .35 kernel)!
Not sure how delicate this version missmatch is, but there's a chance the one or the other important kernel module erroring out upon boot due to the version missmatch....
Well, let's see if a full build from sources works (as I know my luck, it won't....)....
that's because zImage has SFX code which tied very much to data (Image.gz). So you cannot just re-pack it back to existing zImage. You have to download source code of i9100 kernel and execute final part of kernel build where Image binary gets compressed and pre-pended by sfx header.
RyanZA said:
Following bash script to use it:
Code:
end=`repacker/findcpio.pl kernel.img | cut -f 2`
(cd initramfshere/; find . | cpio --quiet -R 0:0 -H newc -o > ../newinitramfs.img)
gzip -f9c newinitramfs.img > newinitramfs.img.gz
repacker/kernel_repacker.sh zImage newinitramfs.img.gz
Click to expand...
Click to collapse
err... the repacker/kernel_repacker.sh script only takes one argument.. how is it supposed to work???
sorg said:
that's because zImage has SFX code which tied very much to data (Image.gz). So you cannot just re-pack it back to existing zImage. You have to download source code of i9100 kernel and execute final part of kernel build where Image binary gets compressed and pre-pended by sfx header.
Click to expand...
Click to collapse
Yeah, that is actually what the repacker script does!
It has precomplied objects and compiles/links them together to the final (new) zImage.
saturn_de said:
err... the repacker/kernel_repacker.sh script only takes one argument.. how is it supposed to work???
Click to expand...
Click to collapse
You only pass the newinitramfs.img.gz that's created in the lines above, just drop the "zImage" from the commandline.
// EDIT
OK, I got as far as to compile my own kernel from the sources Samsung has released
I eventually end up with a nice and fresh, built from scratch zImage \o/
When I throw my selfmade zImage at the extractor script posted above, I get the proper (stock) initramfs filestructure I intended to put in (in other words, I managed to put my (as of now untouched) own initramfs.img into the zImage).
I create a nice .tar, flash with Odin and.... nothing
I get the bootsplash with the triangle and that's it, it doesn't get any further.
Anyone got a hint for me what I did wrong?
What I did:
(this all happened on a Linux machine)
extract Samy's kernel source
installed the codesourcery toolchain
set the CROSS_COMPILE var in ./kernel/Makefile to the proper path to the toolchain
ran
make c1_rev02_defconfig (according to readme.txt)
and then
make zImage CONFIG_INITRAMFS_SOURCE="/path/to/extracted/stock/initramfs/"
padded with 0x00s to the 8MiB size, tar'ed and Odin'ed
which brings me to the dead bootscreen....
Not even recovery works.
HellcatDroid said:
Yeah, that is actually what the repacker script does!
It has precomplied objects and compiles/links them together to the final (new) zImage.
Click to expand...
Click to collapse
I guess you've got repacker from first Galaxy?
It won't work. SFX header you're trying to compile is for first galaxy. It has hardcoded addresses and they are not compatible with Galaxy S II. Toolchain is also for SGS as well (not sure if it still suitable for SGSII).
Take kernel source code and toolchain for SGSII and it will work.
Yah, well, I got the kernel to compile fresh from sources now, no need for a repacker anymore, I just go make zImage and be happycat
Someone knows how to repack it?
Maybe Chainfire or Pulser?
Agreed, Can someone explain the process in full? modyfying and repacking zImage gets 2mb+ less in size, what we are missing?
Grooby said:
Agreed, Can someone explain the process in full? modyfying and repacking zImage gets 2mb+ less in size, what we are missing?
Click to expand...
Click to collapse
Necro much?
rawat said:
necro much?
Click to expand...
Click to collapse
zombie thread wants braaaaiiiiiiinnnnnnnnnnnnzzzzzzzzzzzzzz!!!!!!
Looks like i raised death searching for answer lool
A few tried to make repackers for the I9100 - and failed.
Even less know how to actually do it - and don't share the knownledge.
The thing is, that the initramfs is linked into the zImage during compile time, so it can't simply be "snipped out" and "new one pasted in".
That's why I eventually ended up compiling the whole thing from sources.
It would certainly nice if someone like ChainFire could share how to do it.... but he's too worried about others rebuilding his rootkernel with other nametags on it.
HellcatDroid said:
A few tried to make repackers for the I9100 - and failed.
Even less know how to actually do it - and don't share the knownledge.
The thing is, that the initramfs is linked into the zImage during compile time, so it can't simply be "snipped out" and "new one pasted in".
That's why I eventually ended up compiling the whole thing from sources.
It would certainly nice if someone like ChainFire could share how to do it.... but he's too worried about others rebuilding his rootkernel with other nametags on it.
Click to expand...
Click to collapse
GitHub.com/xiaolu
Sent from my GT-I9100 using xda premium

[Q] How to solve these two problems about compiling a kernel?

I'm just starting to learn the kernel compile
The help of many friends, I made ​​great progress soon. For example AndreiLux, etc.
I can compilethe kernel from Samsung official source code by meself, compile my own kernel for Samsung N7108
But now the two issues can not be resolved. Therefore, I hope more friends to help me and guide me.
The first problem
Compiled kernel does not support exfat format storage card.
In AndreiLux help, I added the code. if (! strncmp ("exfat_", mod-> name, 6)) return 1;
But exfat problem persists. When the the insert the exfat storage card will cause the phone to constantly reboot.
I saw http://forum.xda-developers.com/showthread.php?t=2154703 seems to have explained,
But please forgive my ignorance and ignorance. I'm a beginner. I don't understand it.
The second problem
The Wifi switch settings inside, unable to open. So. WIFI unavailable
Hope you can help me solve these two problems.
any one can help me ?
Try in development section this is generally for generic problems.
Sent from my GT-N7100
wctliu said:
The second problem
The Wifi switch settings inside, unable to open. So. WIFI unavailable
Hope you can help me solve these two problems.
Click to expand...
Click to collapse
Dont forget to copy your wifi modules to your ramdisk
I used boot.img from Samsung official rom
'perl split_bootimg.pl boot.img" extracted 2 files: boot.img-kernel and boot.img-ramdisk.gz.
If I directly use the compiled zImage packaged, such as:used "mkbootimg --base 0x00200000 --kernel /home/wctliu/android/kernel/sumsang-kernel/arch/arm/boot/zImage --ramdisk boot.img-ramdisk.gz -o new_boot.img" .
the new_boot.img can be able to activate the phone. But no WiFI
If i do that:
mkdir ramdisk
cd ramdisk
gzip -dc ../boot.img-ramdisk.gz | cpio -i
Copy compiled module drive replacement adding: system / lib / modules
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz
mkbootimg --base 0x00200000 --kernel /home/wctliu/android/kernel/sumsang-kernel/arch/arm/boot/zImage --ramdisk newramdisk.cpio.gz -o new1_boot.img
the new1_boot.img cann‘t be able to activate the phone
I where operating errors?Please tell me what's wrong?
any one can help me ?
Did you placed the modules in the right path in your initramfs? /lib/modules/ ... Try looking at the logs or try manual insmod...
Nazar78 said:
Did you placed the modules in the right path in your initramfs? /lib/modules/ ... Try looking at the logs or try manual insmod...
Click to expand...
Click to collapse
You mean my operation is not error ?
I mean take a look at the log what cause the operation to fail when you tried to activate wifi. If the module doesn't load, try insmod manually see if it works...
This should be how to operation? I completely understand.Advice about it?
Sorry mate, I don't really get you. When you compile from the source, I believe wifi module should be already turned on in the defconfig. Look at the kernel log or logcat to see what's wrong with your wifi. As for the extfat, take a look at the kernel source from many great developers here on xda. They really helped me a lot compiling my own builds...:good:
Hello,
He seems to have kind of the same problem that I have...
I'm trying to re-compile the boeffla-Kernel for my Galaxy S3 i9300 in order to implement the "aufs"-filesystem.
I've split the boot.img into zImage and ramdisk.gz, opened ramdisk.gz via
Code:
gunzip -c ../ramdisk.gz | cpio -i
and deleted the old zImage.
I patched the boeffla-kernel-source to use "aufs". Then I compiled the Kernel using boeffla_defconfig,
copied the modules into the ramdisk (/lib/modules), repacked it again and I copied the newly compiled zImage
to the same folder.
Finally I did a
Code:
./mkbootimg --kernel ./zImage --ramdisk ./ramdisk.gz --board smdk4x12 --base 0x10000000 --pagesize 2048 -o boot.img
and tarred the resulting boot.img with
Code:
tar cvf kernel.tar.md5 boot.img
.
After I flash it with MobileOdin, the Image boots, "aufs" seems to work but I can not turn on the wifi switch.
Insmod doesn't work and the various suggested workarounds I found through web-search didn't help.
Does anyone have an idea?
greetings
P.S.: Perhaps it would have been better to post this in the dev-section but as I haven't posted the necessary 10 posts I'm not allowed to write to it.
I don't Solved the problems about Wifi.
wctliu said:
I don't Solved the problems about Wifi.
Click to expand...
Click to collapse
Try using different cross-compiler.
So, wctliu, did you solve your problem?

How to pack boot.img for HOV?

Hello there, I have just compiled my first kernel. It is plain vanilla HTC kernel compiled with 4.6 toolchain. Only had to disable some warnings on the Makefile to get it compiled.
But now I am having trouble in booting this kernel. Trying to boot zImage directly fails, apparently because I am required to pack it with a ramdisk into a .img file.
For that I am using my stock kernel, which is in the file boot-stock.img. My first exercise is to try to unpack and repack the stock rom itself:
Code:
$ ./android_bootimg_tools/unpackbootimg -i kernels/boot-stock.img -o ./my_image/
BOARD_KERNEL_CMDLINE �U�%�xMx���p!���_�Tk����%I�x[�`KkzlW�\y\b~jW(���4�[email protected]�c�
BOARD_KERNEL_BASE 2a01537b
BOARD_PAGE_SIZE -880147008
It also gives me a bunch of files in order to remeber this info:
Code:
$ ls my_image/
boot-stock.img-base boot-stock.img-cmdline boot-stock.img-pagesize boot-stock.img-ramdisk.gz boot-stock.img-zImage
Im am pretty sure "base", "page_size" and "cmdline" info will be required in order to repack:
Code:
$ ./android_bootimg_tools/mkbootimg
error: no output filename specified
usage: mkbootimg
--kernel <filename>
--ramdisk <filename>
[ --second <2ndbootloader-filename> ]
[ --cmdline <kernel-commandline> ]
[ --board <boardname> ]
[ --base <address> ]
[ --pagesize <pagesize> ]
[ --ramdiskaddr <address> ]
-o|--output <filename>
However, I can't seem to be able to figure out the command I should use to repack. My first try would be to use
Code:
$ ./android_bootimg_tools/mkbootimg --kernel primou-ics-crc-3.0.16-133e482/primou-ics-crc-3.0.16-133e482/arch/arm/boot/zImage --ramdisk my_image/boot-stock.img-ramdisk.gz --base $(cat my_image/boot-stock.img-base) --cmdline $(cat my_image/boot-stock.img-cmdline) --pagesize $(cat my_image/boot-stock.img-pagesize) -o test.img
error: unsupported page size -880147008
Well, this is unsurprising, I can't figure out a meaning for a negative pag size, whatever it is supposed to mean.
Code:
$ ./android_bootimg_tools/mkbootimg --kernel primou-ics-crc-3.0.16-133e482/primou-ics-crc-3.0.16-133e482/arch/arm/boot/zImage --ramdisk my_image/boot-stock.img-ramdisk.gz --base $(cat my_image/boot-stock.img-base) --cmdline $(cat my_image/boot-stock.img-cmdline) -o test.img
This now succeeds, but the image stucks at "HTC quietly brilliant screen", with the small red text.
.
What am I doing wrong here? I presume it is the page size, which is the correct setting for HOV?
Best,
Elias.
eshneto said:
What am I doing wrong here? I presume it is the page size, which is the correct setting for HOV?
Best,
Elias.
Click to expand...
Click to collapse
I see, the splitting program is doing something wrong, nothing seems to make sense: commando line is rubbish as well.
Also, it seems to be the wrong forum for this. Sorry.
Got it!
eshneto said:
I see, the splitting program is doing something wrong, nothing seems to make sense: commando line is rubbish as well.
Also, it seems to be the wrong forum for this. Sorry.
Click to expand...
Click to collapse
OK, last post. Only to mention I got it working. First off abootimg tool is much more sensible, but this would still not work. Apparently HTC signs its images and I had to trim the file up to the beginning of the ANDROID! magic string. Afterwards, everything went on smooth, abootimg has a nice man page.
I am already the kernel I have compiled. Of course wifi does not work yet, but this is minor. Will test the module now. Next step is adding swipe to wake and then, if all stability tests go OK, move on to OC and VDD.
This is going to be the simplest kernel ever: stock plus s2w and OC/VDD.
Then I will port KitKat to HOV
eshneto said:
OK, last post. Only to mention I got it working. First off abootimg tool is much more sensible, but this would still not work. Apparently HTC signs its images and I had to trim the file up to the beginning of the ANDROID! magic string. Afterwards, everything went on smooth, abootimg has a nice man page.
I am already the kernel I have compiled. Of course wifi does not work yet, but this is minor. Will test the module now. Next step is adding swipe to wake and then, if all stability tests go OK, move on to OC and VDD.
This is going to be the simplest kernel ever: stock plus s2w and OC/VDD.
Then I will port KitKat to HOV
Click to expand...
Click to collapse
I used this for packing boot.img
Code:
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x13f00000 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=primou' --pagesize 4096 -o new_boot.img
You should mention that wifi module should be replaced by yours in ramdisk,the initramfs.cpio.gz
you did it for CM or Sense? 4.0.3? 4.1.2?
It isn't Q&A forum...
Wysłane z mojego HTC One V przy użyciu Tapatalka

Can't compile Galaxy Note 3 Kernel

I am kinda new to kernel development. I need to rebuild the kernel I'm using ((http://forum.xda-developers.com/showthread.php?t=2480353) Compulsion Kernel) with loadable module support. I have also tried other kernels. I also tried using the "-i" flag on make, but the errors kept getting worse, until the whole compilation output was errors...
I keep getting errors from the console output. For example:
Code:
net/bluetooth/hci_conn.c: In function 'hci_le_ltk_reply':
net/bluetooth/hci_conn.c:406:28: warning: argument to 'sizeof' in 'memcpy' call is the same pointer type '__u8 *' as the destination; expected '__u8' or an explicit length [-Wsizeof-pointer-memaccess]
error, forbidden warning: hci_conn.c:406
make[2]: [net/bluetooth/hci_conn.o] Error 1
-Wsizeof-pointer-memaccess errors pop up very often.
There are also file not found errors:
Code:
arm-eabi-ld: error: cannot open net/bluetooth/hci_conn.o: No such file or directory
make[2]: [net/bluetooth/bluetooth.o] Error 1
LD net/bluetooth/built-in.o
arm-eabi-ld: error: cannot open net/bluetooth/bluetooth.o: No such file or directory
make[2]: [net/bluetooth/built-in.o] Error 1
CC net/bridge/br_input.o
Heres another example:
Code:
CC net/bridge/br_ioctl.o
arch/arm/mach-msm/board-8974-sec.c:569:13: warning: 'modem_power_off' defined but not used [-Wunused-function]
error, forbidden warning: board-8974-sec.c:569
make[1]: [arch/arm/mach-msm/board-8974-sec.o] Error 1
LD arch/arm/mach-msm/built-in.o
CC drivers/gpu/ion/ion_cma_heap.o
arm-eabi-ld: error: cannot open arch/arm/mach-msm/bam_dmux.o: No such file or directory
arm-eabi-ld: error: cannot open arch/arm/mach-msm/board-8974-sec.o: No such file or directory
System information:
I attached my .config file. It is the default from the Compulsion kernel.
Compile commands (in order):
Code:
export VARIANT_DEFCONFIG=msm8974_sec_defconfig ##I added this because it wont generate .config if this variable is empty...
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=/home/julian/android-toolchain-eabi/bin/arm-eabi-
git pull
make clean
make msm8974_sec_defconfig
make -j4
Operating system: Fresh install of Linux Mint 16 (Petra)
Build-related packages I installed with apt: git-core, gnupg, flex, bison, gperf, libsdl-dev, libesd0-dev, libwxgtk2.6-dev, build-essential, zip, curl, libncurses5-dev, zlib1g-dev, ia32-libs, lib32z1-dev, lib32ncurses5-dev, gcc-multilib, g++-multilib, and Adb
Toolchain:
Tried linaro, the android NDK from Google's website, and various other toolchains. Same error.
Output of "echo $PATH"
Code:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/julian/android-toolchain-eabi/bin:/home/julian/androidkernel/N900T_Kernel
I think thats all the needed information
Thank you!
Your command for the configuration is incomplete. You need to type a command for the other files as well. Type this command "make msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_hltetmo_defconfig DEBUG_DEFCONFIG= SELINUX_DEFCONFIG=selinux_defconfig SELINUX_LOG_DEFCONFIG=selinux_log_defconfig TIMA_DEFCONFIG=tima_defconfig".
djintrigue808 said:
Your command for the configuration is incomplete. You need to type a command for the other files as well. Type this command "make msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_hltetmo_defconfig DEBUG_DEFCONFIG= SELINUX_DEFCONFIG=selinux_defconfig SELINUX_LOG_DEFCONFIG=selinux_log_defconfig TIMA_DEFCONFIG=tima_defconfig".
Click to expand...
Click to collapse
Still can't compile
No more file not found errors, but still getting:
Code:
arch/arm/mach-msm/bam_dmux.c: In function 'show_waketime':
arch/arm/mach-msm/bam_dmux.c:2440:29: warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
error, forbidden warning: bam_dmux.c:2440
make[1]: *** [arch/arm/mach-msm/bam_dmux.o] Error 1
make: *** [arch/arm/mach-msm] Error 2
make: *** Waiting for unfinished jobs....
My compile script (easier then entering commands...)
#!/bin/bash
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
if [[ "$PATH" == *"/home/julian/android-toolchain-eabi/bin"* ]]; then
echo "PATH Contains toolchain"
else
export PATH=$PATH:/home/julian/android-toolchain-eabi/bin
echo "Toolchain added to PATH!"
fi
git pull
make clean -j4
echo "Building config..."
sleep 2
make msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_hltetmo_defconfig DEBUG_DEFCONFIG= SELINUX_DEFCONFIG=selinux_defconfig SELINUX_LOG_DEFCONFIG=selinux_log_defconfig TIMA_DEFCONFIG=tima_defconfig -j4
sleep 1
read -p "Customize config? (Y/N): " yesno
if [ "$yesno" == "Y" ]; then
make menuconfig -j4
make -j4
else
make -j4
fi
Thank you!
Julian90090 said:
Still can't compile
No more file not found errors, but still getting:
Code:
arch/arm/mach-msm/bam_dmux.c: In function 'show_waketime':
arch/arm/mach-msm/bam_dmux.c:2440:29: warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
error, forbidden warning: bam_dmux.c:2440
make[1]: *** [arch/arm/mach-msm/bam_dmux.o] Error 1
make: *** [arch/arm/mach-msm] Error 2
make: *** Waiting for unfinished jobs....
My compile script (easier then entering commands...)
#!/bin/bash
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
if [[ "$PATH" == *"/home/julian/android-toolchain-eabi/bin"* ]]; then
echo "PATH Contains toolchain"
else
export PATH=$PATH:/home/julian/android-toolchain-eabi/bin
echo "Toolchain added to PATH!"
fi
git pull
make clean -j4
echo "Building config..."
sleep 2
make msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_hltetmo_defconfig DEBUG_DEFCONFIG= SELINUX_DEFCONFIG=selinux_defconfig SELINUX_LOG_DEFCONFIG=selinux_log_defconfig TIMA_DEFCONFIG=tima_defconfig -j4
sleep 1
read -p "Customize config? (Y/N): " yesno
if [ "$yesno" == "Y" ]; then
make menuconfig -j4
make -j4
else
make -j4
fi
Thank you!
Click to expand...
Click to collapse
Ok so I was messing around and decided to fix the -Wsizeof-pointer-memaccess errors. I opened bam_dmux.c and changed the line
Code:
return snprintf(buf, sizeof(buf), "%u\n", wakelock_timeout);
to
Code:
return snprintf(buf, (int)sizeof(buf), "%u\n", wakelock_timeout);
The kernel compiles now, but when I flash it to my device (mkbootimg), I get a ODIN message saying regular boot failed...
MORE UPDATES:
Tried flashing plain zImage in tar with ODIN, got a "unsupport dev_type" error on the device.
I fixed all the compile errors. I changed cross compilers to arm linux gnueabihf 4.7. There is still the task of getting the kernel on the device though... Thanks in advance!
EDIT AGAIN: Still can't get it to boot. Tried compiling stock kernel, leankernel, and Saber kernel. All same result after packing zImage and flashing with flashable zip...
Using repack-zImage.sh, I get a "gunzip result is oscillating between 'too small' and 'too large' at size: 7836575 7836576 7836577 7836578" error. There are no compile errors with any of the kernels. I attached my "finished" stock kernel flashable zip (doesn't work). I heard something about a mismatch between gzip and lzop... *feeling determined*
Any ideas?
EDIT:
Compile warnings about swp{b} although swp emulation is enabled in config. I still can't figure out how to get the zImage to work correctly on my device. I swapped the zImage out of the Saber kernel install zip boot.img and put my own in, flashed with TWRP, device doesn't boot until I go back and install the original kernel.
Julian90090 said:
Still can't compile
No more file not found errors, but still getting:
Code:
arch/arm/mach-msm/bam_dmux.c: In function 'show_waketime':
arch/arm/mach-msm/bam_dmux.c:2440:29: warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
error, forbidden warning: bam_dmux.c:2440
make[1]: *** [arch/arm/mach-msm/bam_dmux.o] Error 1
make: *** [arch/arm/mach-msm] Error 2
make: *** Waiting for unfinished jobs....
My compile script (easier then entering commands...)
#!/bin/bash
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=arm-eabi-
if [[ "$PATH" == *"/home/julian/android-toolchain-eabi/bin"* ]]; then
echo "PATH Contains toolchain"
else
export PATH=$PATH:/home/julian/android-toolchain-eabi/bin
echo "Toolchain added to PATH!"
fi
git pull
make clean -j4
echo "Building config..."
sleep 2
make msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_hltetmo_defconfig DEBUG_DEFCONFIG= SELINUX_DEFCONFIG=selinux_defconfig SELINUX_LOG_DEFCONFIG=selinux_log_defconfig TIMA_DEFCONFIG=tima_defconfig -j4
sleep 1
read -p "Customize config? (Y/N): " yesno
if [ "$yesno" == "Y" ]; then
make menuconfig -j4
make -j4
else
make -j4
fi
Thank you!
Click to expand...
Click to collapse
Please ignore if irrelevant or ignorant. I'm in my infancy and still grasping the basics.
My environment is quite different than yours, on a Mac and using a Sprint note 3, but I came across this thread with the same compiler error using the 4.8 tools in the NDK. If I use 4.6 gcc I make it pretty far into the compilation process before error (failing @net/netfilter/xt_TCPMSS.c). However, using 4.8 gave me the same error as you:
Code:
arch/arm/mach-msm/bam_dmux.c: In function 'show_waketime':
arch/arm/mach-msm/bam_dmux.c:2440:29: warning: argument to 'sizeof' in 'snprintf' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
error, forbidden warning: bam_dmux.c:2440
make[1]: *** [arch/arm/mach-msm/bam_dmux.o] Error 1
make: *** [arch/arm/mach-msm] Error 2
Here's the layout of my toolchains folder and my broken build file (looks like yours)
Code:
z:toolchains anon$ pwd
/Volumes/android/ndk/toolchains
z:toolchains anon$ ls arm-linux-androideabi-4.*/prebuilt/darwin-x86_64/arm-linux-androideabi/bin
arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/arm-linux-androideabi/bin:
ar c++ gcc ld.bfd ld.mcld objcopy ranlib
as g++ ld ld.gold nm objdump strip
arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/arm-linux-androideabi/bin:
ar c++ gcc ld.bfd ld.mcld objcopy ranlib
as g++ ld ld.gold nm objdump strip
Broken Make file edit:
Code:
CROSS_COMPILE ?= /Volumes/android/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
Change to 4.6 for new compile error:
Code:
CROSS_COMPILE ?= /Volumes/android/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
Made is a helluva lot father in the compilation process, but still won't compile correctly.
Code:
net/netfilter/xt_TCPMSS.c:50:8: warning: 'struct xt_tcpmss_info' declared inside parameter list [enabled by default]
error, forbidden warning: xt_TCPMSS.c:50
make[2]: *** [net/netfilter/xt_TCPMSS.o] Error 1
make[1]: *** [net/netfilter] Error 2
make: *** [net] Error 2
Got my NDK from here:
Code:
http://dl.google.com/android/ndk/android-ndk-r9c-darwin-x86_64.tar.bz2
I don't, yet, understand the differences between the versions. Not sure if this will be helpful, samsungs open source community page sure isn't very friendly.
Julian90090 said:
Ok so I was messing around and decided to fix the -Wsizeof-pointer-memaccess errors. I opened bam_dmux.c and changed the line
Code:
return snprintf(buf, sizeof(buf), "%u\n", wakelock_timeout);
to
Code:
return snprintf(buf, (int)sizeof(buf), "%u\n", wakelock_timeout);
The kernel compiles now, but when I flash it to my device (mkbootimg), I get a ODIN message saying regular boot failed...
MORE UPDATES:
Tried flashing plain zImage in tar with ODIN, got a "unsupport dev_type" error on the device.
I fixed all the compile errors. I changed cross compilers to arm linux gnueabihf 4.7. There is still the task of getting the kernel on the device though... Thanks in advance!
EDIT AGAIN: Still can't get it to boot. Tried compiling stock kernel, leankernel, and Saber kernel. All same result after packing zImage and flashing with flashable zip...
Using repack-zImage.sh, I get a "gunzip result is oscillating between 'too small' and 'too large' at size: 7836575 7836576 7836577 7836578" error. There are no compile errors with any of the kernels. I attached my "finished" stock kernel flashable zip (doesn't work). I heard something about a mismatch between gzip and lzop... *feeling determined*
Click to expand...
Click to collapse
I dunno if it is still relevant to you, but in your code change this
Code:
return snprintf(buf, sizeof(buf), "%u\n", wakelock_timeout);
to this
Code:
return snprintf(buf, sizeof([COLOR="Red"]*[/COLOR]buf), "%u\n", wakelock_timeout);
Do that for all the files you get error in.
This error is because the toolchain you are using is higher version than GCC 4.8.*
Use any lower GCC version toolchain and those changes are not needed.
If you want the newer cross compiler, You need to make the cnanges. I hope this helps...
Cheers!!!
daxgirl said:
I dunno if it is still relevant to you, but in your code change this
Code:
return snprintf(buf, sizeof(buf), "%u\n", wakelock_timeout);
to this
Code:
return snprintf(buf, sizeof([COLOR="Red"]*[/COLOR]buf), "%u\n", wakelock_timeout);
Do that for all the files you get error in.
This error is because the toolchain you are using is higher version than GCC 4.8.*
Use any lower GCC version toolchain and those changes are not needed.
If you want the newer cross compiler, You need to make the cnanges. I hope this helps...
Cheers!!!
Click to expand...
Click to collapse
I did the same thing; i.e. I added (int) to the line also. The compiler seems to be ok with it, but I have not installed it on a device yet. I actually see a number of these errors. Do you think there should be another fix for it perhaps? Did you findout anything else about this? I appreciate a reply.
sansari123 said:
I did the same thing; i.e. I added (int) to the line also. The compiler seems to be ok with it, but I have not installed it on a device yet. I actually see a number of these errors. Do you think there should be another fix for it perhaps? Did you findout anything else about this? I appreciate a reply.
Click to expand...
Click to collapse
Yeah there is another fix. You add flags to your makefile for the cross cimpiler to basically accept those. Since they are not errors. Than you can use any chain. I managed to compile on sabermod 4.10 a kernel for s5, which was giving me the same trouble. Once I upload my sources I will send you a link to the repo so you can tweak your makefile accordingly ?
Sent from my SM-G900F using Tapatalk
Thanks. The latest message I get is the following:
Code:
drivers/cpufreq/cpufreq_interactive.c: In function 'show_target_loads':
drivers/cpufreq/cpufreq_interactive.c:813:6: warning: operation on 'ret' may be undefined [-Wsequence-point]
error, forbidden warning: cpufreq_interactive.c:813
make[2]: *** [drivers/cpufreq/cpufreq_interactive.o] Error 1
make[1]: *** [drivers/cpufreq] Error 2
make: *** [drivers] Error 2
But this one is a warning also. I guess there is a flag for ignoring warning(s)? I'll wait to hear back from you.
daxgirl said:
Yeah there is another fix. You add flags to your makefile for the cross cimpiler to basically accept those. Since they are not errors. Than you can use any chain. I managed to compile on sabermod 4.10 a kernel for s5, which was giving me the same trouble. Once I upload my sources I will send you a link to the repo so you can tweak your makefile accordingly ?
Sent from my SM-G900F using Tapatalk
Click to expand...
Click to collapse
@daxgirl - I like to learn how to modify the flags. Did you find out which flags to modify by reading the Makefile documentation? I would really appreciate it if you tell me how I can learn which flags to modify and do it myself vs. copy your Makefile.

[Solved]Help appreciated on compiling PixelC kernel, after flashing cannot boot

Solved, thanks for the reply!
I'm nearly sure your problem is when you generate the fit imagine using the dtb files (notably lz4 compression). Because the signing part and the kernel compilation seem OK.
Maybe @followmsi or @cheep5k8 have an idea. I'm very interested by this too !
This can help you too !
http://forum.xda-developers.com/pixel-c/help/unpack-repack-boot-img-info-to-build-t3367835
Samt434 said:
I'm nearly sure your problem is when you generate the fit imagine using the dtb files (notably lz4 compression). Because the signing part and the kernel compilation seem OK.
Maybe @followmsi or @cheep5k8 have an idea. I'm very interested by this too !
This can help you too !
http://forum.xda-developers.com/pixel-c/help/unpack-repack-boot-img-info-to-build-t3367835
Click to expand...
Click to collapse
Thanks for the reply
hqdvista said:
Solved, thanks for the reply!
Click to expand...
Click to collapse
How did you solved this finally ?
hqdvista said:
Thanks for the reply, yes I have read that thread and followed the instructions, but seems not working though
Click to expand...
Click to collapse
Yes, how did you finally solve it ?
I think, like mentioned here too, it's the already compressed kernel.
Let the generate-its-script.sh script do the compression for you.
Cheers
followmsi said:
Yes, how did you finally solve it ?
I think, like mentioned here too, it's the already compressed kernel.
Let the generate-its-script.sh script do the compression for you.
Cheers
Click to expand...
Click to collapse
Yes absolutely is this point.
pixel-c won't boot after flashing my custom kernel
Hi @hqdvista
Could you please share what step exactly was wrong in:
https://bbs.archlinux.org/viewtopic.php?id=207385
and
http://forum.xda-developers.com/pixel-c/help/unpack-repack-boot-img-info-to-build-t3367835
I have tried everything mentioned on these links with NRD90R kernel source but boot is stuck at "Google" logo:
# checked out "3.18.0-gc66b63e" branch which is the kernel version reported
# built kernel for dragon_defconfig following https://bbs.archlinux.org/viewtopic.php?id=207385
# lz4 -20 -z -f kernel/arch/arm64/boot/Image Image.lz4
# Generated Image.fit with or without including .dtb files, with built Image.gz and with uncompressed Image:
./generate-its-script.sh -a arm64 Image.lz4 kernel/arch/arm64/boot/dts/tegra/*.dtb | dtc -I dts -O dtb -p 1024 > Image.fit
OR
./generate-its-script.sh -a arm64 Image.lz4 | dtc -I dts -O dtb -p 1024 > Image.fit
OR
./generate-its-script.sh -a arm64 kernel/arch/arm64/boot/Image[or Image.gz] | dtc -I dts -O dtb -p 1024 > Image.fit
# Use ramdisk from Android build tree out/target/product/dragon/ramdisk.img
mkbootimg --kernel Image.fit --ramdisk ramdisk.img --output boot.img.unsigned
And finally:
# futility vbutil_keyblock --pack boot.img.keyblock --datapubkey kernel_data_key.vbpubk --signprivate kernel_data_key.vbprivk
# futility vbutil_kernel --pack boot.img --keyblock boot.img.keyblock --signprivate kernel_data_key.vbprivk --version 1 --vmlinuz boot.img.unsigned --config empty --arch arm --bootloader empty --flags 0x1
but pixel-c doesn't boot, as soon as I use NRD90R prebuilt device/google/dragon-kernel/Image.fit in mkbootimg cmd, the boot.img works.
Appreciate any suggestions!
nvm, figured, compression type needs to be supplied to the script:
./generate-its-script.sh -a arm64 -c lz4 kernel/arch/arm64/boot/Image | dtc -I dts -O dtb -p 1024 > Image.fit

Categories

Resources