Skip to main content

How To Load and Run Firmware on Alternative Cores (NXP)

Introduction

This article describes how to load and run firmware compiled for alternative cores using the MCUXpresso SDK.

This article complies with the Typographic Conventions for Toradex Documentation.

Prerequisites

  • Hardware prerequisites:

    • A module with Torizon OS or a Linux BSP image installed
    • Access to the U-Boot console
  • Software prerequisites:

Load Firmware From U-Boot

The following procedure describes how to load the compiled firmware on the alternative cores using the ext4load command from the U-Boot terminal.

To be able to connect to U-Boot console and to the alternative core serial console, refer to the tabs below for the pinout and connection details for each module:

After connecting to the USB Debug port, the U-Boot console can be accessed through the ttyUSB3 port and the alternative core serial console can be accessed through the ttyUSB2 port.

warning

For Torizon OS, Toradex recommends placing the firmware binary in a directory not managed by OSTree. Refer to OSTree documentation for more information.

  1. Copy the firmware binary to the target module using an SD card, USB drive, SCP, or another suitable method.

  2. Identify the firmware path from the U-Boot point of view using the ext4ls command:

    > ext4ls mmc 0:1
  3. Set the load_cmd variable according to the installed image:

    > setenv load_cmd "ext4load mmc 0:1"
    warning

    Select the correct device and partition according to the installed image.

  4. Set the firmware binary path.

    For example, if the firmware binary is placed under /var in a Torizon OS image, use:

    > setenv cm_image "/ostree/deploy/torizon/var/hello_world_cm7.bin"
  5. Set the Cortex-M4 instruction Tightly-Coupled Memory (TCM) size:

    > setenv cm_isize 20000

    The cm_isize value corresponds to 128 KiB.

  6. Create the commands used to load the firmware binary into RAM and copy it to the Cortex-M4 TCM address:

    > setenv load_cm_image "${load_cmd} ${loadaddr} ${cm_image}"
    > setenv cm_boot "run load_cm_image; cp.b ${loadaddr} 0x203c0000 ${cm_isize}; dcache flush; bootaux 0x20000000"
  7. Save the U-Boot environment:

    > saveenv

Start the Application

Before starting the firmware, connect to the alternative core serial console using another terminal.

To start the application, run the U-Boot command below:

> run cm_boot

After running the preceding command, the firmware is loaded and executed on the alternative core. The output can be seen on the alternative core serial console, as shown below:

hello world.

Run the Firmware Automatically at Boot

warning

Changing bootcmd modifies the boot flow. Validate the commands manually before saving the U-Boot environment.

To run the firmware automatically at boot, add the firmware loading and start commands to the bootcmd U-Boot environment variable. After saving the environment, U-Boot loads and starts the firmware during each boot.

> setenv bootcmd "run cm_boot; ${bootcmd}"
> saveenv
> reset

Next Steps

Follow the How To Run a Custom Application on the Alternative Core (NXP) article to understand how to create a custom firmware application for the alternative cores.

Send Feedback!