Skip to main content

How To Compile Firmware for Alternative Cores (NXP)

Introduction

This article describes how to compile firmware for alternative cores using the MCUXpresso SDK.

This article complies with the Typographic Conventions for Toradex Documentation.

Prerequisites

The MCUXpresso SDK and all required tools must be configured before proceeding. Refer to the Setting Up the MCUXpresso SDK and Toolchain for HMP Development article for more information about the installation process.

Understand the NXP MCUXpresso SDK Structure

After the MCUXpresso SDK workspace is installed, the main SDK content is available in the mcuxsdk directory. The example applications provided by the NXP MCUXpresso SDK are available under the mcuxsdk/examples directory.

The following command shows the top-level structure of the mcuxsdk directory:

$ cd mcuxsdk
$ tree -L 1 --dirsfirst
.
├── arch/ # Architecture-specific code
├── cmake/ # CMake modules and toolchain helpers
├── components/ # Reusable software components
├── devices/ # Device-specific headers and startup files
├── docs/ # Documentation
├── drivers/ # Peripheral drivers
├── examples/ # Example applications
├── firmware/ # Prebuilt firmware binaries
├── middleware/ # Middleware stacks
├── rtos/ # RTOS support
├── scripts/ # Build and utility scripts
├── share/ # Shared resources and data files
├── tool_data/ # Tool configuration and metadata
├── cmake_format_config.yml # cmake-format style configuration
├── CMakeLists.txt # Top-level CMake build entry point
├── COPYING-BSD-3 # BSD-3-Clause license
├── Kconfig # Top-level Kconfig
├── Kconfig.mcuxpresso # MCUXpresso IDE-specific Kconfig options
├── mcux-env.cmd # Windows environment setup script
├── mcux-env.sh # Environment setup script
├── MCUX_VERSION # SDK version string
├── README.md # Project overview and quick-start guide
├── SBOM.spdx.json # Software Bill of Materials
├── SCR.txt # Software Content Register
├── tool.yml # West-compatible tool manifest
└── yamllint_config.yml # YAML linter configuration

14 directories, 13 files

Compile the Hello World Example

The following procedure compiles the Hello World example, available under the mcuxsdk/examples/demo_apps/hello_world directory.

  1. Source the Python environment used during the MCUXpresso SDK installation, which contains the west tool.

  2. Enter the mcuxsdk directory:

    $ cd mcuxsdk
  3. Compile the example using west for the target processor:

    Alternative Core UART Function

    MCUXpresso SDK examples uses the LPUART3 peripheral for the UART output on i.MX 95 modules. However, Toradex i.MX 95-based modules are connected to the LPUART2 peripheral instead.

    To be able to view the output of the hello_world example on i.MX 95-based modules, apply the changes shown in the diff below to use the LPUART2 peripheral:

    board.h
    diff --git a/_boards/imx95lp4xevk15/board.h b/_boards/imx95lp4xevk15/board.h
    index 50747a266255..22f238c946ba 100644
    --- a/_boards/imx95lp4xevk15/board.h
    +++ b/_boards/imx95lp4xevk15/board.h
    @@ -85,7 +85,7 @@
    */

    /* boad type: imx95 emulator or imx95 lpddr5 19x19 evk */
    -#define BOARD_DEBUG_UART_INSTANCE 3
    +#define BOARD_DEBUG_UART_INSTANCE 2

    #define BOARD_DEBUG_UART_INSTANCE_FOR_CM7_WITH_SM 3U
    #define BOARD_DEBUG_UART_CLOCK_ROOT_FOR_CM7_WITH_SM hal_clock_lpuart3
    @@ -99,7 +99,7 @@
    #define BOARD_DEBUG_UART_CLOCK_ROOT_FOR_CM33_WITHOUT_SM hal_clock_lpuart2
    #define BOARD_DEBUG_UART_CLK_FREQ_FOR_CM33_WITHOUT_SM HAL_ClockGetRate(BOARD_DEBUG_UART_CLOCK_ROOT_FOR_CM33_WITHOUT_SM)

    -#define BOARD_DEBUG_UART_CLOCK_ROOT hal_clock_lpuart3
    +#define BOARD_DEBUG_UART_CLOCK_ROOT hal_clock_lpuart2

    #define BOARD_DEBUG_UART_CLK_FREQ HAL_ClockGetRate(BOARD_DEBUG_UART_CLOCK_ROOT)
    #define BOARD_DEBUG_UART_BAUDRATE 115200U
    pin_mux.c
    diff --git a/_boards/imx95lp4xevk15/demo_apps/hello_world/cm7/pin_mux.c b/_boards/imx95lp4xevk15/demo_apps/hello_world/cm7/pin_mux.c
    index 7bab22dc933f..0be06a12ed3a 100644
    --- a/_boards/imx95lp4xevk15/demo_apps/hello_world/cm7/pin_mux.c
    +++ b/_boards/imx95lp4xevk15/demo_apps/hello_world/cm7/pin_mux.c
    @@ -50,6 +50,7 @@ BOARD_InitPins:
    *
    * END ****************************************************************************************************************/
    void BOARD_InitPins(void) { /*!< Function assigned for the core: Cortex-M7F[cm7] */
    +#if 0
    HAL_PinctrlSetPinMux(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_GPIO_IO14__LPUART3_TX, 0U);
    HAL_PinctrlSetPinCfg(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_GPIO_IO14__LPUART3_TX,
    HAL_PINCTRL_PLATFORM_IOMUXC_PAD_DSE(15U) |
    @@ -60,6 +61,18 @@ void BOARD_InitPins(void) { /*!< Function assigne
    HAL_PINCTRL_PLATFORM_IOMUXC_PAD_DSE(15U) |
    HAL_PINCTRL_PLATFORM_IOMUXC_PAD_FSEL1(2U) |
    HAL_PINCTRL_PLATFORM_IOMUXC_PAD_PD_MASK);
    +#else
    + HAL_PinctrlSetPinMux(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_UART2_TXD__LPUART2_TX, 0U);
    + HAL_PinctrlSetPinCfg(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_UART2_TXD__LPUART2_TX,
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_DSE(15U) |
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_FSEL1(2U) |
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_PD_MASK);
    + HAL_PinctrlSetPinMux(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_UART2_RXD__LPUART2_RX, 0U);
    + HAL_PinctrlSetPinCfg(HAL_PINCTRL_PLATFORM_IOMUXC_PAD_UART2_RXD__LPUART2_RX,
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_DSE(15U) |
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_FSEL1(2U) |
    + HAL_PINCTRL_PLATFORM_IOMUXC_PAD_PD_MASK);
    +#endif
    }
    $ west build --pristine always examples/demo_apps/hello_world/ --config debug --board imx95lp4xevk15 -Dcore_id=cm7

    The --pristine always flag performs a full rebuild, removing previous build outputs before generating new files.

    info

    Run the following command to list the board configurations supported by the Hello World example:

    $ west list_project -p examples/demo_apps/hello_world 
  4. After the build process completes, the generated build artifacts are available in the mcuxsdk/build directory.

Next Steps

Follow the How To Load and Run Firmware on Alternative Cores (NXP) article for instructions on deploying the firmware on the alternative cores.

Send Feedback!