[HowTo] Build own kernel for Jetson TK1

This method is for fastboot mode. If you use U-boot look to linuxdev post on this thread.

1. On Jetson-TK1

a) Install dependencies:

sudo apt-add-repository universe
sudo apt-get update
sudo apt-get install libncurses5-dev

b) Switch to root account:

sudo su

c) Download, unpack & configure kernel source:

cd /usr/src/
wget https://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/kernel_src.tbz2
tar -xvf kernel_src.tbz2
cd kernel
zcat /proc/config.gz > .config
make menuconfig

Go to: “General setup → Local version” and set your version name eg.: -grinch

After customize kernel options, save & exit. You should look “configuration written to .config”

d) Compile your kernel (about 10minutes)

make -j4
make modules
make modules_install

e) Check modules was installed

ls /lib/modules/

You should look -grinch modules directory:

3.10.24-gf455cd4 3.10.24-grinch

f) Copy kernel zImage to USB or FTP from arch/arm/boot/ directory

-rwxr-xr-x 1 root 5721960 Jul 20 18:32 arch/arm/boot/zImage

g) Turn off Jetson TK1, connect via USB cable to PC-host and turn Jetson in RECOVERY mode.

2. On PC host

a) On PC-Host you should look device 0955:7140:

lsusb
Bus 006 Device 010: ID 0955:7140 NVidia Corp.

b) Download L4T if you haven’t yet:

wget https://developer.nvidia.com/sites/default/files/akamai/mobile/files/L4T/Tegra124_Linux_R19.3.0_armhf.tbz2
tar -xvf Tegra124_Linux_R19.3.0_armhf.tbz2
cd Linux_for_Tegra

c) Replace zImage in “kernel/” in your zImage file compiled before (1.f)

d) Flash kernel

sudo ./flash.sh -k 6 jetson-tk1 mmcblk0p1

You should look:

copying dtbfile(/root/Linux_for_Tegra/kernel/dtb/tegra124-pm375.dtb) to tegra124-pm375.dtb... done.
Just updating kernel and boot device.
copying bootloader(/root/Linux_for_Tegra/bootloader/ardbeg/fastboot.bin)... done.
Bootloader(/root/Linux_for_Tegra/bootloader/ardbeg/fastboot.bin) used as flasher.
Existing flash application(/root/Linux_for_Tegra/bootloader/nvflash) reused.
making zero initrd... 
done.
Making Boot image... done
*** Flashing kernel update started. ***
Nvflash 4.13.0000 started
chip uid from BR is: 0x340010017408f044100000000a020440
rcm version 0X400001
System Information:
   chip name: unknown
   chip id: 0x40 major: 1 minor: 1
   chip sku: 0x81
   chip uid: 0x000000017408f044100000000a020440
   macrovision: disabled
   hdcp: enabled
   jtag: enabled
   sbk burned: false
   board id: 375
   warranty fuse: 0
   dk burned: true
   boot device: emmc
   operating mode: 3
   device config strap: 0
   device config fuse: 0
   sdram config strap: 3

RCM communication completed
downloading bootloader -- load address: 0x80108000 entry point: 0x80108000
sending file: fastboot.bin
- 900492/900492 bytes sent
fastboot.bin sent successfully
waiting for bootloader to initialize
bootloader downloaded successfully
sending file: boot.img
\ 5724160/5724160 bytes sent
boot.img sent successfully
Time taken for flashing 3 Secs
*** The kernel has been updated successfully. ***

IF FLASH FAILED and message is: “mapping system.img to loop device failed.” edit flash.sh on line 284:

losetup /dev/loop0 system.img > /dev/null 2>&1

replace to:

losetup --find --show system.img

thanks linuxdev - more info

e) Reset Jetson (power off-on)

3. On Jetson-TK1

a) Check kernel version

uname -a
Linux tegra-ubuntu 3.10.24-grinch #1 SMP PREEMPT Sun Jul 20 18:31:40 CEST 2014 armv7l armv7l armv7l GNU/Linux

b) Copy extra modules from NVIDIA kernel

sudo cp -rv /lib/modules/3.10.24-gf455cd4/extra /lib/modules/`uname -r`/
sudo depmod -a

Well done. You have own kernel!

p.s. sorry for my english :)

Thank You!

Couple of notes:

  1. R19.3 allows you to optionally choose U-boot instead of fastboot. Default is fastboot. If you choose U-boot, you need to also copy zImage to Jetson’s /boot/. uname -r will fail to upgrade if zImage does not go to /boot while running U-boot.

  2. If your development host machine uses udev (such as fedora, but not ubuntu), /dev/loop0 will not exist until you run losetup --find as root. Not doing this before L4T flash (does not apply to kernel flash) will cause failure and Jetson will be unbootable until correcting the missing /dev/loop0 and flashing again.

  3. Choosing U-boot will probably offer some advantages for booting from SD cards without modifying the host each time. I have not used this on Jetson yet, but have used it on other Tegra SoC…just changing environment variables at the boot prompt (requires U-boot) can allow booting other kernels, e.g., on SD card, without changing the base system.

  4. The existing module directory for default install (see /lib/modules/uname -r/) contains subdirectory “extra” and this contains nVidia’s modules. You probably will want to recursively copy the original module directory to the new uname -r before running make modules_install. Otherwise “extra” will be missing those nVidia modules.

thanks linuxdev - i’m update guide 2d) and 3b)

Thanks. I was just going to post a question for this. I followed most of these steps on my own but I can already see some I missed. Hope that is why my zimage got overwritten by default.

@linuxdev: If I flash jetson to use u-boot, I can later come back to fastboot by use NVIDIA flash.sh procedure?

I don’t see any reason why not…but I have not tried reverting. I’m not where I can check the flash.sh option at the moment for U-boot, but I recall it named the uboot.bin file (or close to that name) in the boot loader directory…I am thinking in the back of my head that instead of just depending on no option causing fastboot you could also use the option and specifically point it at fastboot.bin. I would think not being able to specify going back to fastboot.bin would be a bug.

@Santyago,
Many thanks for your post, as I just followed the steps successfully.
But when I cross-built the kernel on ubuntu(x86) 12.0.4 with arm-none-linux-gnueabi toolchain (Sourcery CodeBench Lite 2013.11-13 4.8.1), Jetson-tk1 can not boot into kernel again, with the last print of bootloader as “jump kernel …”. It could be recovered by the old kernel zImage. I also tried the toolchain arm-linx-gnueabihf, and nothing helps.
Anything wrong with me? Any advices?

i will try in weekend your procedure with cross-build, and I’ll let you know

I haven’t cross-compiled for Jetson yet, but I have cross-compiled on another ARM9 (ARMv7) Tegra platform with no issues. I’ve used arm-linux-gnueabihf, which was listed above, and this should work fine. I also intend to set up for cross compile, but won’t be doing this until I finish other projects (Jetson is just too easy to compile directly on).

If it stalls at jumping from boot loader to kernel, there is probably an installation error…e.g., kernel location and/or kernel format; maybe your cross compile didn’t set export ARCH=arm.

@Santyago, @linuxdev
I believe there must be a little mistake, but it’s not ARCH things, as I got the zImage from arch/arm/boot/.
It so bored me, please let me know once you got any update. Thanks

How would I cross compile on my host pc and then flash to the jetson?

Also, what is the difference between fastboot, uboot etc?

Thank You

I have not yet set up cross-compile for Jetson. Basically you install a development environment which has what compile needs for your software (e.g., libraries from ARMv7), and a cross-compile tool chain. I have not yet tried under Jetson, but it should be interesting to loopback mount the system.img from a flash install as such an environment. Otherwise at least a subset of the rootfs would be used.

About fastboot and U-boot, the gist is…
Fastboot is simpler, and offers no options during boot. It strictly looks for a kernel in the GPT partition from the install’s “-k 6” option. This would probably be the way to go for a non-interactive embedded appliance (if not bare metal booting).

U-boot offers more options, and looks for a zImage in the /boot partition. Boot configuration can also be edited here, for example I threw in a couple of zImage variants (like debugging version and network options added), and edited extlinux.conf…and magically I can boot to any of those kernels at the serial console boot prompt (provided my eye is fast). No flash was required for any kernel beyond the first kernel.

I would like to add bluetooth capabilities to the jetson tk1. Did you try doing it with the above method?

What else do I have to do?

Ok, so I’m missing nvidia drivers. Specifically hdmi audio. I’ve followed the guide and am booting from my kernel. Any ideas?

beowulfs: this may by other issue with hdmi hotplug: HDMI audio sometimes not work - Jetson TK1 - NVIDIA Developer Forums try logout and login again

i prepare custom kernel for jetson tk1, if you have any special requests for kernel modules, let me know

Thanks :)) Score. Definite bug. Log out made it appear. Thanks. I’m down to 4 things:

  1. Blu Ray acceleration or graphic acceleration; frame rate from disc is low, but I’ve only tested from disc. I need it fast from disc though. Maybe CUDA kit will fix?
  2. WiFi / Bluetooth for 7260. My kernel is already modular and has iwlwifi and all the intel wifi selected, so this should be a matter of files.
  3. Set up a ppa for my build.
  4. Make the entire damn thing work in android.

I have successfully built the kernel per your instructions - thanks - you made it much easier.

We do a few custom mods to the board, specifically we set the rate of the GPU per this link: Some login tweaks for L4T 19.3 to disable USB autosuspend and lock the GPU to max MHz. I have lines 3-11 of tk1_tweaks.sh appended to my .profile. · GitHub
and we set the network buffer size so we don’t loose network traffic.

Is is possible to modify the kernel to have these mods built into the kernel such that we don’t have to continue to make these mods by hand? We plan to deploy a few of these on various robotic platforms and would prefer to make the installation process a bit easier if possible.

thanks for any advice/input,

Ricky

I cook some software and scripts attached to my Custom Kernel, with easy setup some options. Stay tunned :)

Santyago,
Great work!
Do you have any experience with the CSI-2 interface? I have connected a OV5640 camera to the CSI-2 interface and I am looking for the kernel support. I can see so far that not even the power supply (2.8V / 1.8V ) is enabled yet.
I can also see that the kernel has V4L OV5640 support enabled. There are also modules for Tegra SoC camera support, but tegra_camera module won’t load…