Build tun.ko for HTC IS - HTC Incredible S

Here is the steps that how I built the tun.ko for my Incredible S(first of all, you need to root your IS)
My IS kernel version: 2.6.35.9-g529446e
Environment: Ubuntu 11.10 Desktop runing on Virtual Box
Kernel source code: vivo-2.6.35-GB_MR.tar.bz2
Dowloaded in htcdev website,
(I tried vivo-2.6.35-g89aa373,it was sucessful to compile and load tun.ko,but my phone reboot automatic once I ran VPNC)
Compiler: arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
Downloaded from sourcery.mentor.com/sgpp/lite/arm/portal/[email protected]=lite
(I tried Android NDK,android-ndk-r6b和android-ndk-r5c, it is fine to compile tun.ko,but get "tun: unknown relocation: 3" error when I ran insmod tun.ko)
1. In Ubuntu terminal,I created folder 710e under home directory, uncompress kernel source code and compiler,
tar zvxf vivo-2.6.35-GB_MR.tar.bz2
tar jvxf arm-2011.03-41-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
the files were put in vivo_GB_MR and arm-2011.03 by default;
2. Get config.gz file:I did this in my Windows 7
Install HTC Sync on Windows, connect IS to PC by USB cable, run below in command line,
adb pull /proc/config.gz
3. transfer config.gz to ~/710/vivo_GB_MR/ in Ubuntu(the rest commands were run in this path)
gunzip config.gz
mv config .config
edit .config, change or add "CONFIG_TUN=m" in .config
4. Modify Makefile
edit Makefile, change "EXTRAVERSION=.9-g529446e" in Makefile
5. run below commands,
export PATH=$PATH:~/710e/arm-2011.03/bin
export ARCH=arm
export CROSS_COMPILE=arm-none-linux-gnueabi-
make modules
Then I got tun.ko under ~/710/vivo_GB_MR/drivers/net/, I ran below command to check and confirm if the tun.ko version is correct,
strings drivers/net/tun.ko | grep 2.6.35
My output was: vermagic=2.6.35.9-g529446e preempt mod_unload ARMv7
6. copy tun.ko to MicroSD card,run below commands in adb on Windows or terminal emulator on phone,
su
mount -o remount,rw /dev/block/mtdblock4 /system
cp /sdcard/tun.ko /system/lib/modules/tun.ko
mount -o remount,ro /dev/block/mtdblock4 /system
insmod /system/lib/modules/tun.ko
tun.ko should be loaded if everything is fine, you can run lsmod check; and you can run dmesg | grep tun to check the error mesage if it goes wrong.

Hi, thanks for your wonderful Guide, i've tried to compile a tun.ko for my htc Flyer under ubuntu 12.04 booted from a Live-USB-Stick, but it doesn't work. I get this output on Step 5:
Code:
[email protected]:/media/Daten/ubuntu/flyer-2.6.35-crc$ export PATH=$PATH:/media/Daten/ubuntu/arm-2011.03/bin
[email protected]:/media/Daten/ubuntu/flyer-2.6.35-crc$ export ARCH=arm
[email protected]:/media/Daten/ubuntu/flyer-2.6.35-crc$ export CROSS_COMPILE=arm-none-linux-gnueabi-
[email protected]:/media/Daten/ubuntu/flyer-2.6.35-crc$ make modules
make: execvp: arm-none-linux-gnueabi-gcc: Keine Berechtigung
HOSTCC scripts/basic/fixdep
/bin/sh: 1: scripts/basic/fixdep: Permission denied
make[2]: *** [scripts/basic/fixdep] Fehler 126
make[1]: *** [scripts_basic] Fehler 2
The present kernel configuration has modules disabled.
Type 'make config' and enable loadable module support.
Then build a kernel with module support enabled.
make: *** [modules] Fehler 1
[email protected]:/media/Daten/ubuntu/flyer-2.6.35-crc$
I've also tried the Compiler-Version arm-2011.09, but same result. I think I have to edit antoher variable in the .config-File, but which?

I doubt it is related to the Ubuntu booted from Live-USB-Stick, maybe you should install the Ubuntu to your harddisk and have another try.

Ok, another try, another fail.
I've installed ubuntu on my Laptop, and i get a bit further: Another output.
Code:
[email protected]:~/Flyer/flyer-2.6.35-crc$ make modules
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/docproc
HOSTCC scripts/basic/hash
HOSTCC scripts/kconfig/conf.o
scripts/kconfig/conf.c: In Funktion »conf_sym«:
scripts/kconfig/conf.c:159:6: Warnung: Variable »type« gesetzt, aber nicht verwendet [-Wunused-but-set-variable]
scripts/kconfig/conf.c: In Funktion »conf_choice«:
scripts/kconfig/conf.c:231:6: Warnung: Variable »type« gesetzt, aber nicht verwendet [-Wunused-but-set-variable]
scripts/kconfig/conf.c:307:9: Warnung: Der Rückgabewert von »fgets«, der mit dem Attribut warn_unused_result deklariert wurde, wird ignoriert [-Wunused-result]
scripts/kconfig/conf.c: In Funktion »conf_askvalue«:
scripts/kconfig/conf.c:105:8: Warnung: Der Rückgabewert von »fgets«, der mit dem Attribut warn_unused_result deklariert wurde, wird ignoriert [-Wunused-result]
HOSTCC scripts/kconfig/kxgettext.o
SHIPPED scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf -s arch/arm/Kconfig
.config:1110:warning: override: reassigning to symbol TUN
#
# configuration written to .config
#
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
GEN include/generated/bounds.h
CC arch/arm/kernel/asm-offsets.s
GEN include/generated/asm-offsets.h
CALL scripts/checksyscalls.sh
CC scripts/mod/empty.o
HOSTCC scripts/mod/mk_elfconfig
MKELF scripts/mod/elfconfig.h
HOSTCC scripts/mod/file2alias.o
HOSTCC scripts/mod/modpost.o
HOSTCC scripts/mod/sumversion.o
HOSTLD scripts/mod/modpost
HOSTCC scripts/kallsyms
HOSTCC scripts/bin2c
CC [M] drivers/net/wireless/bcm4329_204/dhd_linux.o
drivers/net/wireless/bcm4329_204/dhd_linux.c: In function 'dhd_rx_frame':
drivers/net/wireless/bcm4329_204/dhd_linux.c:1082:24: error: variable 'save_pktbuf' set but not used [-Werror=unused-but-set-variable]
drivers/net/wireless/bcm4329_204/dhd_linux.c: In function 'dhd_os_wd_timer':
drivers/net/wireless/bcm4329_204/dhd_linux.c:2555:14: error: variable 'save_dhd_watchdog_ms' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[4]: *** [drivers/net/wireless/bcm4329_204/dhd_linux.o] Fehler 1
make[3]: *** [drivers/net/wireless/bcm4329_204] Fehler 2
make[2]: *** [drivers/net/wireless] Fehler 2
make[1]: *** [drivers/net] Fehler 2
make: *** [drivers] Fehler 2
But i've seen that the source of the Flyer has the ending ".tar.gz" instead of ".tar.bz2", so I tried to extract it via the commands
Code:
gunzip
tar xvf
The output isn't longer in the Terminal, but it generates a tun.o-File. The pasted output generates nothing, there is just the tun.c-File.

Related

[Q] Well, I'm stuck. Make errors...

I can't seem to catch a break...
I haven't been able to compile anything with my build environment. For at least a few weeks. I know it should work, because I compiled a build of WD40M0D prior to all my merging of source. I'm using a MacBookPro running OS X 10.5.8
When trying to build a kernel, I get errors on "bounds.s" and "prepare0":
Code:
sean-whitleys-macbook-pro:kernel-msm wdfowty$ make ARCH=arm CROSS_COMPILE=$CCOMPILER
scripts/kconfig/conf -s arch/arm/Kconfig
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
cc1: error: invalid option ‘little-endian’
cc1: error: invalid option ‘abi=aapcs-linux’
cc1: error: invalid option ‘no-thumb-interwork’
kernel/bounds.c:1: error: bad value (armv5t) for -march= switch
kernel/bounds.c:1: error: bad value (armv5t) for -mtune= switch
make[1]: *** [kernel/bounds.s] Error 1
make: *** [prepare0] Error 2
My next error, if I skip the kernel, is in building libgps.so...It claims to not be able to find librpc.so, which to the best of my knowledge is where it's supposed to be (somewhere in the out directory).
Code:
#
/Users/wdfowty/bin/mydroid/prebuilt/darwin-x86/toolchain/arm-eabi-4.4.0/bin/../lib/gcc/arm-eabi/4.4.0/../../../../arm-eabi/bin/ld: warning: librpc.so, needed by out/target/product/passion/obj/lib/libgps.so, not found (try using -rpath or -rpath-link)
Some things I've noticed...
*Kernel error is constant across AOSP and CM source (could it be a bad .config?)
*Errors persist even after running "make clobber" or "make installclean"
I'm hoping someone can help, as I'm running on minimal knowledge and experience...Thank you in advance!
Here's the full librpc.so error on pastebin: http://pastebin.com/VBtAffE0

[Q] how to compile a driver/kernel ?

how to compile a driver ? SLOVE
i have problem after,,
#cp arch/arm/configs/htc_msm_android_defconfig .config
#make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- TARGET_BOARD_PLATFORM=msm7k
make: arm-none-linux-gnueabi-gcc: Command not found
scripts/kconfig/conf -s arch/arm/Kconfig
make: arm-none-linux-gnueabi-gcc: Command not found
CHK include/linux/version.h
make[1]: `include/asm-arm/mach-types.h' is up to date.
CHK include/linux/utsrelease.h
CC kernel/bounds.s
/bin/sh: arm-none-linux-gnueabi-gcc: command not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
slove after download
codesourcery......com/sgpp/lite/arm/portal/package5383/public/arm-none-linux-gnueabi/arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

[Tutorial][Kernel]How-to: Compile a kernel for P68XX

I know there are a lot of tutorial to compile an Android Kernel but samsung is known to release buggy kernels and none of them tells how to deal with error.
Sources:
- a bunch of others kernel building tutorial on xda (like this one : http://forum.xda-developers.com/archive/index.php/t-1557045.html)
First and foremost, you MUST use a GNU/Linux (hereafter 'Linux') distribution. Don’t use OSX or Cygwin, I got a lot of problem with them.
The easiest way is to get the latest version of Ubuntu Linux. I personally, I’m using archlinux but the installation is a bit complex for this kind of use only.
Step 0: Pre-project Setup (optionnal)
This link will help you to use the main android commands into your newly linux environment: [SCRIPT] [Ubuntu] ADB, AAPT, APKTool, Android SDK/NDK, and udev rules auto-installer
I did not use them for this but it could be useful sometime in other tasks
Step 1: Setting up a build environment
First, you will need to install the required packages:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev g++-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev git
Some of these packages won’t work but normally dependencies will be resolved by apt the package manager.
Next, you will need a Cross-Compile Toolchain, and for our purposes we will be using this specifically CodeSourcery release (2009q3):
Untar it either in /opt (with su permission) or create of directory for it.
Code:
cd ~/
tar xvjf arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
It’s very important for the P68XX kernel to use this toolchain. Otherwise, you’ll have errors while compiling it and trust me, you don’t want this type of errors (look at my mdnie.c (insérer lien) thread for example). As a matter fact, I tried all of the toolchains given by the mentor website and only this one works on my linux.
Step 2: Pulling the Kernel Source
Now, we have to download the kernel from: [url=http://opensource.samsung.com/index.jsp;jsessionid=0EFA22A80FBED4451C1D9C823E3440C4[/url]
You will have an archive unzip it and copy the kernel part into the kernel_P68XX and then untar it.
Code:
mkdir ~/kernel_P68XX
tar xvf Kernel.tar.gz -C ~/kernel_P68XX
You can remove it if you want.
Code:
rm Kernel.tar.gz
Now you have to download and extract the initrd from the samsung zImage found in the official ICS image :
For the UK P6810[url=http://www.hotfile.com/dl/165045602/118260c/P6810XXLPL_P6810OXALPL_XEU.zip.html[/url]
For the Open Austria P6800 [url=http://www.hotfile.com/dl/166221509/de0b31d/P6800XXLQ2_P6800OXALQ2_ATO.zip.html[/url]
Download the zip, unzip it, untar it and copy the zImage as followed.
Then, download also and use unpack-initramfs (both files are attached at the end of this thread).
Code:
mkdir ~/initrd
mv zImage ~/initrd
mv unpack-initramfs ~/initrd
cd ~/initrd
Sudo chmod +x unpack-initramfs
./unpack-initramfs zImage
Step 3: Build the Kernel
Finally, what you've been waiting for!
We have to export a few things first, to prepare the build environment. Open a terminal and type:
Code:
export ARCH=arm
export CROSS_COMPILE=~/arm-2009q3/bin/arm-none-linux-gnueabi-
make P8-wifi_defconfig
You’ll have this :
Code:
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED
scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED
scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to
.config
#
Now edit the kernel’s configuration.
Code:
nano .config
Search for
Code:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
Change to
Code:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="../initrd"
Where initrd is the folder where you extracted the zImage initramfs.
Here, you can make substiantials changes to your kernel .This step is really important if you want to customize your kernel (ie : enabling features such as governors, add init.d, cifs, file systems etc.) (we'll see this on the next tutorial). But do it only if you know what you’re doing. Don’t forget to back up your file config (named .config).
Now you can build it.
Code:
make –jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Now, watch the output at the end carefully and you'll see the necessary files that we need:
Code:
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
AS arch/arm/boot/compressed/head.o
GZIP arch/arm/boot/compressed/piggy.gzip
AS arch/arm/boot/compressed/piggy.gzip.o
CC arch/arm/boot/compressed/misc.o
CC arch/arm/boot/compressed/decompress.o
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/lib1funcs.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Building modules, stage 2.
MODPOST 4 modules
CC drivers/net/wireless/ath/ath.mod.o
LD [M] drivers/net/wireless/ath/ath.ko
CC drivers/net/wireless/ath/ath6kl/ath6kl_sdio.mod.o
LD [M] drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko
CC drivers/scsi/scsi_wait_scan.mod.o
LD [M] drivers/scsi/scsi_wait_scan.ko
CC net/wireless_ath/cfg80211.mod.o
LD [M] net/wireless_ath/cfg80211.ko
Anything marked with an [M] will need to be remembered, as well as the location of the compiled kernel at /arch/arm/boot/zImage
Step 4: Dealing with Samsung's errors
Well that would be it, if Samsung had done the job properly but as far as I’m concerned I got three errors :
First one :
Code:
CC drivers/media/video/samsung/mali/common/mali_kernel_core.o
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné: No such file or directory
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné": No such file or directory
cc1: warnings being treated as errors
<command-line>:0: error: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c: In function 'mali_kernel_constructor':
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: expected expression before ')' token
make[5]: *** [drivers/media/video/samsung/mali/common/mali_kernel_core.o]
Erreur 1
make[4]: ***
[drivers/media/video/samsung/mali] Erreur 2
make[3]: ***
[drivers/media/video/samsung] Erreur 2
make[2]: ***
[drivers/media/video] Erreur 2
make[1]: *** [drivers/media]
Erreur 2
make: *** [drivers] Erreur 2
A way to fix this error is to change the SVN version Makefile in drivers/media/video/Samsung/mali/Makefile. I did not dig into it but I’m sure that one of the term return a wrong value. So I changed it to the number : 1. You can assign any value you want as far as it is not a variable.
Code:
nano drivers/media/video/samsung/mali/Makefile
Search for this chain string : SVN, you’ll find this one :
Code:
# Get subversion revision number, fall back to 0000 if no svn info is available
SVN_REV:=$(shell ((svnversion | grep -qv exported && echo -n 'Revision: ' && sv… … …
Replace with:
Code:
SVN=REV:=1
Relaunch the make
Code:
make -jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Second one :
Code:
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné: No such file or directory
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné": No such file or directory
cc1: warnings being treated as errors
<command-line>:0: error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:
In function 'ump_initialize_module': drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:128:
error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:128:
error: expected expression before ')' token
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:
At top level:
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:472:
error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:472:
error: expected expression before ',' token
make[5]: ***
[drivers/media/video/samsung/ump/linux/ump_kernel_linux.o] Erreur 1
make[4]: ***
[drivers/media/video/samsung/ump] Erreur 2
make[3]: ***
[drivers/media/video/samsung] Erreur 2
make[2]: ***
[drivers/media/video] Erreur 2
make[1]: *** [drivers/media]
Erreur 2
make: *** [drivers] Erreur 2
Do exactly the same manipulation as said above :
Modify the Makefile in drivers/media/video/Samsung/ump/Makefile.
Code:
nano drivers/media/video/Samsung/ump/Makefile
Search for this chain string : SVN, you’ll find this one :
Code:
# Get subversion revision number, fall back to 0000 if no svn info is available
SVN_REV:=$(shell ((svnversion | grep -qv exported && echo -n 'Revision: ' && sv… … …
Replace with:
Code:
SVN=REV:=1
Relaunch the make
Code:
make -jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Last error but not the least :
Code:
drivers/video/samsung/lcdfreq.c: In function 'level_store':
drivers/video/samsung/s3cfb.h:262:
sorry, unimplemented: inlining failed in call to 'get_fimd_global': function
body not available
drivers/video/samsung/lcdfreq.c:150:
sorry, unimplemented: called from here
drivers/video/samsung/s3cfb.h:262:
sorry, unimplemented: inlining failed in call to 'get_fimd_global': function
body not available
drivers/video/samsung/lcdfreq.c:176:
sorry, unimplemented: called from here
make[3]: ***
[drivers/video/samsung/lcdfreq.o] Erreur 1
make[2]: ***
[drivers/video/samsung] Erreur 2
make[1]: *** [drivers/video]
Erreur 2
make: *** [drivers] Erreur 2
Fix this is very simple but took me a lot of time. I found the solution in some patch explainations for the mainstream kernel. The only thing you have to do is : remove the word “inline” in this file drivers/video/Samsung/s3cfb.h
Search for this :
Code:
extern struct fb_ops s3cfb_ops;
extern inline struct s3cfb_global *get_fimd_global(int id);
Remove “inline”:
Code:
extern struct fb_ops s3cfb_ops;
extern struct s3cfb_global *get_fimd_global(int id);
Redo the make command :
Code:
make -jX{/code]
Now you’ve got your kernel built but it's not finished yet !
[COLOR="blue"][B]Final Step: Include modules to your kernel[/B][/COLOR]
At first, I was very surprised by this step but it is essential otherwise your kernel won’t work. Actually, modules included by samsung in the initrd uncompressed before are not working as if. So you have to do this :
in the initrd you made, copy the *.ko into initrd/lib/modules
[code] cp drivers/net/wireless/ath/ath.ko drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko drivers/scsi/scsi_wait_scan.ko net/wireless_ath/cfg80211.ko ../initrd/lib/modules
Overwrite them if asked.
Clean your code, use your backup config file and rebuilt the kernel :
Code:
Make distclean
Make clean
Cp your_backup_file kernel_P68XX/.config
make –jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Your final kernel is here : /arch/arm/boot/zImage
Kernel Installation
Flash via heimdall
Code:
$ adb reboot download
$ heimdall flash --kernel path/to/zImage
Maybe there's another way to do this so feel free to leave comments
Good luck !
Thanks for sharing..
Great tut, thanks a lot, will be really helpful. :good:
Thanks man.
Enviado de meu GT-P6800 usando o Tapatalk 2
Thanks guys !
Next to come : Install the kernel via cwm, Kernel optimisations and Build a custom rom for these devices.
Running my first home built kernel. :laugh:
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
I love android.
dedraks said:
Running my first home built kernel. :laugh:
I love android.
Click to expand...
Click to collapse
So cool you did it
Congrats !
Awesome tutorial mengpo, thanks
mengpo said:
Next to come : Install the kernel via cwm
Click to expand...
Click to collapse
Easiest to just flash via heimdall
Code:
$ adb reboot download
$ heimdall flash --kernel path/to/zImage
locerra said:
Easiest to just flash via heimdall
Code:
$ adb reboot download
$ heimdall flash --kernel path/to/zImage
Click to expand...
Click to collapse
:silly:
I did not know it was so simple !!
I'll change the tuto then !
Thanks again !
Thanks a lot !
I havent coded for ages and setting up the environment was discouraging me from even thinking about trying to play with the kernel
This is extremely useful
Alcibiade said:
Thanks a lot !
I havent coded for ages and setting up the environment was discouraging me from even thinking about trying to play with the kernel
This is extremely useful
Click to expand...
Click to collapse
You're welcome
Hi, I stumbled across this thread while trying to set up my environment to do kernel work for another device (S7562, not that it matters). The problem is that my zImage (extracted from stock Samsung ROM) does not contain any gzip archive and I can't extract the initramfs. I am asking here because I also tried using the script attached in the first post without success.
Essentially, my stock zImage does not seem to contain the hexa string "1f 8b 08" in this order. I tried with scripts and I tried it manually as well:
Code:
grep -a -b --only-matching `perl -e'print "\x1F\x8B\x08"'` zImage
That returns nothing for this kernel. Works fine for others though and I've successfully done this procedure using other ROMs from Samsung in the past. I can provide the initial boot.img and the zImage extracted from the boot.img. Let me know.
Edit - SOLVED: My image did not contain the ramdisk zipped, it was just the compiled kernel.
Thanks,
C.
COmpilation Error FOr Redmi 1S India
Plz help me to solve this error
Code:
[email protected]:~/android/kernel$ make zImage
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC drivers/input/touchscreen/ft5x06_ts.o
drivers/input/touchscreen/ft5x06_ts.c: In function 'ft5x06_get_factory_id':
drivers/input/touchscreen/ft5x06_ts.c:432:45: warning: 'ft5336_bootloader_ver' may be used uninitialized in this function [-Wuninitialized]
error, forbidden warning: ft5x06_ts.c:432
make[3]: *** [drivers/input/touchscreen/ft5x06_ts.o] Error 1
make[2]: *** [drivers/input/touchscreen] Error 2
make[1]: *** [drivers/input] Error 2
make: *** [drivers] Error 2
mengpo said:
I know there are a lot of tutorial to compile an Android Kernel but samsung is known to release buggy kernels and none of them tells how to deal with error.
Sources:
- a bunch of others kernel building tutorial on xda (like this one : http://forum.xda-developers.com/archive/index.php/t-1557045.html)
First and foremost, you MUST use a GNU/Linux (hereafter 'Linux') distribution. Don’t use OSX or Cygwin, I got a lot of problem with them.
The easiest way is to get the latest version of Ubuntu Linux. I personally, I’m using archlinux but the installation is a bit complex for this kind of use only.
Step 0: Pre-project Setup (optionnal)
This link will help you to use the main android commands into your newly linux environment: [SCRIPT] [Ubuntu] ADB, AAPT, APKTool, Android SDK/NDK, and udev rules auto-installer
I did not use them for this but it could be useful sometime in other tasks
Step 1: Setting up a build environment
First, you will need to install the required packages:
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev g++-multilib lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev git
Some of these packages won’t work but normally dependencies will be resolved by apt the package manager.
Next, you will need a Cross-Compile Toolchain, and for our purposes we will be using this specifically CodeSourcery release (2009q3):
Untar it either in /opt (with su permission) or create of directory for it.
Code:
cd ~/
tar xvjf arm-2009q3-68-arm-none-eabi-i686-pc-linux-gnu.tar.bz2
It’s very important for the P68XX kernel to use this toolchain. Otherwise, you’ll have errors while compiling it and trust me, you don’t want this type of errors (look at my mdnie.c (insérer lien) thread for example). As a matter fact, I tried all of the toolchains given by the mentor website and only this one works on my linux.
Step 2: Pulling the Kernel Source
Now, we have to download the kernel from: [url=http://opensource.samsung.com/index.jsp;jsessionid=0EFA22A80FBED4451C1D9C823E3440C4[/url]
You will have an archive unzip it and copy the kernel part into the kernel_P68XX and then untar it.
Code:
mkdir ~/kernel_P68XX
tar xvf Kernel.tar.gz -C ~/kernel_P68XX
You can remove it if you want.
Code:
rm Kernel.tar.gz
Now you have to download and extract the initrd from the samsung zImage found in the official ICS image :
For the UK P6810[url=http://www.hotfile.com/dl/165045602/118260c/P6810XXLPL_P6810OXALPL_XEU.zip.html[/url]
For the Open Austria P6800 [url=http://www.hotfile.com/dl/166221509/de0b31d/P6800XXLQ2_P6800OXALQ2_ATO.zip.html[/url]
Download the zip, unzip it, untar it and copy the zImage as followed.
Then, download also and use unpack-initramfs (both files are attached at the end of this thread).
Code:
mkdir ~/initrd
mv zImage ~/initrd
mv unpack-initramfs ~/initrd
cd ~/initrd
Sudo chmod +x unpack-initramfs
./unpack-initramfs zImage
Step 3: Build the Kernel
Finally, what you've been waiting for!
We have to export a few things first, to prepare the build environment. Open a terminal and type:
Code:
export ARCH=arm
export CROSS_COMPILE=~/arm-2009q3/bin/arm-none-linux-gnueabi-
make P8-wifi_defconfig
You’ll have this :
Code:
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
SHIPPED
scripts/kconfig/zconf.tab.c
SHIPPED scripts/kconfig/lex.zconf.c
SHIPPED
scripts/kconfig/zconf.hash.c
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
#
# configuration written to
.config
#
Now edit the kernel’s configuration.
Code:
nano .config
Search for
Code:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE=""
Change to
Code:
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="../initrd"
Where initrd is the folder where you extracted the zImage initramfs.
Here, you can make substiantials changes to your kernel .This step is really important if you want to customize your kernel (ie : enabling features such as governors, add init.d, cifs, file systems etc.) (we'll see this on the next tutorial). But do it only if you know what you’re doing. Don’t forget to back up your file config (named .config).
Now you can build it.
Code:
make –jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Now, watch the output at the end carefully and you'll see the necessary files that we need:
Code:
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
AS arch/arm/boot/compressed/head.o
GZIP arch/arm/boot/compressed/piggy.gzip
AS arch/arm/boot/compressed/piggy.gzip.o
CC arch/arm/boot/compressed/misc.o
CC arch/arm/boot/compressed/decompress.o
SHIPPED arch/arm/boot/compressed/lib1funcs.S
AS arch/arm/boot/compressed/lib1funcs.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
Building modules, stage 2.
MODPOST 4 modules
CC drivers/net/wireless/ath/ath.mod.o
LD [M] drivers/net/wireless/ath/ath.ko
CC drivers/net/wireless/ath/ath6kl/ath6kl_sdio.mod.o
LD [M] drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko
CC drivers/scsi/scsi_wait_scan.mod.o
LD [M] drivers/scsi/scsi_wait_scan.ko
CC net/wireless_ath/cfg80211.mod.o
LD [M] net/wireless_ath/cfg80211.ko
Anything marked with an [M] will need to be remembered, as well as the location of the compiled kernel at /arch/arm/boot/zImage
Step 4: Dealing with Samsung's errors
Well that would be it, if Samsung had done the job properly but as far as I’m concerned I got three errors :
First one :
Code:
CC drivers/media/video/samsung/mali/common/mali_kernel_core.o
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné: No such file or directory
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné": No such file or directory
cc1: warnings being treated as errors
<command-line>:0: error: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c: In function 'mali_kernel_constructor':
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: missing terminating " character
drivers/media/video/samsung/mali/common/mali_kernel_core.c:172: error: expected expression before ')' token
make[5]: *** [drivers/media/video/samsung/mali/common/mali_kernel_core.o]
Erreur 1
make[4]: ***
[drivers/media/video/samsung/mali] Erreur 2
make[3]: ***
[drivers/media/video/samsung] Erreur 2
make[2]: ***
[drivers/media/video] Erreur 2
make[1]: *** [drivers/media]
Erreur 2
make: *** [drivers] Erreur 2
A way to fix this error is to change the SVN version Makefile in drivers/media/video/Samsung/mali/Makefile. I did not dig into it but I’m sure that one of the term return a wrong value. So I changed it to the number : 1. You can assign any value you want as far as it is not a variable.
Code:
nano drivers/media/video/samsung/mali/Makefile
Search for this chain string : SVN, you’ll find this one :
Code:
# Get subversion revision number, fall back to 0000 if no svn info is available
SVN_REV:=$(shell ((svnversion | grep -qv exported && echo -n 'Revision: ' && sv… … …
Replace with:
Code:
SVN=REV:=1
Relaunch the make
Code:
make -jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Second one :
Code:
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné: No such file or directory
arm-none-eabi-gcc: non: No such file or directory
arm-none-eabi-gcc: versionné": No such file or directory
cc1: warnings being treated as errors
<command-line>:0: error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:
In function 'ump_initialize_module': drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:128:
error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:128:
error: expected expression before ')' token
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:
At top level:
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:472:
error: missing terminating " character
drivers/media/video/samsung/ump/linux/ump_kernel_linux.c:472:
error: expected expression before ',' token
make[5]: ***
[drivers/media/video/samsung/ump/linux/ump_kernel_linux.o] Erreur 1
make[4]: ***
[drivers/media/video/samsung/ump] Erreur 2
make[3]: ***
[drivers/media/video/samsung] Erreur 2
make[2]: ***
[drivers/media/video] Erreur 2
make[1]: *** [drivers/media]
Erreur 2
make: *** [drivers] Erreur 2
Do exactly the same manipulation as said above :
Modify the Makefile in drivers/media/video/Samsung/ump/Makefile.
Code:
nano drivers/media/video/Samsung/ump/Makefile
Search for this chain string : SVN, you’ll find this one :
Code:
# Get subversion revision number, fall back to 0000 if no svn info is available
SVN_REV:=$(shell ((svnversion | grep -qv exported && echo -n 'Revision: ' && sv… … …
Replace with:
Code:
SVN=REV:=1
Relaunch the make
Code:
make -jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Last error but not the least :
Code:
drivers/video/samsung/lcdfreq.c: In function 'level_store':
drivers/video/samsung/s3cfb.h:262:
sorry, unimplemented: inlining failed in call to 'get_fimd_global': function
body not available
drivers/video/samsung/lcdfreq.c:150:
sorry, unimplemented: called from here
drivers/video/samsung/s3cfb.h:262:
sorry, unimplemented: inlining failed in call to 'get_fimd_global': function
body not available
drivers/video/samsung/lcdfreq.c:176:
sorry, unimplemented: called from here
make[3]: ***
[drivers/video/samsung/lcdfreq.o] Erreur 1
make[2]: ***
[drivers/video/samsung] Erreur 2
make[1]: *** [drivers/video]
Erreur 2
make: *** [drivers] Erreur 2
Fix this is very simple but took me a lot of time. I found the solution in some patch explainations for the mainstream kernel. The only thing you have to do is : remove the word “inline” in this file drivers/video/Samsung/s3cfb.h
Search for this :
Code:
extern struct fb_ops s3cfb_ops;
extern inline struct s3cfb_global *get_fimd_global(int id);
Remove “inline”:
Code:
extern struct fb_ops s3cfb_ops;
extern struct s3cfb_global *get_fimd_global(int id);
Redo the make command :
Code:
make -jX{/code]
Now you’ve got your kernel built but it's not finished yet !
[COLOR="blue"][B]Final Step: Include modules to your kernel[/B][/COLOR]
At first, I was very surprised by this step but it is essential otherwise your kernel won’t work. Actually, modules included by samsung in the initrd uncompressed before are not working as if. So you have to do this :
in the initrd you made, copy the *.ko into initrd/lib/modules
[code] cp drivers/net/wireless/ath/ath.ko drivers/net/wireless/ath/ath6kl/ath6kl_sdio.ko drivers/scsi/scsi_wait_scan.ko net/wireless_ath/cfg80211.ko ../initrd/lib/modules
Overwrite them if asked.
Clean your code, use your backup config file and rebuilt the kernel :
Code:
Make distclean
Make clean
Cp your_backup_file kernel_P68XX/.config
make –jX
Where X is the number of tasks you want to run simultaneously. As for me, I use 4 or 5.
Your final kernel is here : /arch/arm/boot/zImage
Kernel Installation
Flash via heimdall
Code:
$ adb reboot download
$ heimdall flash --kernel path/to/zImage
Maybe there's another way to do this so feel free to leave comments
Good luck !
Click to expand...
Click to collapse
@mengpo "Step 4: Dealing with Samsung's errors" is still relevent in 2016. Samsung, great work maintaining and updating your source--what committment to open source. NOT!!!

building kernel failed

I am trying to build a kernel for moto g 2014
I have tried using linaro and stock gcc toolchains.
Code:
[email protected]:~/kernelmoto$ export ARCH=arm
[email protected]:~/kernelmoto$ export CROSS_COMPILER=~/android/aosp-6.0/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9/bin/arm-linux-androideabi-
[email protected]:~/kernelmoto$
[email protected]:~/kernelmoto$ make titan_defconfig
drivers/usb/gadget/Kconfig:881:warning: defaults for choice values not supported
#
# configuration written to .config
#
[email protected]:~/kernelmoto$ make clean && mrproper
CLEAN .
CLEAN arch/arm/kernel
CLEAN kernel
CLEAN security/selinux
CLEAN usr
CLEAN arch/arm/boot
CLEAN .tmp_versions
mrproper: command not found
[email protected]:~/kernelmoto$ make -j6
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/zconf.tab.o
HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --silentoldconfig Kconfig
drivers/usb/gadget/Kconfig:881:warning: defaults for choice values not supported
CHK include/linux/version.h
CHK include/generated/utsrelease.h
HOSTCC scripts/conmakehash
HOSTCC scripts/kallsyms
CC scripts/mod/empty.o
HOSTCC scripts/dtc/checks.o
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option ‘-mlittle-endian’
gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
scripts/Makefile.build:307: recipe for target 'scripts/mod/empty.o' failed
make[2]: *** [scripts/mod/empty.o] Error 1
scripts/Makefile.build:443: recipe for target 'scripts/mod' failed
make[1]: *** [scripts/mod] Error 2
make[1]: *** Waiting for unfinished jobs....
HOSTCC scripts/selinux/genheaders/genheaders
HOSTCC scripts/dtc/data.o
HOSTCC scripts/selinux/mdp/mdp
HOSTCC scripts/dtc/dtc-lexer.lex.o
make[1]: 'include/generated/mach-types.h' is up to date.
HOSTCC scripts/dtc/dtc-parser.tab.o
HOSTCC scripts/dtc/dtc.o
HOSTCC scripts/dtc/flattree.o
CC kernel/bounds.s
HOSTCC scripts/dtc/fstree.o
gcc: error: unrecognized argument in option ‘-mabi=aapcs-linux’
gcc: note: valid arguments to ‘-mabi=’ are: ms sysv
gcc: error: unrecognized command line option ‘-mlittle-endian’
gcc: error: unrecognized command line option ‘-mno-thumb-interwork’
/home/sid/kernelmoto/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
make[1]: *** [kernel/bounds.s] Error 1
Makefile:995: recipe for target 'prepare0' failed
make: *** [prepare0] Error 2
make: *** Waiting for unfinished jobs....
HOSTCC scripts/dtc/livetree.o
HOSTCC scripts/dtc/srcpos.o
HOSTCC scripts/dtc/util.o
HOSTCC scripts/dtc/treesource.o
HOSTLD scripts/dtc/dtc
Makefile:515: recipe for target 'scripts' failed
make: *** [scripts] Error 2
[email protected]:~/kernelmoto$
how to fix these errors? any help will be appreciated.

LineageOS and build error (kernel/gcc)

Hi,
I had my environment set up for building LineageOS (Ubuntu xenial) and it was working perfectly fine.
I haven't updated the machine since March 2017.
Now I did 'repo sync' and suddenly I'm getting the following errors during brunch hammerhead
Code:
LD drivers/video/msm/mdss/mdss-dsi.o
LD drivers/video/msm/mdss/built-in.o
LD drivers/video/msm/built-in.o
LD drivers/video/built-in.o
LD drivers/usb/gadget/g_android.o
LD drivers/usb/gadget/built-in.o
LD drivers/usb/built-in.o
LD drivers/built-in.o
LD vmlinux.o
MODPOST vmlinux.o
ERROR: modpost: Found 12 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)
/media/rawi/android/lineageos/kernel/lge/hammerhead/scripts/Makefile.modpost:98: recipe for target 'vmlinux.o' failed
make[2]: *** [vmlinux.o] Error 1
/media/rawi/android/lineageos/kernel/lge/hammerhead/Makefile:936: recipe for target 'vmlinux.o' failed
make[1]: *** [vmlinux.o] Error 2
Makefile:130: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/media/rawi/android/lineageos/kernel/lge/hammerhead'
[ 12% 4387/34154] target Java: android-support-compat-ics-mr1 (/media/rawi/android/lineageos/out/target/common/obj/JAVA_LIBRARIES/android-support-compat-ics-mr1_intermediates/classes)
ninja: build stopped: subcommand failed.
build/core/ninja.mk:151: recipe for target 'ninja_wrapper' failed
make: *** [ninja_wrapper] Error 1
make: Leaving directory '/media/rawi/android/lineageos'
#### make failed to build some targets (13:29 (mm:ss)) ####
What I've already googled is that it's probably wrong toolchain used but I'm using the one supplied with LineageOS which is arm-eabi-4.8.
I added (not sure if it's necessary) the following exports
Code:
export PATH="/media/rawi/android/lineageos/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin:$PATH"
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE="/media/rawi/android/lineageos/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8/bin/arm-eabi-"
I'd like to highlight that this environment was building LineageOS (cm-14.1 branch) in March perfectly fine
I know that I can add CONFIG_NO_ERROR_ON_MISMATCH=y to config but I assume this is not the right way to do.
Any help greatly appreciated
EDIT: solved... I was compiling CAF kernel with non-caf device
Thread closed as per OP request
-XDA Staff

Categories

Resources