Skip to content

Kernel Only Build Instructions for Jetson reference platform

Michael Scott edited this page Aug 5, 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 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://[email protected]".

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 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 nvidia-jetson-boot-lmy47z.img
$ mv nvidia-jetson-boot-lmy47z.img-ramdisk.gz ramdisk.gz

# NOTE: Extract ramdisk for re-packing later

$ cd ramdisk
$ gzip -dc ../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

STEP 1: make zImage

# NOTE: Make sure you export the root location of your kernel build once at the beginning of your session
# 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

$ cd $JKB_ROOT

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

$ 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

# 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_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/

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/

# Power on your Jetson
# Make sure you have a USB cable connected to the Micro-USB (OTG) port of the Jetson device
# 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 from 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

# 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