[HowTo] Build own kernel for Jetson TK1
This method is for fastboot mode. If you use U-boot look to [url=https://devtalk.nvidia.com/default/topic/762653/embedded-systems/-guide-build-own-kernel-for-jetson-tk1/post/4264541/#4264541]linuxdev post on this thread[/url]. [b]1. On Jetson-TK1[/b] [u]a) Install dependencies:[/u] [code] sudo apt-add-repository universe sudo apt-get update sudo apt-get install libncurses5-dev[/code] [u]b) Switch to root account:[/u] [code]sudo su[/code] [u]c) Download, unpack & configure kernel source: [/u] [code]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[/code] Go to: [b]"General setup -> Local version"[/b] and set your version name eg.: [b]-grinch[/b] After customize kernel options, save & exit. You should look [i]"configuration written to .config"[/i] [u]d) Compile your kernel (about 10minutes)[/u] [code]make -j4 make modules make modules_install[/code] [u]e) Check modules was installed[/u] [code]ls /lib/modules/[/code] You should look [b]-grinch[/b] modules directory: 3.10.24-gf455cd4 [b]3.10.24-grinch[/b] f) Copy kernel zImage to USB or FTP from [b]arch/arm/boot/[/b] 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. [b]2. On PC host[/b] [u]a) On PC-Host you should look device 0955:7140:[/u] [code]lsusb Bus 006 Device 010: ID 0955:7140 NVidia Corp.[/code] [u]b) Download L4T if you haven't yet:[/u] [code] 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[/code] [u]c) Replace [b]zImage[/b] in "kernel/" in your [b]zImage[/b] file compiled before (1.f) [/u] [u]d) Flash kernel[/u] [code]sudo ./flash.sh -k 6 jetson-tk1 mmcblk0p1[/code] You should look: [code]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. ***[/code] IF FLASH FAILED and message is: "[b]mapping system.img to loop device failed.[/b]" edit flash.sh on line 284: [code]losetup /dev/loop0 system.img > /dev/null 2>&1[/code] replace to: [code]losetup --find --show system.img[/code] thanks [b]linuxdev[/b] - [url=https://devtalk.nvidia.com/default/topic/760912/embedded-systems/flashing-r19-3-mapping-system-img-to-loop-device-failed-/post/4259804/#4259804]more info[/url] [u]e) Reset Jetson (power off-on)[/u] [b]3. On Jetson-TK1[/b] a) Check kernel version [code]uname -a[/code] [code]Linux tegra-ubuntu 3.10.24-grinch #1 SMP PREEMPT Sun Jul 20 18:31:40 CEST 2014 armv7l armv7l armv7l GNU/Linux[/code] b) Copy extra modules from NVIDIA kernel [code]sudo cp -rv /lib/modules/3.10.24-gf455cd4/extra /lib/modules/`uname -r`/ sudo depmod -a[/code] Well done. You have own kernel! p.s. sorry for my english :)
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 :)
#1
Posted 07/20/2014 05:11 PM   
Thank You!
Thank You!

My Public PGP Key: http://pastebin.com/PYB2Afbc

#2
Posted 07/20/2014 06:57 PM   
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.
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.

#3
Posted 07/20/2014 09:18 PM   
thanks linuxdev - i'm update guide 2d) and 3b)
thanks linuxdev - i'm update guide 2d) and 3b)
#4
Posted 07/20/2014 10:41 PM   
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.
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.

#5
Posted 07/21/2014 02:53 PM   
@linuxdev: If I flash jetson to use u-boot, I can later come back to fastboot by use NVIDIA flash.sh procedure?
@linuxdev: If I flash jetson to use u-boot, I can later come back to fastboot by use NVIDIA flash.sh procedure?
#6
Posted 07/21/2014 09:53 PM   
[quote="Santyago"]@linuxdev: If I flash jetson to use u-boot, I can later come back to fastboot by use NVIDIA flash.sh procedure?[/quote] 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 said:@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.

#7
Posted 07/21/2014 10:05 PM   
@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?
@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?

#8
Posted 07/24/2014 08:46 AM   
i will try in weekend your procedure with cross-build, and I'll let you know
i will try in weekend your procedure with cross-build, and I'll let you know
#9
Posted 07/24/2014 06:36 PM   
[quote="extend_chen"]@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?[/quote] 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.
extend_chen said:@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 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.

#10
Posted 07/24/2014 08:36 PM   
@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
@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

#11
Posted 07/25/2014 03:33 AM   
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
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

My Public PGP Key: http://pastebin.com/PYB2Afbc

#12
Posted 07/29/2014 06:54 PM   
[quote="Pyrex"]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[/quote] 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.
Pyrex said: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.

#13
Posted 07/29/2014 08:58 PM   
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?
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?

#14
Posted 07/31/2014 10:55 PM   
Ok, so I'm missing nvidia drivers. Specifically hdmi audio. I've followed the guide and am booting from my kernel. Any ideas?
Ok, so I'm missing nvidia drivers. Specifically hdmi audio. I've followed the guide and am booting from my kernel. Any ideas?

#15
Posted 08/05/2014 03:12 AM   
Scroll To Top

Add Reply