cubemx + openocd搭建嵌入式开发环境
使用cubemx导出makefile工程
make进行编译
想要添加自己的c文件需要修改makefile,但在cubemx打开时它生成的"Makefile"文件无法修改,需要复制它的内容,新建一个Makefile文件,并在使用make命令的时候用-f
指定它。
生成clangd需要的compile_commands.json
需要使用compiledb
工具,加在make命令前,如:compiledb make -f _Makefile -j10
openocd完成二进制文件烧录
需要下载一些特定芯片的配置文件,常见芯片的cfg文件一般都有提供。一般通过openocd -f *.cfg
进入openocd调试,可通过telnet连接到本地端口,常用openocd命令:
init, halt, reset halt, flash [your_image] [addr], shutdown
arm-none-eabi-gdb进行调试
连接到openocd:
target remote localhost:3333
加载二进制文件:
file [your_hex]