The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.
Difference between revisions of "Funtoo on the Nvidia TK1"
m (→Flash the TK1) |
m |
||
(45 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
This is the barest outline of a method for getting Funtoo with a custom kernel on to the Nvidia Jetson TK1 development board. To avoid complications fastboot is used as the bootloader intead of the default u-boot, but much more sophisticated network and nfs boots are possible. | |||
Environment variables and bash functions referred to are defined here [http://www.funtoo.org/Crossdev_Automation]. | |||
== Getting the Sources == | == Getting the Sources == | ||
Use the tools issued by Nvidia to handle kernel sources via git. Checkout the desired kernel version, probably the | Use the tools issued by Nvidia to handle kernel sources via git. Checkout the desired kernel version, which probably should match the version of the driver package (RXX-X), update the environment variables and create a branch named by the kernel version. | ||
{{console|body= | {{console|body= | ||
# wget http://developer.nvidia.com/embedded/dlc/l4t-Jetson-TK1-Driver-Package-R21-5 -O $TOOLS/l4t-Jetson-TK1-Driver-Package-R21-5 | # wget http://developer.nvidia.com/embedded/dlc/l4t-Jetson-TK1-Driver-Package-R21-5 -O $TOOLS/l4t-Jetson-TK1-Driver-Package-R21-5 | ||
Line 17: | Line 15: | ||
# cd sources/kernel_source | # cd sources/kernel_source | ||
# git ls-remote | # git ls-remote | ||
# git checkout tegra-l4t- | # git checkout tegra-l4t-r21.5 | ||
# ln -s $PWD $XC_KERNEL_SRC | # ln -s $PWD $XC_KERNEL_SRC | ||
# . xcompile_variables.sh | # . xcompile_variables.sh | ||
Line 47: | Line 45: | ||
# cp $XC_KERNEL_OLDCONFIG .config | # cp $XC_KERNEL_OLDCONFIG .config | ||
# ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make oldconfig | # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make oldconfig | ||
# ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make menuconfig | |||
# ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make zImage modules dtbs | # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make zImage modules dtbs | ||
}} | |||
== Download and Configure Stage3 == | |||
See http://www.funtoo.org/Crossdev_Automation#Stage3_Configuration | |||
Don't configure fstab and leave a serial console configured on ttyS0 in $XC_STAGES/etc/inittab. Now dig out that old 2$ RS-232 null modem cable - if you have the right interface on your box. Or else pay $40 for a usb to RS-232 with an fdti chip in it. You can also just plug a monitor into the hdmi. | |||
{{console|body= | |||
# echo "# UNCONFIGURED FSTAB FOR BASE SYSTEM" > $XC_STAGE3S/fstab | |||
# cat $XC_STAGE3S/etc/inittab {{!}} grep ttyS0 | |||
s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100 | |||
}} | |||
== Install Super Special Blobs == | |||
Make a link to our stage 3 and copy over nvidia binaries to it. | |||
{{console|body= | |||
# cd $TOOLS/Linux_for_Tegra | |||
# rmdir rootfs | |||
# ln -s $XC_STAGE3S rootfs | |||
# ./apply_binaries.sh | |||
}} | }} | ||
Line 61: | Line 81: | ||
}} | }} | ||
== Flash the TK1 == | == Flash the TK1 == | ||
{{warning|You should really only flash the root file system ONCE, upon initial install of Funtoo to the board. Doing so again will overwrite any changes and configurations and installations you have done. | |||
You will probably flash the kernel many times as you tweak it.}} | |||
Put your system into “reset recovery mode” by holding down the “RECOVERY” button and press “RESET” button once on the main board. | Put your system into “reset recovery mode” by holding down the “RECOVERY” button and press “RESET” button once on the main board. | ||
Ensure your Linux host system is connected to the target device through the USB cable for flashing. | Ensure your Linux host system is connected to the target device through the micro-USB port with the provided cable for flashing. | ||
{{console|body= | {{console|body= | ||
# lsusb | # lsusb {{!}} grep -i nvidia | ||
Bus 003 Device 002: ID 0955:7140 NVidia Corp. | Bus 003 Device 002: ID 0955:7140 NVidia Corp. | ||
}} | }} | ||
Now flash the root file system. We only flash 8GiB of the 14580MiB available to save time. Total time will depend on size of the transferred sparse image after a comparison with what is already on the tk1. | |||
{{console|body= | |||
# cd $TOOLS/Linux_for_Tegra | |||
# ln -sf $XC_STAGE3 rootfs | |||
# ./flash.sh -S 8GiB -L bootloader/fastboot.bin jetson-tk1 mmcblk0p1 | |||
copying bctfile(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/ardbeg/BCT/PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg)... done. | |||
Existing bootloader(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/fastboot.bin) reused. | |||
making zero initrd... | |||
done. | |||
Making Boot image... done. | |||
Making system.img... | |||
populating rootfs from /usr/src/fun_kernel/stage3s/TK1/funtoo-current/arm-32bit/armv7a_neonvfpv4_hardfp ... done. | |||
Sync'ing system.img ... done. | |||
Converting RAW image to Sparse image... | |||
---- Raw to Sparse Image Converter v1.0 ---------------------------- | |||
0: RAW: 4214784( 1029 blks) ==> 28:4214796 | |||
1: SKP: 49152( 12 blks) ==> 4214824:49164 | |||
2: RAW: 8192( 2 blks) ==> 4214836:8204 | |||
...<lots of output>... | |||
Create, format and download took 91 Secs | |||
Time taken for flashing 95 Secs | |||
*** The target ardbeg has been flashed successfully. *** | |||
Reset the board to boot from internal eMMC. | |||
}} | |||
The board may or may not reboot at this point. Make sure it is back in recovery mode and attached to your cross compiling host as a usb device. | |||
Flash the kernel to the partition id LNX. Cross your fingers. | |||
{{console|body= | |||
# cd $TOOLS/Linux_for_Tegra | |||
#./flash.sh -k LNX -L bootloader/fastboot.bin -K $XC_KERNEL_SRC/arch/arm/boot/zImage jetson-tk1 mmcblk0p1 | |||
copying bctfile(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/ardbeg/BCT/PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg)... done. | |||
Existing bootloader(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/fastboot.bin) reused. | |||
making zero initrd... | |||
done. | |||
Making Boot image... done. | |||
Making system.img... | |||
populating rootfs from /mnt/Workspace/Jetson/21-5/Linux_for_Tegra/rootfs ... done. | |||
Sync'ing system.img ... done. | |||
Converting RAW image to Sparse image... | |||
---- Raw to Sparse Image Converter v1.0 ---------------------------- | |||
0: RAW: 4231168( 1033 blks) ==> 28:4231180 | |||
1: SKP: 40960( 10 blks) ==> 4231208:40972 | |||
2: RAW: 4096( 1 blks) ==> 4231220:4108 | |||
...<lots o output>... | |||
Time taken for flashing 4 Secs | |||
*** The 6:LNX has been updated successfully. *** | |||
}} | |||
{{Tip|Once you get a stage 3 booted, you can just flash the kernel and transfer the modules via rsync over ssh once the new kernel has come up. It helps to have a kernel that can load without any modules, or else you have to flash the /lib directory on the tegra along with the kernel. That's not covered here. | |||
Make sure you DON'T flash the root file system again! | |||
}} | |||
== Issues == | |||
How do the nvidia binaries interact with portage? The follow are regular outputs from emerge. What causes this? | |||
{{console|body= | {{console|body= | ||
/sbin/ldconfig: /lib/libip6tc.so.0 is not a symbolic link | |||
/sbin/ldconfig: /lib/libusb-1.0.so.0 is not a symbolic link | |||
/sbin/ldconfig: /lib/libncurses.so.6 is not a symbolic link | |||
/sbin/ldconfig: /lib/libblkid.so.1 is not a symbolic link | |||
/sbin/ldconfig: /lib/libz.so.1 is not a symbolic link | |||
/sbin/ldconfig: /lib/libprocps.so.6 is not a symbolic link | |||
/sbin/ldconfig: /lib/libacl.so.1 is not a symbolic link | |||
/sbin/ldconfig: /lib/libpam.so.0 is not a symbolic link | |||
/sbin/ldconfig: /lib/libxfs.so.0 is not a symbolic link | |||
/sbin/ldconfig: /lib/libiptc.so.0 is not a symbolic link | |||
/sbin/ldconfig: /lib/libss.so.2 is not a symbolic link | |||
}} | }} |
Latest revision as of 03:25, February 17, 2019
Introduction
This is the barest outline of a method for getting Funtoo with a custom kernel on to the Nvidia Jetson TK1 development board. To avoid complications fastboot is used as the bootloader intead of the default u-boot, but much more sophisticated network and nfs boots are possible.
Environment variables and bash functions referred to are defined here [1].
Getting the Sources
Use the tools issued by Nvidia to handle kernel sources via git. Checkout the desired kernel version, which probably should match the version of the driver package (RXX-X), update the environment variables and create a branch named by the kernel version.
root # wget http://developer.nvidia.com/embedded/dlc/l4t-Jetson-TK1-Driver-Package-R21-5 -O $TOOLS/l4t-Jetson-TK1-Driver-Package-R21-5 root # cd $TOOLS root # tar jxf l4t-Jetson-TK1-Driver-Package-R21-5 root # rm l4t-Jetson-TK1-Driver-Package-R21-5 root # cd Linux_for_Tegra root # ./source_sync.sh #skip tag selection both times root # cd sources/kernel_source root # git ls-remote root # git checkout tegra-l4t-r21.5 root # ln -s $PWD $XC_KERNEL_SRC root # . xcompile_variables.sh root # git checkout -b `get_kernel_version`
Kernel Building
You need a working kernel config. You can get one from a running TK1 and get it into your $XC_KERNEL_SRC directory.
root # zcat /proc/config.gz > my_TK1_config root # scp my_TK1_config <xc_user>@<xc_host>:~ root # cp ~/my_TK1_config $CONFIGS/`get_kernel_version`.kconf
Or you can get it from the kernel headers.
root # cd $TOOLS/Linux_for_Tegra/kernel root # tar xvf kernel_headers.tbz2 root # cp linux-headers-<kernel_version>/.config $CONFIGS/`get_kernel_version`.kconf
Make the Kernel
root # . xcompile_variables.sh root # cd $XC_KERNEL_SRC root # cp $XC_KERNEL_OLDCONFIG .config root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make oldconfig root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make menuconfig root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- make zImage modules dtbs
Download and Configure Stage3
See http://www.funtoo.org/Crossdev_Automation#Stage3_Configuration
Don't configure fstab and leave a serial console configured on ttyS0 in $XC_STAGES/etc/inittab. Now dig out that old 2$ RS-232 null modem cable - if you have the right interface on your box. Or else pay $40 for a usb to RS-232 with an fdti chip in it. You can also just plug a monitor into the hdmi.
root # echo "# UNCONFIGURED FSTAB FOR BASE SYSTEM" > $XC_STAGE3S/fstab root # cat $XC_STAGE3S/etc/inittab | grep ttyS0 s0:12345:respawn:/sbin/agetty -L 115200 ttyS0 vt100
Install Super Special Blobs
Make a link to our stage 3 and copy over nvidia binaries to it.
root # cd $TOOLS/Linux_for_Tegra root # rmdir rootfs root # ln -s $XC_STAGE3S rootfs root # ./apply_binaries.sh
Copy over Everything
root # cd $XC_KERNEL_SRC root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- INSTALL_MOD_PATH=$XC_STAGE3S INSTALL_MOD_STRIP=1 make modules_install root # ARCH=$ARCH CROSS_COMPILE=$CROSSDEV_TARGET- INSTALL_MOD_PATH=$XC_STAGE3S make firmware_install root # rsync -avz $XC_FIRMWARE/ $XC_STAGE3S/lib/firmware root # rsync -avz arch/arm/boot/zImage $XC_STAGE3S/boot root # rsync -avz arch/arm/boot/dts/*.dtb $XC_STAGE3S/boot root # rm $XC_STAGE3S/lib/modules/`get_kernel_release`/{build,source}
Flash the TK1
You should really only flash the root file system ONCE, upon initial install of Funtoo to the board. Doing so again will overwrite any changes and configurations and installations you have done.
You will probably flash the kernel many times as you tweak it.
Put your system into “reset recovery mode” by holding down the “RECOVERY” button and press “RESET” button once on the main board.
Ensure your Linux host system is connected to the target device through the micro-USB port with the provided cable for flashing.
root # lsusb | grep -i nvidia Bus 003 Device 002: ID 0955:7140 NVidia Corp.
Now flash the root file system. We only flash 8GiB of the 14580MiB available to save time. Total time will depend on size of the transferred sparse image after a comparison with what is already on the tk1.
root # cd $TOOLS/Linux_for_Tegra root # ln -sf $XC_STAGE3 rootfs root # ./flash.sh -S 8GiB -L bootloader/fastboot.bin jetson-tk1 mmcblk0p1 copying bctfile(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/ardbeg/BCT/PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg)... done. Existing bootloader(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/fastboot.bin) reused. making zero initrd... done. Making Boot image... done. Making system.img... populating rootfs from /usr/src/fun_kernel/stage3s/TK1/funtoo-current/arm-32bit/armv7a_neonvfpv4_hardfp ... done. Sync'ing system.img ... done. Converting RAW image to Sparse image... ---- Raw to Sparse Image Converter v1.0 ---------------------------- 0: RAW: 4214784( 1029 blks) ==> 28:4214796 1: SKP: 49152( 12 blks) ==> 4214824:49164 2: RAW: 8192( 2 blks) ==> 4214836:8204 ...<lots of output>... Create, format and download took 91 Secs Time taken for flashing 95 Secs *** The target ardbeg has been flashed successfully. *** Reset the board to boot from internal eMMC.
The board may or may not reboot at this point. Make sure it is back in recovery mode and attached to your cross compiling host as a usb device.
Flash the kernel to the partition id LNX. Cross your fingers.
root # cd $TOOLS/Linux_for_Tegra root #./flash.sh -k LNX -L bootloader/fastboot.bin -K $XC_KERNEL_SRC/arch/arm/boot/zImage jetson-tk1 mmcblk0p1 copying bctfile(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/ardbeg/BCT/PM375_Hynix_2GB_H5TC4G63AFR_H5TC4G63CFR_RDA_924MHz.cfg)... done. Existing bootloader(/usr/src/fun_kernel/tools/TK1/Linux_for_Tegra/bootloader/fastboot.bin) reused. making zero initrd... done. Making Boot image... done. Making system.img... populating rootfs from /mnt/Workspace/Jetson/21-5/Linux_for_Tegra/rootfs ... done. Sync'ing system.img ... done. Converting RAW image to Sparse image... ---- Raw to Sparse Image Converter v1.0 ---------------------------- 0: RAW: 4231168( 1033 blks) ==> 28:4231180 1: SKP: 40960( 10 blks) ==> 4231208:40972 2: RAW: 4096( 1 blks) ==> 4231220:4108 ...<lots o output>... Time taken for flashing 4 Secs *** The 6:LNX has been updated successfully. ***
Once you get a stage 3 booted, you can just flash the kernel and transfer the modules via rsync over ssh once the new kernel has come up. It helps to have a kernel that can load without any modules, or else you have to flash the /lib directory on the tegra along with the kernel. That's not covered here.
Make sure you DON'T flash the root file system again!
Issues
How do the nvidia binaries interact with portage? The follow are regular outputs from emerge. What causes this?
/sbin/ldconfig: /lib/libip6tc.so.0 is not a symbolic link /sbin/ldconfig: /lib/libusb-1.0.so.0 is not a symbolic link /sbin/ldconfig: /lib/libncurses.so.6 is not a symbolic link /sbin/ldconfig: /lib/libblkid.so.1 is not a symbolic link /sbin/ldconfig: /lib/libz.so.1 is not a symbolic link /sbin/ldconfig: /lib/libprocps.so.6 is not a symbolic link /sbin/ldconfig: /lib/libacl.so.1 is not a symbolic link /sbin/ldconfig: /lib/libpam.so.0 is not a symbolic link /sbin/ldconfig: /lib/libxfs.so.0 is not a symbolic link /sbin/ldconfig: /lib/libiptc.so.0 is not a symbolic link /sbin/ldconfig: /lib/libss.so.2 is not a symbolic link