Developing Standalone Linux Applications Print

 

Development of standalone Linux applications relies on the ARM GCC toolchain included in the Yocto SDK. The SDK is built as part of the Yocto Linux build procedure, and is packaged into a self-installing archive with the following name:
fsl-imx-wayland-glibc-x86_64-image-pmd-debug-aarch64-toolchain-5.4-zeus.sh.

A archive with prebuilt Yocto SDK can be downloaded from the following link: Yocto SDK

Being on your Linux cross-development host, go through the steps described below to install the C/C++ SDK and develop standalone Linux applications (those built outside of the Yocto build).


Installing C/C++ SDK

The Yocto SDK is installed on the Linux development host using the following command:

[user@localhost ~]$ chmod 755 fsl-imx-wayland-glibc-x86_64-image-pmd-debug-aarch64-toolchain-5.4-zeus.sh
[user@localhost ~]$ sudo /bin/bash fsl-imx-wayland-glibc-x86_64-image-pmd-debug-aarch64-toolchain-5.4-zeus.sh
NXP i.MX Release Distro SDK installer version 5.4-zeus
=======================================================
Enter target directory for SDK (default:/opt/fsl-imx-wayland/5.4-zeus):
You are about to install the SDK to "/opt/fsl-imx-wayland/5.4-zeus". Proceed[Y/n]?
Extracting SDK..................


Activating SDK

After installation, the Yocto SDK environment needs to be activated. The activation process configures paths to the SDK tools and sets up various environment variables, required by the SDK. The environment activation can be done using the following command (which needs to be performed every time a new instance of shell is opened):

[user@localhost ~]$ source /opt/fsl-imx-wayland/5.4-zeus/environment-setup-aarch64-poky-linux


Building Linux Application

Let's go through the step required to develop and build a simple "Hello, world" C application.

  1. Being on the Linux cross-development host, use your favorite editor to develop application code:
  2. [user@localhost ~]$ vi hello.c #include int main() { printf("Hello, World!\n"); return 0; }

  3. Exit the editor and build the application, as follows:
  4. [user@localhost ~]$ $CC -o hello hello.c

The resultant hello binary is ready to be tested on the i.MX 8M Mini target.


Running Linux Application

  1. From the Linux host, copy the application binary to the i.MX 8M Mini as follows:
  2. [user@localhost ~]$ scp hello root@192.168.1.10:/tmp

    Note that the i.MX 8M Mini IP address in the above command may differ, depending on your configuration.

  3. From the target serial command monitor, run the application on the i.MX 8M as follows:
  4. root@imx8mmcube2g:~# cd /tmp
    root@imx8mmcube2g:~# ./hello
    Hello, World!