This article describes configuring a cross-compilation toolchain on a PC using Ubuntu Linux to target an ARM64 target such as the NXP i.MX 8M Plus. For alternative toolchains, please refer to the sibling articles.
- Building VisionPack Applications with Yocto Toolchains
- Building VisionPack Applications with Docker Toolchains
- Ubuntu 20.04 or newer or Debian Buster or newer.
- Either can be installed through the Windows Subsystem for Linux.
- VisionPack installed onto a compatible target device.
Typical workstations use an Intel x86_64 (amd64) processor running Windows or Linux, while embedded devices typically use an ARM Cortex-A application processor. This article is focused on newer generation 64-bit Cortex-A processors, known as the aarch64 or arm64 architecture. To build native applications on the Intel workstation that can be run on the ARM embedded target a cross-compiler is required. Debian and Ubuntu Linux both provide not only the cross-compiler but also a mechanism for installing foreign architecture libraries needed to build applications with wide dependencies.
The VisionPack libraries are made available as multi-architecture Debian-compatible packages. This makes the installation of the toolchain easy through the standard "apt-get" tool.
Note: we cover some important steps which are missing from the Ubuntu multi-arch instructions. Namely the fact that Intel and non-Intel repositories are hosted at different locations requiring modifications to the base sources.list as well as creation of a new ubuntu-arm64.list pointing to the "ports".
The first step is to confirm the architecture of your host workstation. If it is arm64, you can close this article and read about VisionPack for Debian Packages. You're already using the target architecture and do not require a cross-compiler.
For most users, the above command will report amd64 or possibly i386. In these cases, you will need to add the aarch64/arm64 foreign architecture.
dpkg --add-architecture arm64
At this point you Debian/Ubuntu system is ready to work with apt and arm64 packages. The next section covers how to fix a bug in how the apt repositories are managed.
The problem now is when you try to run "apt update" you will get 404 errors for all the arm64 packages. This is because Ubuntu hosts the Intel packages at archive.ubuntu.com while non-Intel packages are at ports.ubuntu.com and, of course, adding the foreign architecture does not properly handle this gap.
The first step will be to add the arm64 ports, we've included in this article ubuntu-REL-arm64.list files which you can save to /etc/apt/sources.list.d for your Ubuntu release. Make sure to take the REL that corresponds to your release, as shown in /etc/os-release under UBUNTU_CODENAME. If your version is missing you can simply edit the provided version, such as focal, and replace the focal with the appropriate version such as jammy.
cp ubuntu-focal-arm64.list /etc/apt/sources.list.d/ubuntu-jammy-arm64.list
sed -i 's/focal/jammy/g' /etc/apt/sources.list.d/ubuntu-jammy-arm64.list
Now when you run "apt update" you will continue to see the 404 errors but the arm64 packages will be found. The final step is to clean up the base /etc/apt/sources.list file to ensure it only checks amd64 packages, the following script can handle that.
sed -i 's/deb http/deb [arch=amd64] http/g' /etc/apt/sources.list
Create the file /etc/apt/sources.list.d/deepviewml.list with the following content (you can also download the file from the attachments).
deb [signed-by=/usr/share/keyrings/deepviewml.gpg] https://deepviewml.com/apt stable main
Next, save the deepviewml.gpg key to /usr/share/keyrings/deepviewml.gpg either by downloading from the attachments or by running the following command.
sudo curl https://deepviewml.com/apt/deepviewml.gpg -o /usr/share/keyrings/deepviewml.gpg
Additional instructions are provided in the article Debian Packages for VisionPack.
You will now have the working toolchain to build the provided detect.c sample for the target's ARM processor.
aarch64-linux-gnu-gcc -o detect detect.c -lvaal