How To Compile Firmwares for the Alternative Cores (NXP)
Introduction
This article will guide you through the process of compiling firmware using the MCUXpresso SDK (Software Development Kit).
This article complies with the typographic conventions.
Typographic Conventions
Throughout the Toradex documentation, the following typographic conventions are used:
$ (dollar sign) Command in the host computer (e.g. your PC)
$ Command in your PC
$$ (double dollar sign) Command in a container in the host computer (e.g. your PC)
$$ Command inside a container in your PC
# (hashtag) Command in the target device/board (e.g. Linux terminal)
# Command in the target board, e.g. Colibri iMX6
## (double hashtag) Command inside a container in the target device (Torizon)
## Command inside a container in Torizon
> (greater-than sign) Command in the bootloader (e.g. U-Boot console)
> Command in the Bootloader
No symbol: Command output
$ Command waiting for output
Output
Prerequisites
You must have cmake installed in your system. In Debian based OSs, this can be achieved by running
$ sudo apt install cmake
Understanding NXP's SDK Structure
In this article, ${SDK_INSTALL_PATH} refers to path where the SDK is installed. For example, in Linux, ${SDK_INSTALL_PATH} refers to ${HOME}/hmp. Besides that, <processor> refers to the SoC name.
Most example applications provided by NXP's MCUXpresso are available at ${SDK_INSTALL_PATH}/boards/<processor>. Within each example folder, you will find all the necessary files to build the firmware, as shown below:
$ cd ${SDK_INSTALL_PATH}/boards/<processor>
$ tree -L 1
.
├── cmsis_driver_examples
├── demo_apps
├── driver_examples
├── mekmimx8qx.png
├── multicore_examples
├── project_template
└── rtos_examples
7 directories, 1 file
The following section describes how to compile the Hello World example, which is available at ${SDK_INSTALL_PATH}/boards/<processor>/demo_apps, for the Colibri iMX8X.
Compiling Your First Firmware
Compiling the Hello World Example
If you are compiling this code for Apalis iMX8, you will see an additional folder to choose for which Cortex-M core you want to build your code. You can choose either core 1 or core 0.
Enter the build folder:
$ cd ./boards/<PROCESSOR_ID>/demo_apps/hello_world/armgcc/
There are several build scripts in this folder. We will use the build_debug.sh for this tutorial, but you can use the others scripts as well. Before running the script tough, we need to export the ARMGCC_DIR environment variable. This variable must store the root directory of the GCC toolchain.
$ export ARMGCC_DIR=~/hmp/toolchain/<GCC_TOOLCHAIN_FOLDER>
$ ./build_debug.sh
After the build is completed, you will find the compiled binary inside the armgcc/debug folder. To learn how to deploy the firmware, refer to How To Load Compiled Firmwares Into Alternative Cores article.