Skip to main content
Version: BSP 6.x.y

Build Custom i.MX 8/8X System Controller Firmware (SCFW)

Introduction

In this article, we will guide you through the steps of building custom System Controller Firmware (SCFW) for the i.MX 8/8X based modules, including setting up the build environment, configuring the SCFW, and building the SCFW firmware image. Be aware that Toradex customers rarely need to rebuild or customize SCFW. Please think carefully if you really need to rebuild it.

Why Building a Custom SCFW

The i.MX 8/8X System Controller Firmware (SCFW) is a critical component of the i.MX 8/8X SoC (System on Chip) that provides low-level system control and management functionality. The SCFW runs on the System Controller Processor (SCP) which is a dedicated ARM Cortex-M4 processor embedded in the i.MX 8/8X SoC. The SCFW is responsible for managing the power, clocks, resets, and security of the i.MX 8/8X SoC, as well as providing communication interfaces to other subsystems.

Requirements

  • A Toradex module featuring an NXP i.MX 8/8X processor.

In-depth

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:

  • Boot management
  • Power management
  • Clock
  • IO and reset management configuration and muxing
  • Resource partitioning/access control
  • DDR Management
  • Temperature monitoring
  • AP watchdog services
  • Low power wakeup

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.

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.

Pre-built SCFW

You can find the latest pre-built binaries for Toradex SoMs on our GitHub project i.MX-System-Controller-Firmware:

info

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.

Building Custom SCFW

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

Download and Install SCFW Porting Kit

  1. Check at Embedded Linux Release Matrix the specific SCFW version for the Toradex BSP release you are aiming to use.

  2. Download the SCFWKIT from NXP website (requires a valid account).

  3. Extract the downloaded SCFWKIT.

    $ tar -xf ./L5.15.52_2.1.0_SCFWKIT-1.14.0.tar.gz
  4. Launch the porting kit binary package extractor reading and accepting NXP's EULA. This creates a secondary folder imx-scfw-porting-kit

    $ cd packages/
    $ chmod +x imx-scfw-porting-kit-1.14.0.bin
    $ ./imx-scfw-porting-kit-1.14.0.bin
  5. cd into its src subdirectory and extract the desired porting kit (containing mostly binaries but also some sources) specific for the SoM.

  • For Apalis iMX8, extract the scfw_export_mx8qm_b0.tar.gz.

  • For Colibri iMX8X, extract the scfw_export_mx8qx_b0.tar.gz.

    $ cd imx-scfw-porting-kit-1.14.0/src
    $ tar -xf scfw_export_mx8qm_b0.tar.gz

Download and Install a GNU Toolchain

  1. Look at the Porting Kit documentation (packages/imx-scfw-porting-kit-1.14.0/doc/pdf/sc_fw_port.pdf, chapter Porting Guide, sub-chapter Tool Chain) to find out which GNU Toolchain version corresponds to the SCFW you are willing to build.

  2. Download and install the suitable toolchain. 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.

    $ tar xvf gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2
  3. 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

Get and Build the Board-specific Files

  1. Get the Apalis iMX8 or Colibri iMX8X specific board source files at Toradex Git.

    $ git clone https://github.com/toradex/i.MX-System-Controller-Firmware.git
  2. 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/
  3. 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
    info

    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
  4. Deploy the SCFW by configuring the device boot to start at a specific offset. For more information, see Build U-Boot From Source Code.

Additional Resources

  1. The NXP's extracted SCFWKIT has further documentation about SCFW at:
$ packages/imx-scfw-porting-kit/doc/pdf
  1. There are some suitable slides of a past training provided by NXP to learn more about the SCU and SCFW.


Send Feedback!