您好,我正在尝试让 Zephyr 的 MCUboot 在 LPC55XpressoS69 上使用 0 号核心运行。我正在 Zephyr 中运行简单的 Blinky 示例应用程序。
应用程序运行正常,没有任何错误。
但是,我一直尝试使用 mcumgr 通过 UART 发送设备固件更新 (DFU),但由于某种原因,我甚至无法在 mcumgr 和我的设备之间建立连接。我一直收到“NMP超时”的错误提示。
为了方便理解,我的目录结构如下所示:
|
__boards
|__ lpcxpresso55s69_lpc55s69_cpu0.overlay
__ src
|__ main.c
__sysbuild
|__mcuboot.conf
__mcuboot.overlay
__prj.conf
__sysbuild.conf
我的prj.conf文件内容如下:
# Enable MCUMGR subsystem and OS/Image management commands
CONFIG_MCUMGR=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_IMG=y
# DIRECT SMP over UART
CONFIG_MCUMGR_TRANSPORT_UART=y
CONFIG_MCUMGR_TRANSPORT_SHELL=n
# Dedicate flexcomm0 to SMP — nothing else on the UART
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_LOG=n
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# Required for SMP UART processing thread
CONFIG_NET_BUF=y
CONFIG_ZCBOR=y
CONFIG_BASE64=y
# Required subsystems for DFU
CONFIG_FLASH=y
CONFIG_IMG_MANAGER=y
CONFIG_MCUBOOT_IMG_MANAGER=y
# Dependencies for System/Reboot management via DFU
CONFIG_REBOOT=y
我的sysbuild.conf文件内容如下:
SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_MCUBOOT_MODE_OVERWRITE_ONLY=y我的mcuboot.conf文件内容如下:
CONFIG_LOG=y
CONFIG_MCUBOOT_LOG_LEVEL_INF=y
CONFIG_MCUBOOT_SERIAL=y
CONFIG_BOOT_SERIAL_UART=y
CONFIG_UART_CONSOLE=n/* Step 3.4 - Configure button and LED for Serial Recovery */
// zephyr,console = &flexcomm0;
// zephyr,uart-mcumgr = &flexcomm0;
/ {
chosen {
zephyr,code-partition = &boot_partition;
zephyr,uart-mcumgr = &flexcomm0;
zephyr,shell-uart = &flexcomm0;
};
};
&flexcomm0 {
status = "okay";
};
/ {
aliases {
mcuboot-button0 = &user_button_3;
mcuboot-led0 = &blue_led;
};
};
&gpio0 {
status = "okay";
};
&gpio1 {
status = "okay";
};
&blue_led {
status = "okay";
};
/* Enlarge boot partition to 64KB to fit MCUboot with serial recovery */
&boot_partition {
reg = <0x00000000 DT_SIZE_K(64)>;
};
&slot0_partition {
reg = <0x00010000 DT_SIZE_K(160)>;
};
&slot1_partition {
reg = <0x00038000 DT_SIZE_K(160)>;
};
&storage_partition {
reg = <0x00060000 DT_SIZE_K(50)>;
};
最后,我的 lpcxpresso55s69_lpc55s69_cpu0.overlay 文件看起来像这样
/ {
chosen {
zephyr,code-partition = &slot0_partition;
zephyr,mgmt-smp = &flexcomm0;
zephyr,uart-mcumgr = &flexcomm0;
};
};
&flexcomm0 {
status = "okay";
};
/* Enlarge boot partition to 64KB to fit MCUboot with serial recovery */
&boot_partition {
reg = <0x00000000 DT_SIZE_K(64)>;
};
&slot0_partition {
reg = <0x00010000 DT_SIZE_K(160)>;
};
&slot1_partition {
reg = <0x00038000 DT_SIZE_K(160)>;
};
&storage_partition {
reg = <0x00060000 DT_SIZE_K(50)>;
};
当我运行以下 MCUmgr 命令时,会收到 NMP 超时错误,如下所示:
> mcumgr --conntype serial --connstring "dev=COM11,baud=115200" echo "test"
Error: NMP timeout所以 mcumgr 肯定知道端口可用(否则它会拒绝访问),但它一直超时。
我非常确定这是配置选项错误。我多次尝试更改配置选项,但似乎都无法解决问题。我几乎可以肯定,我漏掉了一些对这个功能正常运行至关重要的配置选项。
我已经尽可能地查阅了所有相关的应用笔记和用户手册。这些方法似乎都无法帮助我解决我的具体问题:在运行 Zephyr 应用程序的 LPC55Sxx 芯片上使用 Zephyr MCUboot 进行 DFU。
任何帮助都将不胜感激,不过最好是有人能在自己的板子上测试一下,例如:LPCXpresso55S69 并确认它们可以使用任何简单的程序执行 UART DFU。
LPC55S6x LPC55S69-EVK
嗨@Harry_Zhang ,
你的方法确实有效。事实上,我能够将命令简化到仅仅只保留一个部分。
west build -p always -b lpcxpresso55s69/lpc55s69/cpu0 --sysbuild samples/subsys/mgmt/mcumgr/smp_svr -- -DEXTRA_CONF_FILE="serial.conf"这个方法也奏效了。非常感谢您重现我的问题,感激不尽。
你好@ZQ2
我能够在 LPCXpresso55S69 板上重现并验证该设置。
1.关键在于,在此配置中,MCUmgr 必须与 MCUboot 一起使用。该应用程序链接到 slot0(而不是闪存基地址),因此单独构建和烧录 smp_svr 应用程序将无法正常工作。MCUboot 是启动应用程序并将控制权移交给应用程序所必需的。
2. 我在文件 /c/SDK/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/boards 中添加了覆盖文件 lpcxpresso55s69_lpc55s69_cpu0.overlay。
&boot_partition {
reg = <0x00000000 DT_SIZE_K(64)>;
};
&slot0_partition {
reg = <0x00010000 DT_SIZE_K(160)>;
};
&slot1_partition {
reg = <0x00038000 DT_SIZE_K(160)>;
};
&storage_partition {
reg = <0x00060000 DT_SIZE_K(50)>;
};
3. 使用以下命令构建项目:
west build -p always -b lpcxpresso55s69/lpc55s69/cpu0 --sysbuild samples/subsys/mgmt/mcumgr/smp_svr -- -DEXTRA_CONF_FILE="serial.conf" -DEXTRA_DTC_OVERLAY_FILE="C:/SDK/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/boards/lpcxpresso55s69_lpc55s69_cpu0.overlay" -Dmcuboot_EXTRA_DTC_OVERLAY_FILE="C:/SDK/zephyrproject/zephyr/samples/subsys/mgmt/mcumgr/smp_svr/boards/lpcxpresso55s69_lpc55s69_cpu0.overlay"
4. 建成之后。您可以使用命令
grep -A20 -B5 "boot_partition" build/mcuboot/zephyr/zephyr.dts
5. 和西闪光
6.
7.
这证实了 UART 传输、SMP 服务器、MCUmgr 和 MCUboot 集成均正常工作。
BR
哈里
嗨@Harry_Zhang ,
巧合的是,就在我昨天发布这个问题之后,我正好在使用 Zephyr 的smp_svr示例。
我遇到的问题也完全一样。
我按照 Zephyr 文档中的示例进行了操作,链接如下。
我创建了一个示例项目,然后成功构建了代码,并按照文档说明,使用以下命令启用了Raw UART(串行) smp_svr 选项的配置:
west build -p always -b lpcxpresso55s69/lpc55s69/cpu0 --sysbuild -- -DEXTRA_CONF_FILE="raw-serial.conf;fs.conf"
然后我成功地刷入了代码。
尽管如此:
C:\Users\Dev>mcumgr --conntype serial --connstring "dev=COM11,baud=115200" echo "test"
Error: NMP timeout
我甚至尝试将调试探针从 Link2 改为 JLink,之后调试探针就连接到了 COM16。为了以防万一,我还使用 JLink Commander 禁用了所有大容量存储设备功能。
然后我尝试刷机并运行:
> west flash -r jlink
但再次出现这种情况:
C:\Users\Dev> mcumgr --conntype serial --connstring "dev=COM16,baud=115200" echo "test"
错误:NMP 超时
我究竟漏掉了什么?我猜这跟配置有关?如果是这样,我很好奇为什么 Zephyr 官方提供的smp_svr示例与 LPC55S69 不兼容,需要进行修改。
你好@ZQ2
由于 mcumgr echo 已经返回 NMP 超时,我认为您可以在调试 MCUboot DFU 流程之前验证 MCUmgr UART 通信。
您可以确认以下内容:
flexcomm0 是连接到 LPCXpresso55S69 板上 COM11 的 UART。
应用程序运行正常(未停留在MCUboot串行恢复模式)。
没有控制台、shell 或日志输出与 MCUmgr 共享同一个 UART。
mcumgr --conntype serial --connstring "dev=COM11,baud=115200" echo "test"
BR
哈里