使用stm32CubeIDE调试stm32mp157的Cortex-M4核


stm32CubeIDE 1.3.0 软件问题不少,针对 stm32mp1 系列,相关支持没跟上,在 Production mode下调试,软件无法识别 USB 转串口,同时 J-link 无法在 stm32CubeIDE 1.3.0 软件上识别芯片,故而使用 ST-Link,在某宝买的十几块钱小 USB 样式。

环境及工具

Win10下的 stm32CubeIDE 1.3.0 软件
开发板:PanGu-MP157A开发板
开发板上运行自制最小文件系统
ST-Link 调试器(在 stm32CubeIDE 软件中可更新固件)

串口设备驱动修改

stm32CubeIDE 1.3.0 软件无法正常识别串口,笔者在调试时发现了一种取巧的方法,修改设备驱动程序:(本文用到 CH340 串口,测试 CP2102 的串口也可通过修改设备驱动的方式使用
设备管理器找到 CH340 串口,右击更新驱动程序, 浏览我的计算机以查找驱动程序 ---- >>> 让我从计算机的可用列表中选取,选择 FTDI 中的 USB Serial Port,点击下一步跟换串口驱动为 FTDI 的, 重启 stm32CubeIDE 软件,就可以识别到串口
在这里插入图片描述

在这里插入图片描述

最小系统修改

由于使用自制最小系统在 Production mode 调试模式,在调试过程中需要用到网口和串口,网口主要是将调试文件复制到系统中,故而这个用到了SSH ,本文使用轻量级 Dropbear SSH,将编译好的 Dropbear 放置在 /usr/sbin/ 文件夹下, 将 OpenSSH 中编译的 sftp-server 放置到 /usr/libexec 文件夹下,密钥文件放置在 /etc/dropbear 文件夹下,具体的在早期文章中有描述,就不具体说明。
同时,在 /lib 文件夹下新建文件夹 firmware,否则直接烧写程序会报错,如下:

[  673.166637] remoteproc remoteproc0: powering up m4
[  673.170322] remoteproc remoteproc0: loading /lib/firmware/updates/4.19.43+/157AAA3_CM4.elf failed with error -20
[  673.180346] remoteproc remoteproc0: loading /lib/firmware/updates/157AAA3_CM4.elf failed with error -20
[  673.189761] remoteproc remoteproc0: loading /lib/firmware/4.19.43+/157AAA3_CM4.elf failed with error -20
[  673.199388] remoteproc remoteproc0: loading /lib/firmware/157AAA3_CM4.elf failed with error -20
[  673.207887] remoteproc remoteproc0: Direct firmware load for 157AAA3_CM4.elf failed with error -20
[  673.216872] remoteproc remoteproc0: request_firmware failed: -20
[  673.222848] remoteproc remoteproc0: Boot failed: -20

都修改完成后,可成功烧录并调试,开发板系统串口打印如下:

[  754.711411] remoteproc remoteproc0: powering up m4
[  754.719251] remoteproc remoteproc0: Booting fw image 157AAA3_CM4.elf, size 1909304
[  754.725436] remoteproc remoteproc0: header-less resource table
[  754.731372] remoteproc remoteproc0: not resource table found for this firmware
[  754.738615] remoteproc remoteproc0: header-less resource table
[  754.744324] remoteproc remoteproc0: remote processor m4 is now up

调试烧写后,会在系统中出现 /usr/local/project 目录,运行程序就在其目录中。

烧写程序后,IDE软件还是会报错,如下,不过不影响调试
在这里插入图片描述

补充

近来使用新版的 stm32CubeIDE 1.11.2,出现了一些问题。

环境 : win11

在 linux 系统下,下载M4程序后,提示:

在这里插入图片描述

Error in final launch sequence:

Failed pre launch
Failed pre launch
Firmware remoteproc load failed, please:
     1. make sure that /lib/firmware on your target has space
     2. make sure that /lib/firmware has write access

   > you can open a Console View for this..

有些奇怪,所需文件已烧录到了 /usr/local/project/ 目录下,但无法在 /lib/fireware 目录下形成链接文件,暂不明白原因

  • 若需使用在线调试,需手动启动 M4 工程,使用工程目录下的 fw_cortex_m4.sh start 命令即可,然后切换到 Engineering mode 模式调试即可
    在这里插入图片描述

  • 也可以手动将工程复制到 linux 系统中 /lib/fireware 目录下,手动启动运行

echo mp157aac_CM4.elf > /sys/class/remoteproc/remoteproc0/firmware
echo start > /sys/class/remoteproc/remoteproc0/state

调试时会出现掉线情况,可点击隐藏的设置,修改接口频率即可
在这里插入图片描述

在这里插入图片描述

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值