Warning: Toradex customers rarely need to rebuild SCFW. Please think carefully if you really need to rebuild it.
Note: Apalis iMX8X is phased out, and it is not available for purchase anymore. The latest supported BSP and TorizonCore version is 5.4.0.
The NXP i.MX8/i.MX8X families of processors feature a System Controller Unit (SCU). The SCU is an Arm Cortex-M4 core and is the first processor to boot in the SoC. It has some essential functions in the system such as:
The SCU firmware (SCFW) is in large part provided by NXP, but Toradex slightly modified it for the Apalis iMX8QM/Colibri iMX8QXP. The firmware also loads an intermediate firmware running on the Cortex-A class CPUs: The Trusted Firmware for the Cortex-A (TF-A), previously named ARM Trusted Firmware (ATF). The TF-A then hands over control to U-Boot, which then can boot Linux.
There are some suitable slides of past training provided by NXP to learn more about the SCU and SCFW.
The Toradex Reference Images for Yocto Project already provide the SCFW image. Therefore, Toradex customers rarely need to rebuild SCFW. This article will show the steps to build the SCFW for debugging purposes manually or if you, for any reason, need to modify the SCU's firmware.
You can find the latest pre-built binaries for Toradex SoMs on our GitHub project i.MX-System-Controller-Firmware:
Note: The scfw_tcm.bin
is an older file that you can disregard. We have switched to using a less generic name as mx8qm-apalis-scfw-tcm.bin
for Apalis iMX8.
Note: The scfw_tcm.bin
is an older file that you can disregard. We have switched to using a less generic name as mx8qx-apalis-scfw-tcm.bin
for Apalis iMX8X and mx8qx-colibri-scfw-tcm.bin
for Colibri iMX8X.
We will build the SCFW in a directory called build-scfw
. First, create it and cd
to the directory.
$ mkdir ~/build-scfw
$ cd ~/build-scfw
Look at the Embedded Linux Release Matrix to check which SCFW Porting Kit version corresponds to the SCFW you are building. At the time of this writing, the latest version Toradex BSP uses the SCFW kit version L5.4.70_2.3.3_SCFWKIT-1.7.3
.
After that, download the SCFWKIT directly from NXP (requires a valid account).
Then, extract the top-level SCFWKIT package:
$ tar xf imx-scfw-porting-kit-1.7.3.tar.gz
Now, cd
into the packages folder and launch the .bin package extractor reading and accepting NXP's EULA:
$ cd packages/
$ chmod +x imx-scfw-porting-kit-1.7.3.bin
$ ./imx-scfw-porting-kit-1.7.3.bin
You will need to accept the EULA to extract the package.
This creates another folder imx-scfw-porting-kit
, cd
into its src
subdirectory :
$ cd imx-scfw-porting-kit-1.7.3/src/
Now, extract the desired porting kit (containing mostly binaries but also some sources) specific for your SoM:
$ tar xf scfw_export_mx8qm_b0.tar.gz
$ tar xf scfw_export_mx8qx_b0.tar.gz
Now, get the Apalis iMX8 resp. Colibri iMX8X specific board source files.
$ git clone https://github.com/toradex/i.MX-System-Controller-Firmware.git
And deploy them to the relevant platform/board/ folder
. Once that is done, cd
into the top-level src
folder.
$ cp -r i.MX-System-Controller-Firmware/src/scfw_export_mx8qm_b0/* scfw_export_mx8qm_b0/
$ cp -r i.MX-System-Controller-Firmware/src/scfw_export_mx8qx_b0/* scfw_export_mx8qx_b0/
Look at the packages/imx-scfw-porting-kit-1.7.3/doc/pdf/
, chapter Porting Guide, sub-chapter Tool Chain to check which GNU Toolchain version corresponds to the SCFW you are building. The imx-scfw-porting-kit-1.7.3
version uses the GNU Toolchain version gcc-arm-none-eabi-8-2018-q4-major
.
Download/install the suitable toolchain.
Note: Please Note: The toolchain to build the SCFW begins with gcc-arm-none-eabi-
and it targets bare-metal (No-OS) applications for ARM Cortex-M4. It is a different toolchain from the one that you usually use to build code targetting the Linux kernel (aarch64).
In our example, we will install the toolchain on the ~/gcc-arm-none-eabi-8-2018-q4-major/
directory.
After installing the toolchain, set up the environment variable relevant for building.
$ export ARCH=arm
$ export TOOLS=~/gcc-arm-none-eabi-8-2018-q4-major
$ export CROSS_COMPILE=arm-none-eabi-
$ export PATH=~/gcc-arm-none-eabi-8-2018-q4-major/bin:$PATH
And last but not least, do a clean build.
$ cd scfw_export_mx8qm_b0/
$ make clean; make SOC=MX8QM B=apalis DL=2 R=b0 U=0 V=0 qm
Note: U=2
flag above will select the SCU's tightly coupled UART aka SCU.UART0.RX/TX available on SCU UART test pin for debugging output.
The final binary will be called scfw_tcm.bin and will be at:
$ ls build_mx8qm_b0/scfw_tcm.bin
$ cd scfw_export_mx8qx_b0/
$ make clean; make SOC=MX8QX B=colibri DL=2 R=b0 U=0 V=0 qx
Note: U=2
flag above will select the SCU's tightly coupled UART aka SCU.UART0.RX/TX available on SODIMM pin 144/146 for debugging output.
The final binary will be called scfw_tcm.bin and will be at:
$ ls build_mx8qx_b0/scfw_tcm.bin
To deploy the SCFW, you will need to assembly a boot container. This container is read by the boot device, starting at a specific offset. See the Build U-Boot and Linux Kernel from Source Code for instruction about how to assembly a boot container.
The NXP's extracted SCFWKIT has further documentation about SCFW at:
$ packages/imx-scfw-porting-kit/doc/pdf