Skip to content

Kernel Only Build Instructions for Jetson reference platform

Michael Scott edited this page Oct 7, 2015 · 10 revisions

General Notes

This assumes user has followed the instructions to setup your reference device:
Getting Started with Jetson

"~/jetson-kernel-build" is used as the main directory for this setup per the export settings. Can be whatever you prefer, but must not be a relative path.

For internal use replace "git clone https://git-ara-mdk.linaro.org" with "git clone ssh://git@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

$ export JKB_ROOT=~/jetson-kernel-build
$ mkdir $JKB_ROOT
$ cd $JKB_ROOT
$ mkdir bin boot-files boot-files/ramdisk

STEP 2. copy split_bootimg.pl script to /bin

$ cd $JKB_ROOT/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. use a prebuilt Ara Android Jetson boot.img to extract the ramdisk

$ cd $JKB_ROOT/boot-files

# NOTE: download Ara Android Jetson boot.img:
# http://releases-ara-mdk.linaro.org/jetson-5.1.0-open/
# latest file is: nvidia-jetson-boot-lmy47z.img

$ wget -O boot.img http://releases-ara-mdk.linaro.org/jetson-5.1.0-open/nvidia-jetson-boot-lmy47z.img

# NOTE: Using split_bootimg.pl from step #2 extract ramdisk
$ ../bin/split_bootimg.pl 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 $JKB_ROOT
$ git clone https://git-ara-mdk.linaro.org/platform/system/core.git -b projectara-5.1
$ 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
$ mv mkbootimg ../../bin

STEP 5. clone arm-eabi-4.8 for arm toolchain for lollipop-mr1-release

$ cd $JKB_ROOT
$ git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8 -b lollipop-mr1-release

STEP 6. clone greybus master

$ cd $JKB_ROOT
$ git clone https://github.com/projectara/greybus.git -b master

STEP 7. git clone jetson kernel for Android

$ cd $JKB_ROOT
$ git clone https://git-ara-mdk.linaro.org/kernel/tegra.git -b projectara-5.1

Testing Your Custom Kernel

PREPARE YOUR CURRENT SESSION

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

# Make sure you export the root location of your kernel build.
# This can be a custom location, but make sure this is not a relative path.
# “cd $JKB_ROOT” should work from anywhere.
$ export JKB_ROOT=~/jetson-kernel-build

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

STEP 1. make zImage

$ cd $JKB_ROOT
# NOTE: [OPTIONAL] you can erase the kernel-out directory for a clean start (if it exists)
$ rm -rf kernel-out

$ mkdir -p kernel-out
$ cd tegra
$ make ARCH=arm KCFLAGS="-fno-pic" O=../kernel-out defconfig tegra12_android_hdmi-primary_defconfig
$ make -j8 ARCH=arm KCFLAGS="-fno-pic" O=../kernel-out zImage-dtb
$ mv ../kernel-out/arch/arm/boot/zImage-dtb ../boot-files/zImage

STEP 2. make greybus modules

$ cd $JKB_ROOT/greybus
$ make clean
$ make ARCH=arm KERNELDIR=../kernel-out EXTRA_CFLAGS+=-fno-pic
$ rm $JKB_ROOT/boot-files/ramdisk/lib/modules/*
$ mv *.ko $JKB_ROOT/boot-files/ramdisk/lib/modules/
$ ${CROSS_COMPILE}strip --strip-unneeded $JKB_ROOT/boot-files/ramdisk/lib/modules/*

STEP 3. recombine ramdisk and boot.img for testing

$ cd $JKB_ROOT/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 $JKB_ROOT/boot-files/
# Follow these instructions to place your device in fastboot mode:
[[How to place Jetson in fastboot mode|Getting-Started-with-the-Jetson-reference-platform#how-to-place-jetson-in-fastboot-mode]]

# Use the following command to load your boot.img directly into memory and start
$ sudo fastboot boot newboot.img

# OR if you prefer to flash the device with your new boot.img you can use "fastboot flash
# boot" to write the boot.img to the "boot" partition.  Follow this up with
# "fastboot reboot" to restart the device and use the newly flashed boot.img:
$ sudo fastboot flash boot newboot.img
$ sudo fastboot reboot