Skip to content

Kernel Only Build Instructions for Jetson reference platform

Michael Scott edited this page Mar 11, 2015 · 10 revisions

General Notes

This assumes user has followed the instructions to setup Jetson for Ara

"jetson-kernel-build" is used as the main directory for this setup. Can be whatever you prefer.

For internal use replace "git-ara-mdk.linaro.org" with "projectara-git.linaro.org"

Need the following packages installed (many of these are required during Ara for Jetson setup):

$ sudo apt-get install gcc-4.8
$ sudo apt-get install gzip
$ sudo apt-get install cpio
$ sudo apt-get install git

1-Time Build Setup Instructions

STEP 1. make install dirs

$ mkdir ~/jetson-kernel-build
$ mkdir ~/jetson-kernel-build/bin
$ mkdir ~/jetson-kernel-build/boot-files
$ mkdir ~/jetson-kernel-build/boot-files/ramdisk

STEP 2. copy split_bootimg.pl script to /bin

$ cd ~/jetson-kernel-build/bin
$ wget http://www.enck.org/tools/split_bootimg_pl.txt
$ mv split_bootimg_pl.txt split_bootimg.pl
$ chmod 755 split_bootimg.pl

STEP 3. using Ara Jetson installer extract boot.img to boot-files and extract the ramdisk

$ cd ~/jetson-kernel-build/boot-files

# NOTE: download Ara for Jetson release from: http://releases-ara-mdk.linaro.org/jetson-5.0.0-open/
# latest file is: nvidia-jetson-ara-android-lrx22g_20150126.tgz

$ wget http://releases-ara-mdk.linaro.org/jetson-5.0.0-open/nvidia-jetson-ara-android-lrx22g_20150126.tgz
$ tar -xvf nvidia-jetson-ara-android-lrx22g_20150126.tgz Android_for_Jetson/bootloader/boot.img

# NOTE: Using split_bootimg.pl from step #2 extract ramdisk

$ ../bin/split_bootimg.pl Android_for_Jetson/bootloader/boot.img

# NOTE: Extract ramdisk for re-packing later

$ cd ramdisk
$ gzip -dc ../boot.img-ramdisk.gz | cpio -i

STEP 4. clone system/core for 1-time compile of "mkbootimg" / "mkbootfs"

# NOTE: confirm gcc is installed on host via "gcc --version"

$ cd ~/jetson-kernel-build
$ git clone https://git-ara-mdk.linaro.org/platform/system/core.git -b projectara-spiral2-5.0.0
$ cd core/libmincrypt/
$ gcc -c *.c -I../include
$ ar rcs libmincrypt.a *.o
$ cd ../mkbootimg
$ gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
$ cp mkbootimg ~/jetson-kernel-build/bin
$ chmod 755 ~/jetson-kernel-build/bin/mkbootimg

STEP 5. clone arm-eabi-4.8 for arm toolchain for android-5.0.2_r1

$ cd ~/jetson-kernel-build
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8 -b android-5.0.2_r1

STEP 6. clone greybus master

$ cd ~/jetson-kernel-build
$ git clone https://github.com/projectara/greybus.git -b master

STEP 7: git clone jetson kernel for Android

$ cd ~/jetson-kernel-build
$ git clone https://git-ara-mdk.linaro.org/kernel/tegra.git -b projectara-spiral2-5.0.0

Testing Your Custom Kernel

STEP 1: make zImage

$ cd ~/jetson-kernel-build

# NOTE: You need to set the following export variables only once per window session:

$ export PATH=`pwd`/arm-eabi-4.8/bin:$PATH
$ export CROSS_COMPILE=`pwd`/arm-eabi-4.8/bin/arm-eabi-
$ export KERNEL_DIR=`pwd`/tegra

# NOTE: [OPTIONAL] you can erase the kernel-out directory for a clean start

$ rm -rf kernel-out
$ mkdir -p kernel-out
$ cd tegra
$ make ARCH=arm KCFLAGS="-fno-pic" O=../kernel-out defconfig tegra12_android_defconfig
$ make -j32 ARCH=arm KCFLAGS="-fno-pic" O=../kernel-out zImage-dtb
$ cp ../kernel-out/arch/arm/boot/zImage-dtb ../boot-files/zImage

STEP 2: make greybus modules

$ cd ~/jetson-kernel-build/greybus
$ make clean
$ make ARCH=arm KERNELDIR=../kernel-out EXTRA_CFLAGS+=-fno-pic
$ rm ../boot-files/ramdisk/lib/modules/*
$ cp *.ko ../boot-files/ramdisk/lib/modules/

STEP 3: recombine ramdisk and boot.img for testing

$ cd ~/jetson-kernel-build/boot-files/ramdisk
$ find . | cpio -o -H newc | gzip > ../ramdisk.gz
$ cd ..
$ ../bin/mkbootimg --kernel zImage --ramdisk ramdisk.gz --base 0x80000000 \
--kernel_offset 0x01000000 --ramdisk_offset 0x02100000 --tags_offset 0x02000000 \
--pagesize 2048 --cmdline "androidboot.hardware=jetson vmalloc=384M \
androidboot.selinux=permissive" -o newboot.img

STEP 4: testing your custom "newboot.img" $ cd ~/jetson-kernel-build/boot-files/

# NOTE: To place Jetson in fastboot mode do one of the following:
    - interrupt power-on boot via serial console by using <enter> key and type: fastboot
      (WARNING: You will not see any visual indication fron serial console after entering this command)
    or
    - (While booted into Android and connected to micro USB enter the following on your host)
      $ adb reboot bootloader
    or
    - (While booted and connected to serial console enter the following on Jetson)
      $ reboot bootloader

$ fastboot boot newboot.img