So, the next step it so enter an environment where it’s possible to edit the rootfs. The easiest way to install a python package globally is with either apt-get or pip. Assuming your project is on pypi or GitHub and has a setup.py, it can be installed this way.
First, let’s download a chroot script which will let us enter the rootfs.
ubuntu@tegra-image-maker:~$ git clone https://github.com/mdegans/enter_chroot.git
ubuntu@tegra-image-maker:~$ sudo cp enter_chroot/enter_chroot.sh /usr/bin/
Now that the script is installed, let’s enter the rootfs and run the
arch command to test we can execute aarch64 binaries.
ubuntu@tegra-image-maker:~$ sudo enter_chroot.sh Linux_for_Tegra/rootfs/
+ cp /usr/bin/qemu-aarch64-static Linux_for_Tegra/rootfs//usr/bin
+ mount -t sysfs -o ro none Linux_for_Tegra/rootfs//sys
+ mount -t proc -o ro none Linux_for_Tegra/rootfs//proc
+ mount -t tmpfs none Linux_for_Tegra/rootfs//tmp
+ mount -o bind,ro /dev Linux_for_Tegra/rootfs//dev
+ mount -t devpts none Linux_for_Tegra/rootfs//dev/pts
+ mount -o bind,ro /etc/resolv.conf Linux_for_Tegra/rootfs//run/resolvconf/resolv.conf
+ chroot Linux_for_Tegra/rootfs/
You’re now in a “virtual nano” of sorts you can use to install software from apt repositories or from pip as if you were on the device itself. There are some limitations to what you can do (example, using the GPU is not possible), however simple things like apt or pip will usually work fine. As a example, I’m going to install one of my own python packages, mce.
Apt update and apt install pip3 since it’s not installed by default:
sudo is not needed since we’re already root (in fact it may cause warnings/errors in this case).
root@tegra-image-maker:/# apt update
144 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@tegra-image-maker:/# apt install python3-pip
Setting up python3.6-dev (3.6.9-1~18.04ubuntu1) ...
Setting up libpython3-dev:arm64 (3.6.7-1~18.04) ...
Setting up python3-dev (3.6.7-1~18.04) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Then install the python package itself, which, since we’re root will install to a system python path.
root@tegra-image-maker:/# pip3 install mce
Building wheels for collected packages: mce
Running setup.py bdist_wheel for mce ... done
Stored in directory: /home/ubuntu/.cache/pip/wheels/65/93/26/6ca68cc28171db6639be1dfd917e2747c8d64e76bbf83d28c9
Successfully built mce
Installing collected packages: mce
Successfully installed mce-0.1.3
Note: If a package is available in the apt repos, you should usually prefer that, since they’re tested to play nice with other system pakages.
Note2: For reasons, pip created a
/home/ubuntu folder. that sould be deleted with
rm -rf /home/ubuntu (from within the chroot)
Note3: Mce will not actually work for several reasons, (deepstream is not installed and it hasnt’ been updated to work with DS 5.0)