内容概览
本篇是一篇 FRDM-MCXN947 快速上手技术帖,目标很明确:确认开发板在 VS Code + NXP MCUXpresso 工具链下可以完成编译、下载和串口输出。
本文完成项如下:
项目结果要求
| VS Code 插件 | 已安装 NXP MCUXpresso for VS Code |
| 工具链 | 使用 MCUXpresso IDE 自带 Arm GNU Toolchain |
| 构建 | hello_world_cm33_core0 可以生成 .axf |
| 下载运行 | LinkServer 可以识别并运行目标 |
| 串口输出 | 能看到 hello world. |
1. 开发板与工程
本次使用的开发板是 FRDM-MCXN947。
当前使用的工程不是 Zephyr 工程,而是 MCUXpresso SDK 导出的 Hello World 示例:
frdmmcxn947hello_world_cm33_core0
版本包装目录为:
01_board_bringup_mcuxpresso_hello_world
图片展示:


图 1 FRDM-MCXN947 外包装正面


图 2 FRDM-MCXN947 外包装反面


图 3 FRDM-MCXN947 所有东西


图 4 FRDM-MCXN947 开发板正面


图 5 FRDM-MCXN947 开发板背面
2. 开发环境清单
类型当前配置
| 编辑器 | Visual Studio Code |
| VS Code 插件 | NXP MCUXpresso for VS Code |
| NXP IDE | MCUXpresso IDE 25.6.136 |
| 编译器 | Arm GNU Toolchain 14.2.Rel1 |
| 构建工具 | mingw32-make |
| 下载工具 | LinkServer |
| 目标设备 | MCXN947:FRDM-MCXN947 |
| 串口 | COM13 @ 115200 |
这个工程依赖 NXP Redlib:
redlib.specs
因此不能随便换成其它厂商工具链里的 arm-none-eabi-gcc。如果 PATH 里优先找到的是 STM32 或其它工具链,编译可能会报缺少 redlib.specs。
本工程内部路径采用相对定位,脚本会从自身位置找到 SDK 示例工程。MCUXpresso IDE、LinkServer 属于外部工具,脚本会自动探测;如果安装位置比较特殊,可以用下面的环境变量指定:
$env:MCUXPRESSO_IDE_ROOT="C:pathtoMCUXpressoIDE_xxx"
$env:MCUXPRESSO_TOOLCHAIN_BIN="C:pathtotoolsbin"
$env:LINKSERVER_PATH="C:pathtoLinkServer.exe"
图片展示:


图 6 VS Code 安装 NXP MCUXpresso for VS Code
3. 编译 Hello World
确认当前目录位于 MCXN947 项目根目录,然后执行编译:
.build.cmd
这里使用 .cmd 作为对外入口,原因是它会自动调用内部的 build.ps1,并加上 -ExecutionPolicy Bypass,避免 Windows PowerShell 执行策略拦截。工程路径由脚本根据自身位置相对解析,不依赖固定盘符。脚本还会把 MCUXpresso 生成的 Debug/**/*.mk 中的工程绝对路径改写为 ../source、../drivers 这类相对路径,然后切换到真实 SDK 工程的 Debug 目录,并执行:
mingw32-make MAKE=mingw32-make -B main-build
也可以从项目根目录进入 code 目录后执行本地包装脚本:
cd .01_board_bringup_mcuxpresso_hello_worldcode
.build.cmd
编译完成后应生成:
frdmmcxn947_hello_world_cm33_core0.axf
frdmmcxn947_hello_world_cm33_core0.bin
frdmmcxn947_hello_world_cm33_core0.map
本次构建结果:
PROGRAM_FLASH0: 14884 B / 1 MB
SRAM: 8728 B / 384 KB
图片预留:


图 7 FRDM-MCXN947 Hello World 编译成功
4. 识别调试器
使用 LinkServer 查看调试探针:
LinkServer.exe probes
本次识别结果:
MCU-LINK FRDM-MCXN947 CMSIS-DAP V3.128
Serial: AQO40TGAZF5ME
Device: MCXN947
Board: FRDM-MCXN947
图片展示:


图 8 LinkServer 识别到 FRDM-MCXN947
5. 下载运行并检查串口
执行运行脚本:
.run.cmd
也可以从项目根目录进入 code 子目录后使用同名包装脚本:
cd .01_board_bringup_mcuxpresso_hello_worldcode
.run.cmd
脚本调用 LinkServer 下载 .axf,同时监听串口:
LinkServer.exe run --mode serial:COM13:115200 --pass-mark "hello world." MCXN947:FRDM-MCXN947 xxx.axf
预期输出:
MCUX SDK version: 2026.03.00
hello world.
图片展示:


图 9 FRDM-MCXN947 运行 Hello World 串口输出
6. 常见问题处理
问题 1:make 递归调用路径被空格截断
现象:
'D:/AppLication/VS' is not recognized as an internal or external command
原因:mingw32-make 路径中包含空格,递归调用时被拆开。
处理方式:
mingw32-make MAKE=mingw32-make -B main-build
问题 2:非 NXP GCC 缺少 Redlib
现象:
cannot read spec file 'redlib.specs'
原因:工程使用 NXP Redlib,普通 Arm GCC 不一定带对应 specs 文件。
处理方式:把 MCUXpresso IDE 自带工具链路径放到 PATH 前面。
问题 3:PowerShell 禁止执行脚本
现象:
running scripts is disabled on this system
处理方式:
.build.cmd
.run.cmd
7. 结果确认
检查项结果
| VS Code 插件安装 | 通过 |
| NXP GCC 编译 | 通过 |
| .axf 生成 | 通过 |
| .bin 生成 | 通过 |
| LinkServer 识别开发板 | 通过 |
| 下载运行 | 通过 |
| 串口输出 hello world. | 通过 |
我要赚赏金
