Skip to content

Commit 31bf5a6

Browse files
committed
NXP backend: Building MCUXpresso example
1 parent 266e0dc commit 31bf5a6

8 files changed

Lines changed: 701 additions & 0 deletions

File tree

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Using the MCUXpresso Example
2+
3+
This example demonstrates how to build and run the ExecuTorch CIFARNet application for the NXP RT700 platform using the MCUXpresso SDK and the GNU Arm Embedded Toolchain. Before building the project, make sure that all required dependencies are installed and that the necessary environment variables are configured correctly.
4+
5+
## 1. Install the Arm GNU Toolchain
6+
7+
First, download the Arm GCC cross-compilation toolchain that is supported by the RT700 platform:
8+
9+
```text
10+
https://developer.arm.com/-/media/Files/downloads/gnu/15.2.rel1/binrel/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi.tar.xz
11+
```
12+
13+
After extracting the archive, create an environment variable called `ARMGCC_DIR` that points to the root directory of the toolchain installation. The build scripts use this variable to locate the compiler, linker, and other required tools.
14+
15+
Example on Linux:
16+
17+
```bash
18+
export ARMGCC_DIR=/path/to/arm-gnu-toolchain-15.2.rel1-x86_64-arm-none-eabi
19+
```
20+
21+
To verify the installation, you can run:
22+
23+
```bash
24+
$ARMGCC_DIR/bin/arm-none-eabi-gcc --version
25+
```
26+
27+
The command should print the installed compiler version.
28+
29+
## 2. Download the MCUXpresso SDK
30+
31+
Next, download MCUXpresso SDK version **26.06** for the RT700 device family:
32+
33+
```text
34+
https://mcuxpresso.nxp.com/builder?hw=MIMXRT700-EVK
35+
```
36+
37+
When generating the SDK package, make sure that you select:
38+
39+
- **Toolchain:** ARMGCC
40+
- **SDK Layout:** Classic Layout
41+
- **Target Board:** MIMXRT700-EVK
42+
43+
After extracting the SDK package, configure the `SdkRootDirPath` environment variable to point to the SDK root directory.
44+
45+
Example on Linux:
46+
47+
```bash
48+
export SdkRootDirPath=/path/to/SDK_26_06
49+
```
50+
51+
The build system relies on this variable to locate board support packages, middleware components, startup code, linker scripts, and device-specific libraries.
52+
53+
## 3. Build the Application
54+
55+
Once both environment variables have been configured, build the project by executing the provided build script:
56+
57+
```bash
58+
./run.sh
59+
```
60+
61+
The script configures the build environment, compiles the source code, links the application, and generates the executable image:
62+
63+
```text
64+
executorch_cifarnet.elf
65+
```
66+
67+
If the build completes successfully, the ELF file will be available in the build output directory and ready for programming onto the target board.
68+
69+
## 4. Flash the Application
70+
71+
The generated application can be programmed onto the RT700 device using SEGGER J-Link tools.
72+
73+
### Linux
74+
75+
```bash
76+
echo "loadfile executorch_cifarnet.elf" | \
77+
/opt/SEGGER/JLink_V796k/JLinkExe \
78+
-IF SWD \
79+
-speed auto \
80+
-Device MIMXRT798S_M33_0
81+
```
82+
83+
Before flashing, ensure that:
84+
85+
- The board is powered on.
86+
- The J-Link debugger is connected to the target.
87+
- The SWD interface is available and correctly wired.
88+
- No other debugging application is currently using the J-Link connection.
89+
90+
The programming process typically takes only a few seconds. Once the image has been loaded successfully, the application can be started directly from flash memory.
91+
92+
## 5. Running the Example
93+
94+
After the firmware is programmed, reset the board and open a serial terminal connected to the device's debug UART interface. The application will initialize the hardware, load the embedded CIFARNet model, and begin performing image inference.
95+
96+
During execution, inference results and diagnostic messages are printed to the terminal. The included demonstration image contains a cat, and the model is expected to classify the image accordingly.
97+
98+
A successful run produces output similar to the following:
99+
100+
![example](terminal.png "Example")
101+
102+
This example serves as a basic validation that the ExecuTorch runtime, model integration, SDK configuration, and hardware platform are all functioning correctly. It can also be used as a starting point for evaluating custom neural network models and experimenting with on-device machine learning workloads on the RT700 platform.

docs/source/backends/nxp/nxp-overview.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ For more finegrained tutorial, visit [this manual page](https://mcuxpresso.nxp.c
5252
For guideline how to update the eIQ Neutron Runtime on MCUXpresso SDK, follow the instructions from the eIQ Neutron SDK package `docs/NeutronSDKUserGuide.md` available
5353
here https://www.nxp.com/design/design-center/software/eiq-ai-development-environment/eiq-toolkit-for-end-to-end-model-development-and-deployment:EIQ-TOOLKIT.
5454

55+
## Using the MCUXpresso Example
56+
57+
[This page](nxp-mcuxpresso-example.md) demonstrates how to build and run the ExecuTorch CIFARNet example from MCUXpresso SDK.
58+
59+
5560
## Reference
5661

5762
**→{doc}`nxp-partitioner` — Partitioner options.**
44.2 KB
Loading
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2026 NXP
2+
#
3+
# This source code is licensed under the BSD-style license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.10.0)
7+
8+
# THE VERSION NUMBER
9+
SET (MCUXPRESSO_CMAKE_FORMAT_MAJOR_VERSION 2)
10+
SET (MCUXPRESSO_CMAKE_FORMAT_MINOR_VERSION 0)
11+
12+
set(CMAKE_EXECUTABLE_LIBRARY_PREFIX)
13+
set(CMAKE_EXECUTABLE_LIBRARY_SUFFIX)
14+
15+
# CURRENT DIRECTORY
16+
set(ProjDirPath ${CMAKE_CURRENT_SOURCE_DIR})
17+
18+
set(EXECUTABLE_OUTPUT_PATH ${ProjDirPath}/${CMAKE_BUILD_TYPE})
19+
set(LIBRARY_OUTPUT_PATH ${ProjDirPath}/${CMAKE_BUILD_TYPE})
20+
21+
project(executorch_cifarnet)
22+
23+
enable_language(ASM)
24+
25+
set(MCUX_BUILD_TYPES flash_debug flash_release)
26+
27+
set(MCUX_SDK_PROJECT_NAME executorch_cifarnet.elf)
28+
29+
set(EXECUTORCH_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../..)
30+
31+
file(GLOB example_sources ${SdkRootDirPath}/boards/mimxrt700evk/eiq_examples/executorch_cifarnet/cm33_core0/*)
32+
33+
add_executable(${MCUX_SDK_PROJECT_NAME}
34+
${example_sources}
35+
${EXECUTORCH_ROOT_DIR}/backends/nxp/runtime/NeutronBackend.cpp
36+
${SdkRootDirPath}/middleware/tfm/tf-m/platform/ext/common/syscalls_stub.c
37+
)
38+
39+
add_config_file(${SdkRootDirPath}/devices/MIMXRT798S/mcuxpresso/startup_MIMXRT798S_cm33_core0.c "" device_startup.MIMXRT798S)
40+
41+
include(${SdkRootDirPath}/tools/cmake_toolchain_files/mcux_config.cmake)
42+
include(config.cmake)
43+
include(flags.cmake)
44+
include(${SdkRootDirPath}/devices/MIMXRT798S/all_lib_device.cmake)
45+
46+
set(EXECUTORCH_BUILD_PYBIND OFF)
47+
set(EXECUTORCH_BUILD_TESTS OFF)
48+
set(EXECUTORCH_BUILD_DEVTOOLS OFF)
49+
set(EXECUTORCH_BUILD_EXECUTOR_RUNNER OFF)
50+
set(EXECUTORCH_BUILD_CPUINFO OFF)
51+
set(EXECUTORCH_BUILD_PTHREADPOOL OFF)
52+
set(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
53+
set(EXECUTORCH_BUILD_PORTABLE_OPS ON)
54+
set(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)
55+
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
56+
add_subdirectory(${EXECUTORCH_ROOT_DIR} EXCLUDE_FROM_ALL executorch)
57+
58+
target_link_libraries(${MCUX_SDK_PROJECT_NAME} PRIVATE
59+
-Wl,--start-group
60+
executorch
61+
executorch_core
62+
extension_runner_util
63+
quantized_kernels
64+
portable_kernels
65+
${SdkRootDirPath}/middleware/eiq/neutron/rt700/cm33/libNeutronDriver.a
66+
${SdkRootDirPath}/middleware/eiq/neutron/rt700/cm33/libNeutronFirmware.a
67+
-Wl,--end-group
68+
)
69+
70+
# wrap all libraries with -Wl,--start-group -Wl,--end-group to prevent link order issue
71+
group_link_libraries()

0 commit comments

Comments
 (0)