www.chinaphonearena.com

Full Version: kernel building mt6582....ramblings
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ramblings as I am not organised just doing online notes to myself in no particular order

Having bought a new PC and installed Xubuntu 64 bit on it, its time to look if I can build a kernel for my phone.....mt6582



Building a Kernel from source{Mediatek}
CREDITS
######
MasterAwesome

2) one of the differences is I won't try an emulator

because I know how to mod a recovery image, I shall inject my new kernel and use mobileuncle or fastboot to flash the new recovery

--- no need to worry about kernel modules in recovery mode

3) I have already looked.....there is no config anywhere in my /proc or system files.....but I can get lsmod output off phone to see what modules are currently running on it.


now to have time to do it.....can anyone give me their spare time?
giggles

one of the things we need is a toolchain

EDIT
Just found out a gotcha....can't use 4.7 need to use 4.6

Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.6

this produces a folder called.......150 Mb unpacked size
/home//arm-eabi-4.6/

and the kernel source for our cross compile stuff

Code:
git clone https://github.com/kashifmin/MT6582-KK-KERNEL.git

produces a folder called...............size unpacked is 2.4 Gb

I repeat 2400 Mb in case you think its a typo

/home//MT6582-KK-KERNEL/
huh, since when are MTK kernel sources open?
interesting stuff, i'd like to read more of your proceedings.
i am personally hoping to start some development of my own when Xiaomi finally releases kernel source code for MI3.
a quick google against phone and github produces this
[Only registered and activated users can see links Click here to register]

and don't get excited but mi2 is here
[Only registered and activated users can see links Click here to register]

is it close enough?
(2014-08-27, 17:39)aus9 Wrote: [Only registered and activated users can see links Click here to register]

and don't get excited but mi2 is here
[Only registered and activated users can see links Click here to register]

is it close enough?
Nope mi2 is snapdragon 600 and pretty much completely different. Source for mi3 should be available until end of year.
Some efforts were already made, search cancro
stumbling block is a missing header.....it is not found anywhere
well not in the kernel source
here are the details and cross compile instructions so far....oh and I changed to Linaro toolchain

Code:
# commands done in same shell, no persistence at this stage
export TARGET_PRODUCT=A9CL
export PATH=/home/gordon/android-toolchain-eabi/bin:$PATH
export ARCH_MTK_PLATFORM=mt6582
export TARGET_BUILD_VARIANT=user
export TARGET_PRODUCT=A9CL
export MTK_ROOT_CUSTOM=/home/gordon/$KS/mediatek/custom/
export TARGET_KERNEL_VERSION=mt6582
export CROSS_COMPILE=arm-eabi-
export ARCH=arm
KS=MT6582-KK-KERNEL
DN=mt6582
cd $KS
cp mediatek/config/$DN/autoconfig/kconfig/platform kernel/.config
cd kernel
make prepare

# fix errors of gcc name not found
ln -s /home/gordon/android-toolchain-eabi/bin/arm-linux-androideabi-gcc   /home/gordon/android-toolchain-eabi/bin/arm-eabi-gcc

# fix missing headers
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/timex.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/timex.h
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/memory.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/memory.h
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/irqs.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/irqs.h
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/mt_irq.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/mt_irq.h
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/x_define_irq.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/x_define_irq.h

# no more make prepare errors
make menuconfig  # no changes at this stage
make zImage

# fix zImage errors
ln -s /home/gordon/MT6582-KK-KERNEL/mediatek/platform/mt6582/kernel/core/include/mach/mt_spm_idle.h /home/gordon/MT6582-KK-KERNEL/mediatek/kernel/include/mach/mt_spm_idle.h

# unresolved error no dfo_boot.h

thanks for reading
ok so I found the header but its for the wrong kernel mt6572 but still no joy
make zImage fails for a related df0* object

code tidied up so its easier to reaad
Code:
KS=MT6582-KK-KERNEL
DN=mt6582

# fix errors in Linaro bin
cd /home/gordon/android-toolchain-eabi/bin
ln -s arm-linux-androideabi-ld.bfd arm-eabi-ld.bfd
ln -s arm-linux-androideabi-gcc    arm-eabi-gcc
cd ~

# fix missing headers
cd $KS/mediatek
S1=platform/mt6582/kernel/core/include/mach
L2=kernel/include/mach
ln -s $S1/timex.h        $L2/timex.h
ln -s $S1/memory.h       $L2/memory.h
ln -s $S1/irqs.h         $L2/irqs.h
ln -s $S1/mt_irq.h       $L2/mt_irq.h
ln -s $S1/x_define_irq.h $L2/x_define_irq.h
ln -s $S1/mt_spm_idle.h  $L2/mt_spm_idle.h
ln -s $S1/mt_devinfo.h   $L2/mt_devinfo.h
ln -s $S1/entry-macro.S  $L2/entry-macro.S
cd ~


# commands done in same shell, no persistence at this stage
export TARGET_PRODUCT=A9CL
export PATH=/home/gordon/android-toolchain-eabi/bin:$PATH
export ARCH_MTK_PLATFORM=mt6582
export TARGET_BUILD_VARIANT=user
export TARGET_PRODUCT=A9CL
export MTK_ROOT_CUSTOM=/home/gordon/$KS/mediatek/custom/
export TARGET_KERNEL_VERSION=mt6582
export CROSS_COMPILE=arm-eabi-
export ARCH=arm
cd $KS
cp mediatek/config/$DN/autoconfig/kconfig/platform kernel/.config
cd kernel
make prepare
# do not proceed unless no errors
# make menuconfig  # no changes at this stage
# make zImage

# unresolved error no dfo_boot.h
# google and borrow the header from mt6572
# inject it and sym link it

I can not edit first post, but that is not important

If you are on Linux there are a number of Linaro toolchains to choose from

I chose the simplest cos I am a simple person .....giggles

[Only registered and activated users can see links Click here to register]

click on d/l link = android-toolchain-eabi-4.9-2014.07-x86.tar.bz2

good luck

now we look to see if we can choose a different custom kernel within the kernel source

eg

#ifndef __ARCH_ARM_MACH_MT6575 visible from
/home/gordon/MT6582-KK-KERNEL/mediatek/custom/bird82_tb_td_a_kk/kernel/core/src/board-custom.h

mine is mt6582 so we can't use that one

2) Can't use same pathway for next kernel
but
/home/gordon/MT6582-KK-KERNEL/mediatek/custom/banyan_addon_x86/factory/init.rc

contents includes
chmod 0777 /dev/mt6516
and
mount yaffs2 mtd@system /system

Nope....my partition does not use yaffs nor do I have such dev

3) other one is also not mine as this pathway exist
/home/gordon/MT6582-KK-KERNEL/mediatek/custom/common/kernel/wifi/mt592x/

so I can't use "common" in my export pathway

I am no closer than before but I have eliminated all but mt6582 as potential custom kernel configs

grrrrrrrrrrr
Hi.. i compiled with this command

./makeMtk bird82_tb_td_a_kk n k

but error for this
make[2]: *** [sub-make] Error 2
out/target/product/bird82_tb_td_a_kk/obj/KERNEL_OBJ/kernel_bird82_tb_td_a_kk.bin does NOT exist!


how ti fix ?
Please my mobile lenovo a328 mt6582 KitKat kernel I have update lolipop kernel please guide
Hiļ¼Œaus9:
Do you have solved these build errors, now. Could you share some experience about this MT6582 Source code building, or if there are some other solution on MT6582 platform.