System Workbench for STM32 Semihosting
好戏开场了
硬件开发平台是Nucleo-64 STM32F446 ,通过STM32Cubemx生成sw4stm32开发工程。
第一步,删除因新依赖,导致重复定义的函数
第二步添加依赖条件
specs=rdimon.specs -lc -lrdimon
这是默认生成加添加后的链接参数 -specs=nosys.specs -specs=nano.specs -specs=rdimon.specs -lc -lrdimon
第三步
添加函数声明
extern void initialise_monitor_handles(void);
在调用printf前,调用initialise_monitor_handles()函数,仅需调用一次即可。
第四步
添加初始化命令 Add initialization commands
第五步编译debug查看效果
第四步时没有添加Debug文件,debug时会报错,手动添加,我的文件是Debug/SW4STM32.elf。如果还不能打印,请一定确认链接参数是否添加,命令参数是否使能。
这是我的参考链接谢谢这些前人的知识分享
https://embeddeddiaries.com/alternative-debugging-prints-for-stm32-without-uart/
上面这个链接介绍了三种方式是最全的也是最推荐的。
https://bgamari.github.io/posts/2014-10-31-semihosting.html
此链接讲解的一般也可做个参考
https://www.openstm32.org/forumthread2893
此链接亦讲解了具体原理
http://t.zoukankan.com/mickey-double-p-14652431.html
此链接帮助也很大
多谢以上链接的帮助,虚心学习。
附上工程