|
|
LinkBack | Thread Tools | Display Modes |
|
||||
Re: How To Compile Your Own Kernels, Modules, Tinboot (for NAND booting), and More
Below is a copy of my full build script for NAND. Haret users will have to make a few changes which I'll explain later. Just copy/paste it into gedit and save as fullbuild.sh and run it from terminal. You may need to change the directory paths at the beginning if you don't put them where I recommended.
Code:
#!/bin/sh #------------------------------------------------------------------------- # Build Script for linux-msm-rhod-nand (Android on HTC) kernel, modules, XIP, and NBH #------------------------------------------------------------------------- # # Set the following variables # ANDROID -- Root director for Android files ANDROID=~/android # TINBOOT -- tinboot directory TINBOOT=$ANDROID/tinboot-linux-msm # KERNEL_PATH -- directory containing the linux-msm kernel source KERNEL_PATH=$ANDROID/linux-msm-rhod-nand # TOOLCHAIN_PATH -- directory containing the arm toolchain TOOLCHAIN_PATH=$ANDROID/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi # MODULES_PATH -- directory for modules MODULES_PATH=$TINBOOT/modules #------------------------------------------------------------------------- # do some cleanup before building if zImage already exists echo "Removing previous zImage" if [ -f $TINBOOT/kernel/zImage ] ; then rm $TINBOOT/kernel/zImage fi # build kernel and modules #export ARCH=arm cd $KERNEL_PATH make clean make ARCH=arm htc_msm_nand_defconfig make ARCH=arm CROSS_COMPILE=$TOOLCHAIN_PATH- INSTALL_MOD_PATH=$MODULES_PATH zImage modules modules_install [ $? -eq 0 ] || fail "Kernel compilation failure" # copy all drivers to single level directory for compression cd $MODULES_PATH KERNMODS=$(find -name "*.ko") if [ ! -d $ANDROID/androidupdate/data/modules ] ; then mkdir -p $ANDROID/modules fi for i in $KERNMODS ; do cp $i $ANDROID/modules done # make squash files KER_VER="$(cat $KERNEL_PATH/include/config/kernel.release)" mkdir -p $ANDROID/androidupdate/system/lib/modules mksquashfs $ANDROID/modules $ANDROID/androidupdate/system/lib/modules/$KER_VER.sqsh # compress modules to a tar.gz and move to output echo "Outputting modules to Desktop" cd $ANDROID/androidupdate tar -cvzf $ANDROID/androidupdate.tgz data system rm -rf $ANDROID/modules rm -rf $ANDROID/androidupdate/system/lib/modules # clean up modules rm -Rf $MODULES_PATH mkdir $MODULES_PATH rm -Rf $KERNEL_PATH/lib/modules # move new kernel mv $KERNEL_PATH/arch/arm/boot/zImage $TINBOOT/kernel #-----start build XIP----- # remove old XIP if it exists cd $TINBOOT if [ -f xip/rhod ]; then rm xip/rhod echo Deleting old XIP fi # make XIP folder if it does not exist if [ ! -d "$TINBOOT/xip" ] ; then mkdir $TINBOOT/xip fi # compile tinboot XIP echo "Start compiling tinboot/xip for rhod....." $TOOLCHAIN_PATH-as tinboot/tinboot2.S -o tinboot.o --defsym rhod=1 --defsym MTYPE=2292 $TOOLCHAIN_PATH-objcopy tinboot.o -O binary tinbootxip mv tinbootxip xip/rhod # cleanup tinboot rm tinboot.o # make sure XIP build was successful if [ ! -f xip/rhod ] ; then fail "XIP build failed. XIP file was not found." fi #-----start build NBH----- # clean up previous log file if [ -e "tools/log" ]; then rm tools/log fi # compile tinboot cp tools/rhod_payload2 os.nb.payload echo "Inserting tinboot into payload" wine tools/osnbtool -c os.nb.payload 1 xip/rhod >> tools/log mv os.nb.payload.NEW os.nb.payload >> tools/log echo "Inserting blank imgfs into payload" wine tools/ImgfsToNb.exe tools/imgfs.bin os.nb.payload os-new.nb.payload >> tools/log echo "Creating os.nb portion of nbh" tools/nbmerge < os-new.nb.payload > os-new.nb echo "Creating NBH" wine tools/yang.exe -F RHODIMG.NBH -f os-new.nb -t 0x400 -s 64 -d RHOD****0 -c 11111111 -v Tinboot -l WWE >> tools/log # clean up payloads mv RHODIMG.NBH $ANDROID/RHODIMG.NBH rm os.nb.payload rm os-new.nb.payload rm os-new.nb # clean up tinboot directory rm -rf xip What the heck is zImage, modules, tinboot, rootfs, initrd, and System.ext2? This section will be updated slowly as I have time. The zImage is the kernel (which is required to run the operating system). We currently use the linux kernel 2.6.27.46. The modules are your drivers. These are a matched pair with the zImage/kernel. It is also important to clean up the modules periodically when building the kernel/modules or you will start running out of space ![]() Awesome explanation of the kernel and its modules here: http://www.howtogeek.com/howto/31632...at-does-it-do/ Tinboot is the bootloader for running Android from the NAND. Currently, we put initrd.gz and the zImage on the NAND while the zImage, rootfs, and System.ext2 are pulled from the SD Card. RootFS is a special type of ramfs file system. It basically lets us use part of the memory as a partition for caching files. This gives us a nice performance boost ![]() Initrd is an initial RAM disk that is temporary and used only for booting. Generally it uses a slightly different scheme than rootfs does. System.ext2 is your file system. This is technically your hard drive where all of the Android files and applications are stored. It uses the ext2 file system which is an extended file system designed specifically for linux. Last edited by natemcnutty; 04-05-2011 at 11:23 PM. |
This post has been thanked 9 times. |
|
|
|