Build and run a 32-bit app on i.MX 8M / i.MX 93

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Build and run a 32-bit app on i.MX 8M / i.MX 93

100% helpful (1/1)

Build and run a 32-bit app on i.MX 8M / i.MX 93

The following setup is done on i.MX 93. For i.MX 8M the same steps are valid and can be followed.

Prerequisites

Prepare the Yocto environment.

$ mkdir imx-yocto-bsp
$ cd imx-yocto-bsp
$ repo init -u https://github.com/nxp-imx/imx-manifest -b imx-linux-langdale -m imx-6.1.1-1.0.0.xml
$ repo sync

 Set the build environment.

$ DISTRO=fsl-imx-wayland MACHINE=imx93-11x11-lpddr4x-evk source imx-setup-release.sh -b build-imx93

Add the 32-bit support to the image

For i.MX 8M / i.MX 93, building 32-bit applications on 64-bit OS can be supported using the multilib configuration. Multilib offers the ability to build libraries with different target optimizations or architecture formats and combine these together into one system image. 

Building a 32-bit application requires the following statements in conf/local.conf. The configuration specifies a 64-bit machine as the main machine type and adds multilib:lib32, where those libraries are compiled with the armv7athf-neon tune, and then includes to the image the lib32 packages.

# Define multilib target
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE:virtclass-multilib-lib32 = "armv7athf-neon"
# Add the multilib packages to the image
IMAGE_INSTALL:append = " lib32-glibc lib32-libgcc lib32-libstdc++"

Multilib is not supported with the debian package management. It requires the RPM system. Check and comment out the two package management lines in conf/local.conf to go to the default RPM.

PACKAGE_CLASSES = "package_deb"
EXTRA_IMAGE_FEATURES += "package-management"

Build the image.

bitbake imx-image-core

Cross-compile a 32-bit application

This section shows how to use the Linux SDK to cross-compile a simple C application into a 32-bit binary.

Generate the SDK, which includes the tools, toolchain, and small rootfs to compile against to put on host machine:

DISTRO=fsl-imx-wayland MACHINE=imx93-11x11-lpddr4x-evk bitbake core-image-minimal -c populate_sdk

Set the SDK environment with the following command before building:

source /opt/fsl-imx-wayland/6.1-langdale/environment-setup-armv7at2hf-neon-pokymllib32-linux-gnueabi

Implement a simple hello world application:

cat hello_world_32.c

#include <stdio.h>
int main() {
   printf("Hello, World!");
   return 0;
}

$CC hello_world_32.c -o hello_world_32

Check the file's type:

$ file hello_world_32
hello_world_32: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=0a5042a0309858e0b10b12175a155cfbfb4c6a80, for GNU/Linux 3.2.0, with debug_info, not stripped                                              

Copy the binary to the Linux rootfs.

Run the application on i.MX 93

Boot the board and run the application:

root@imx93-11x11-lpddr4x-evk:~# ./hello_world_32
Hello, World!

 

Version history
Last update:
‎06-28-2023 01:22 AM
Updated by: