Skip to main content

How To Run a Custom Application on an Alternative Core (NXP)

Introduction

This article describes how to customize, compile, and run an application on alternative cores using the MCUXpresso SDK.

This article complies with the Typographic Conventions for Toradex Documentation.

Prerequisites

Customize the Hello World Example Application

The MCUXpresso SDK provides example applications that can be used as starting points for HMP development. This article uses the hello_world example application as the base for the custom application.

The hello_world example application is available in the examples/demo_apps directory of the SDK workspace. The structure of this example application is shown below:

$ cd mcuxsdk/examples/demo_apps/hello_world/
$ tree
.
├── CMakeLists.txt
├── example.yml
├── hello_world.c
├── Kconfig
└── readme.md

1 directory, 5 files

The hello_world.c file contains the main code of the example application. To run a custom application on the alternative core, modify the hello_world.c with the following code:

hello_world.c
/*
* Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
* Copyright 2016-2017, 2024 NXP
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

#include "fsl_device_registers.h"
#include "fsl_debug_console.h"
#include "board.h"
#include "app.h"

/*******************************************************************************
* Definitions
******************************************************************************/

/*******************************************************************************
* Prototypes
******************************************************************************/

/*******************************************************************************
* Variables
******************************************************************************/

/*******************************************************************************
* Code
******************************************************************************/
/*!
* @brief Main function
*/
int main(void)
{
/* Init board hardware. */
BOARD_InitHardware();

PRINTF("MCUX SDK version: %s\r\n", MCUXSDK_VERSION_FULL_STR);

PRINTF("hello world.\r\n");

uint8_t count = 1;

while (1)
{
PRINTF("hello world. [%d]\r\n", count);

if (count == 100)
count = 1;
else
count++;
}
}

After modifying the code, follow the How To Compile Firmware for Alternative Cores (NXP) article to compile the firmware for the alternative core.

Run the Custom Application on the Alternative Core

After compiling the firmware, follow the How To Load and Run Firmware on Alternative Cores (NXP) article to load and run the firmware on the alternative core.

After the firmware starts, the alternative core executes the hello_world application. The output appears on the alternative core serial console, as shown below:

hello world.
hello world. [1]
hello world. [2]
hello world. [3]
...

However, when the target module boots, the alternative core UART output stops working. This behavior occurs because the Linux kernel can request ownership of the pins used by the alternative core UART. To avoid this behavior, apply a device tree overlay that keeps those pins available for the alternative core.

Apply the Device Tree Overlay

For Torizon OS, device tree overlays can be enabled with TorizonCore Builder. For Linux BSP images, refer to Device Tree Overlays documentation.

As each module features a distinct pin configuration, the required device tree overlay may vary accordingly. Refer to the tabs below for the specific overlay information for each module:

info

Before applying the required overlays, apply the i.MX 95-based modules changes described in the How To Compile Firmware for Alternative Cores (NXP) article.

Toradex provides the necessary overlays for i.MX 95-based modules:

These overlays can be used to run the custom hello_world demo application on the alternative core.

Update the U-Boot Environment Variables

After applying the required overlays, run the following commands to update the tdxargs on the U-Boot console to prevent the Linux Kernel from disabling the alternative core UART clocks:

> setenv tdxargs "clk_ignore_unused pd_ignore_unused"
> saveenv
> reset

Next Steps

Follow the Cortex-M JTAG Debugging article to debug applications running on the alternative core using JTAG.

Send Feedback!