Skip to main content
Version: 5.0

FreeRTOS on the Cortex-M4s of a Apalis iMX8

The i.MX8QM applications processor is a feature and performance-scalable multicore platform including 2 Cortex-M4 cores. These secondary cores typically run an RTOS optimized for microcontrollers or a bare-metal application. Toradex provides FreeRTOS™, a free professional-grade real-time operating system for microcontrollers, along with drivers and several examples that can be used on our Apalis iMX8QM platform. The FreeRTOS™ port is based on NXP's MCUxpresso SDK for i.MX8QM.

The build system supported to build the firmware and examples is:


The 2 Cortex-M4 CPU cores live side by side with the Cortex-A53/A72 based primary CPU cores. Both CPU complexes have access to the same interconnect and hence have equal access to all peripherals (shared bus topology). The graphic below is an incomplete and simplified drawing of the architecture with emphasis on the relevant sub systems to understand the heterogeneous asymmetric multicore architecture.

i.MX 8QM Heterogeneous Asymmetric Multicore Architecture Block Diagram

There are several types of memory available. The Cortex-M4 provides local memory (Tightly Coupled Memory, TCM), which is relatively small but can be accessed by the CPU without any latency. For applications requiring more memory, the system DRAM is accessible by the M4 cores. From a performance perspective the TCM memory should be used whenever possible.

A traditional microcontroller typically has internal NOR flash where the firmware is stored and executed from. This is not the case on the Apalis iMX8QM: There is no NOR flash where the firmware can be flashed onto. Instead, the firmware needs to be stored on the mass storage device such as SD-card or the internal eMMC flash. The available mass storage devices are not "memory mapped", and hence application can not be executed directly from any of the cores (no executed-In-Place, XIP). Instead, code need to be loaded into one of the available memory sections before the CPU can start executing it.

The M4 firmware can be placed in the common boot container, so it will be loaded and started by the boot ROM, or it can be placed on a mass storage device. In this case U-Boot needs to be configured to load and execute the M4 firmware.

Memory areas

The two CPU platforms use a different memory layout to access individual sub systems. This table lists some important areas and their memory location for each of the cores side by side. The full list can be found in the i.MX8QM reference manual.

RegionSizeCortex-A53/A72M4-0 (Code Bus)M4-0 (System Bus)M4-1 (Code Bus)M4-1 (System Bus)
DDR Address2GB(*1)0x80000000-0xFFFFFFFF0x00100000-0x1BFFFFFF0x80000000-0xDFFFFFFF0x00100000-0x1BFFFFFF0x80000000-0xDFFFFFFF
TCML for M4-0128KB0x34FE0000-0x34FFFFFF0x1FFE0000-0x1FFFFFFFN/AN/A
TCMU for M4-0128KB0x35000000-0x3501FFFF0x20000000-0x2001FFFFN/AN/A
TCML for M4-1128KB0x38FE0000-0x38FFFFFFN/AN/A0x1FFE0000-0x1FFFFFFF
TCMU for M4-1128KB0x39000000-0x3901FFFFN/AN/A0x20000000-0x2001FFFF

(*1): Full DRAM range is 0x8_00000000 - 0xB_FFFFFFFF. Only a part of the DRAM is accessible by the M4 cores

The Cortex-M4 CPU has two buses connected to the main interconnect (modified Harvard architecture). One bus is meant to fetch data (system bus) whereas the other bus is meant to fetch instructions (code bus). To get optimal performance, the program code should be located and linked for a region which is going to be fetched through the code bus, while the data area (e.g. bss or data section) should be located in a region which is fetched through the system bus.

The TCML and TCMU regions can be accessed with zero wait-states and thus provides massively better performance than DRAM, even if it is cached. Therefore it is advisable to place all code and data in the TCM whenever possible.

Get the FreeRTOS Source Code

The FreeRTOS source code is currently only available on NXP's MCUXpresso web page:

Here are the steps to download the resources (as of 2019-10-04)

  1. Register and log into MCUXpresso
  2. On the main page, Explore and Filter Devices
  3. Select Board on the left side
  4. Navigate to Processors i.MX 8QuadMax MIMX8QMx MIMX8QM6xxxFF
  5. Click the button to Generate MCUXpresso SDK
  6. Click the Download SDK button to get the source code.