Compiling Picuntu Kernel

Compiling Picuntu Kernel (Ubuntu Linux for RK3066 devices)
Starting from Picuntu Linux' source code, along with several tools, we will end up with a recovery.img file. This is used to flash the recovery partition of an RK3066 device, which will then be able to boot into Picuntu (Ubuntu Linux).

 WARNING:  You DO NOT need to follow these steps unless you want to modify Picuntu's kernel!The stock kernel from Alok Sinha works fine and is very easy to install. Follow this guide:https://www.miniand.com/wiki/Picuntu+Linux+Step+by+Step+Installation

Assuming the kernel is compiled from an x86 PC running an Ubuntu Linux:

#get the right packages for the compiler [3]

sudo apt-get install git-core gnupg flex bison gperf libsdl-dev libesd0-dev libwxgtk2.8-dev build-essential zip curl libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib sharutils lzop

 #start out from the user's home and create "rk" folder for all the work

cd ~

mkdir rk

cd rk

 #toolchains folder is where the ARM compiler toolchain will be downloaded to [3]

git clone https://github.com/DooMLoRD/android_prebuilt_toolchains.git toolchains

 #tools folder is where the mkbootimg tool (create recovery image) will be downloaded to [4]

git clone https://github.com/olegk0/tools.git

 #initramfs folder is where the Picuntu kernel's .config file looks for initramfs.cpio (see CONFIG_INITRAMFS_SOURCE)

git clone https://github.com/Galland/rk30_linux_initramfs.git initramfs

<span style="font-family:Verdana,sans-serif;">cd initramfs

<span style="font-family:Verdana,sans-serif;">gzip -dc debian-3.0.8+fkubi.cpio.gz > initramfs.cpio

<span style="font-family:Verdana,sans-serif;">cd ..

<span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#rk3x_kernel_3.0.36 is where we download the latest available Picuntu Linux kernel source code

<span style="font-family:Verdana,sans-serif;">git clone https://github.com/Galland/rk3x_kernel_3.0.36.git

<span style="font-family:Verdana,sans-serif;">cd  <span style="font-family:Verdana,sans-serif;">rk3x_kernel_3.0.36 <span style="font-family:Verdana,sans-serif;">/

<span style="font-family:Verdana,sans-serif;"><span style="color:rgb(56,118,29);">#copy Picuntu 0.9 RC3 config file (actually extracted from a running Picuntu, located at /proc/config.gz)

<span style="font-family:Verdana,sans-serif;"> cp ../initramfs/config .config

<span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;"> <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#copy updated Picuntu kernel config file <span style="font-family:Verdana,sans-serif;">cp config.galland .config

<span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#set the target architecture and toolchain location ( CHANGE the base folder<span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;"> if you are not using ~/rk/)

<span style="font-family:Verdana,sans-serif;">export ARCH=arm

<span style="font-family:Verdana,sans-serif;">export CROSS_COMPILE=~/rk/toolchains/arm-eabi-linaro-4.6.2/bin/arm-eabi-

<span style="font-family:Verdana,sans-serif;"> <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#launch the Kernel compilation (-j 4 indicates that 4 compiler threads run in parallel, I have a quad-core PC...)

<span style="font-family:Verdana,sans-serif;">make -j 4

<span style="font-family:Verdana,sans-serif;"> <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;"># <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;"># Kernel compilation takes some minutes...

<span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;"># BTW, don't worry about the warnings while compiling <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#

<span style="font-family:Verdana,sans-serif;"> <span style="color:rgb(56,118,29);font-family:Verdana,sans-serif;">#last step is to generate the recovery.img to flash the recovery partition of the Android stick

<span style="font-family:Verdana,sans-serif;">cd ..

<span style="font-family:Verdana,sans-serif;">tools/mkbootimg --kernel  <span style="font-family:Verdana,sans-serif;">rk3x_kernel_3.0.36/ <span style="font-family:Verdana,sans-serif;">arch/arm/boot/Image --ramdisk initramfs/fakeramdisk.gz --base 60400000 --pagesize 16384 --ramdiskaddr 62000000 -o recovery.img

Now flash recovery.img into the recovery partition and boot into Picuntu Linux, just like using the stock Picuntu kernel!

Installing modules and firmware
In the same x86 PC as above, after the flashing step:

<span style="font-family:'CourierNew',Courier,monospace;">mkdir mod_fw cd rk3x_kernel_3.0.36 make modules_install INSTALL_MOD_PATH=~/rk/mod_fw/ A new  folder called "lib", with "modules" and "firmware" subfolders, should appear inside "mod_fw". Copy & overwrite "lib" into the Picuntu MicroSD card's root folder, start Picuntu and in a Terminal write:

<span style="font-family:'CourierNew',Courier,monospace;">sudo depmod -a And, after a restart, everything should be ready.

REFERENCES

[1] https://docs.google.com/folder/d/0B02hgWz32NpXcC1ONVBSLWx6RHc/edit

[2] http://www.slatedroid.com/topic/41654-pre-alpha-03-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1/page__view__findpost__p__502961

[3] http://www.armtvtech.com/armtvtechforum/viewtopic.php?p=5072#p5072

[4] http://www.slatedroid.com/topic/41654-pre-alpha-03-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1/page__view__findpost__p__495617