Difference between revisions of "Jetson/Filesystem Emulation/Emulating Jetson Filesystem with QEMU and CHROOT"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | |||
− | |||
− | |||
== Setting up the Target Device == | == Setting up the Target Device == | ||
Line 50: | Line 47: | ||
$ sudo cp /usr/bin/qemu-aarch64-static $HOME/jetsonfs/usr/bin/ | $ sudo cp /usr/bin/qemu-aarch64-static $HOME/jetsonfs/usr/bin/ | ||
− | + | Now you should be able to chroot into the mounted filesystem with the following command: | |
− | uname -m | + | $ sudo chroot $HOME/jetsonfs |
+ | To verify whether chroot emulated filesystem corresponds to an ARM-based one: | ||
+ | |||
+ | $ uname -m | ||
The console output should look like the following: | The console output should look like the following: | ||
aarch64 | aarch64 | ||
− | + | From inside chroot, go to the desired MMAPI sample folder and build it. | |
− | |||
− | |||
− | From inside | ||
$ cd /usr/src/jetson_multimedia_api/samples/00_video_decode | $ cd /usr/src/jetson_multimedia_api/samples/00_video_decode | ||
Line 69: | Line 66: | ||
== Copying the binaries to the device == | == Copying the binaries to the device == | ||
− | + | The artifacts and produced binaries will be present in the mounted filesystem when chroot is exited. You can copy the binaries into the Jetson device for executing. | |
− | |||
− | |||
− | |||
− | $ sudo | + | $ sudo cp $HOME/jetsonfs/usr/src/jetson_multimedia_api/00_video_decode/video_decode /$HOME |
Lastly copy the binaries to the target device (here connected over USB) | Lastly copy the binaries to the target device (here connected over USB) | ||
$ sudo cd ~ | $ sudo cd ~ | ||
$ sudo scp ./video_decode jetson@192.168.55.1:~ | $ sudo scp ./video_decode jetson@192.168.55.1:~ |
Latest revision as of 08:09, 18 May 2021
Contents
Setting up the Target Device
From the L4T Archive, download the desired L4T Driver Package and corresponding sample filesystem.
Flash the target device following the instructions described here.. After flashing, the device will reboot. Please configure the device at first boot and log into the OS.
Installing the Dependencies
The dependencies to be installed are specific to the task to be performed on the emulated filesystem. For the sake of exemplification, the Jetson Multimedia API samples will be compiled, therefore the dependencies are set for this purpose.
For more details, please see the documentation for the Multimedia API Sample Applications.
On the target, issue the following commands:
$ sudo apt update $ apt list --upgradable $ sudo apt upgrade $ sudo apt install nvidia-jetpack
Clone Your Device's Image
After installing the JetPack, shut down the device and set it into recovery mode.
Now, on the host PC, issue the following commands to clone your device's image.
$ cd <path_to_L4T> $ sudo ./flash.sh -r -k APP -G <name_of_the_img> <target> mmcblk0p1
Setting up Emulation Environment
Install docker and Nvidia Container Runtime. See instructions here.
Install QEMU and dependencies:
$ sudo apt-get update $ sudo apt-get install qemu binfmt-support qemu-user-static schroot
Mount your target filesystem
$ mkdir $HOME/jetsonfs $ sudo mount -t ext4 <path_to_image>/<name_of_image>.img.raw $HOME/jetsonfs
You can find the Jetson Multimedia API in the mounted file system under following path:
/usr/src/jetson_multimedia_api
Emulating the Filesystem
To be able to emulate the mounted jetson filesystem, first copy QEMU from the host machine into the mounted filesystem:
$ sudo cp /usr/bin/qemu-aarch64-static $HOME/jetsonfs/usr/bin/
Now you should be able to chroot into the mounted filesystem with the following command:
$ sudo chroot $HOME/jetsonfs
To verify whether chroot emulated filesystem corresponds to an ARM-based one:
$ uname -m
The console output should look like the following:
aarch64
From inside chroot, go to the desired MMAPI sample folder and build it.
$ cd /usr/src/jetson_multimedia_api/samples/00_video_decode $ make
For larger tasks, you can assign the a larger number of jobs to the build. The number of jobs usually matches the number of available cores. For example, in a system with 12 CPU cores:
$ make -j12
Copying the binaries to the device
The artifacts and produced binaries will be present in the mounted filesystem when chroot is exited. You can copy the binaries into the Jetson device for executing.
$ sudo cp $HOME/jetsonfs/usr/src/jetson_multimedia_api/00_video_decode/video_decode /$HOME
Lastly copy the binaries to the target device (here connected over USB)
$ sudo cd ~ $ sudo scp ./video_decode jetson@192.168.55.1:~