i.MX 8 Hello World Linux - ArmV7a 32-bit and ArmV8a 64-bit

cancel
Showing results for 
Search instead for 
Did you mean: 

i.MX 8 Hello World Linux - ArmV7a 32-bit and ArmV8a 64-bit

i.MX 8 Hello World Linux - ArmV7a 32-bit and ArmV8a 64-bit

NXP i.MX 8 series of application processors support running ArmV8a 64-bit and ArmV7a 32-bit user space programs.  A Hello World program that prints the size of a long int is cross-compiled as 32-bit and as 64-bit from an Ubuntu host and then each is copied to MCIMX8MQ-EVK and run.

Resources:

Source Code:

Create a file with contents below using your favorite editor, example name hello-sizeInt.c.

#include <stdio.h>

int main (int argc, char **argv)
{
 printf ("Hello World, size of long int: %zd\n", sizeof (long int));
 return 0;
}‍‍‍‍‍‍‍

Ubuntu host packages:

$ sudo apt-get install -y gcc-arm-linux-gnueabihf
$ sudo apt-get install -y gcc-aarch64-linux-gnu‍‍

Line 1 installs the ArmV7a cross-compile tools: arm-linux-gnueabihf-gcc is used to cross compile on Ubuntu host

Line 2 install the ArmV8a cross-compile tools: aarch64-linux-gnu-gcc is used to cross compile on Ubuntu host

Create Linux User Space Applications

Build each application and use the static option to gcc to include run time libraries.

Build ArmV7a 32-bit application:

$ arm-linux-gnueabihf-gcc -static hello-sizeInt.c -o hello-armv7a‍-static

Build ArmV8a 64-bit application:

$ aarch64-linux-gnu-gcc -static  hello-sizeInt.c -o hello-armv8a‍-static

Copy Hello applications from Ubuntu host and run on MCIMX8MQ-EVK

Using a SDCARD written with images from L4.9.88_2.0.0 Linux release (see resources for image link), power on EVK with Ethernet connected to network and Serial Console port which was connected to a windows 10 PC. Launched a terminal client (TeraTerm) to access console port. Login credentials: root and no password needed. Since Ethernet was connected a DHCP IP address was acquired, 192.168.1.241 on the EVK.  On the Ubuntu host, secure copy the hello applications to EVK:

$ scp hello-armv7a-static root@192.168.1.241:~/
hello-armv7a-static                           100%  389KB   4.0MB/s   00:00    

$ scp hello-armv8a-static root@192.168.1.241:~/
hello-armv8a-static                           100%  605KB   4.7MB/s   00:00 ‍‍‍‍‍

Run:

root@imx8mqevk:~# ./hello-armv8a-static
Hello World, sizeof long int: 8
root@imx8mqevk:~# ./hello-armv7a-static
Hello World, sizeof long int: 4‍‍‍‍
Version history
Revision #:
2 of 2
Last update:
‎09-10-2020 01:37 AM
Updated by:
 
Contributors