From Gentoo Wiki
Jump to:navigation Jump to:search

This article briefly describes the process of imaging a NVIDIA Jetson TX2 with Gentoo aarch64 from an amd64 host.


1. Configure and install QEMU (if you wish to chroot into your image from the host machine)

root #echo 'QEMU_SOFTMMU_TARGETS="aarch64 x86_64"' >> /etc/portage/make.conf
root #echo 'QEMU_USER_TARGETS="aarch64"' >> /etc/portage/make.conf
root #echo app-emulation/qemu static-user >> /etc/portage/package.use/qemu
root #echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:' > /proc/sys/fs/binfmt_misc/register
root #echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-aarch64:' > /etc/binfmt.d/qemu-aarch64-static.conf
root #systemctl restart systemd-binfmt
root #emerge --ask app-emulation/qemu
root #gpasswd -a larry kvm
root #quickpkg app-emulation/qemu

2. Setup an appropriate crossdev toolchain:

root #emerge --ask sys-devel/crossdev
root #mkdir -p /var/db/repos/crossdev/{profiles,metadata}
root #echo 'crossdev' > /var/db/repos/crossdev/profiles/repo_name
root #echo 'masters = gentoo' > /var/db/repos/crossdev/metadata/layout.conf
root #echo 'thin-manifests = true >> /var/db/repos/crossdev/metadata/layout.conf
root #chown -R portage:portage /var/db/repos/crossdev
FILE /etc/portage/repos.conf/crossdev.conf
location = /var/db/repos/crossdev
priority = 10
masters = gentoo
auto-sync = no
root #crossdev --stable -t aarch64-linux-gnueabi

Creating an Image

1. Create a development space for your device and extract the L4T driver package from NVIDIA.

user $mkdir -p ~/development/jetson_tx2
user $cd ~/development/jetson_tx2
user $tar xvfj jetson_linux_r32.7.2_aarch64.tbz2
user $cd Linux_for_tegra

2. Download and extract the latest arm64 stage3 tarball and portage snapshot.

root #cd var/db/repos
root #mv portage gentoo

3. Apply the supplied Tegra kernel and modules.

root #cd ../../../
root #./apply_binaries.sh

4. Set the root password

root #cd rootfs
root #ROOTPASS=$(openssl passwd -6 -salt xyz «your_password_here»)
root #sed -i -e "s,^root:[^:]\+:,root:${ROOTPASS}:," etc/shadow

5. Create a non-root user

root #USERNAME=larry
root #USERPASS=$(openssl passwd -6 -salt xyz «your_password_here»)
root #mkdir -p home/${USERNAME} && cp -R etc/skel/* home/${USERNAME}/
root #chown -R ${USERNAME}:${USERNAME} home/${USERNAME}
root #chmod -R go=u,go-w home/${USERNAME} && chmod go= home/${USERNAME}
root #echo "${USERNAME}:x:1000:1000::/home/${USERNAME}:/bin/bash" >> /etc/passwd
root #echo "${USERNAME}:x:1000:" >> /etc/group
root #for group in wheel audio video users;
root # do sed -i "/^${group}:/ s/$/ ${USERNAME}/" /etc/group; done

6. Customise your system image! Emerge QEMU into the target and chroot.

root #ROOT=$PWD/ emerge --usepkgonly --oneshot --nodeps qemu
root #mount --bind /proc proc
root #mount --bind /sys sys
root #mount --bind /dev dev
root #mount --bind /dev/pts dev/pts
root #chroot . /bin/bash --login

Flashing the Image

1. Connect your device to power and via the USB recovery port to your computer.

2. Power on the board, hold the recovery button then press the reset button.

3. Enter the following command to flash your image and kernel to the device:

root #flash.sh -C console=ttyS1,115200 -C console=tty0 jetson-tx2 «root_device»

Where root_device is:

  • sda1 for SATA or USB devices
  • mmcblk1p1 for an attached SD card
  • mmcblk0p1 for the internal eMMC