终于搞定ubuntu编译和烧写stm32 openocd

这里遇到的问题都总结一下

 

首先编译固件库的启动文件,选错arm下的文件,报错:

startup_stm32f10x_hd.s: Error: bad instruction

 

编译头文件指令:

arm-none-eabi-gcc -c -mthumb -mcpu=cortex-m3 -g -Wa,--warn -o startup_stm32f10x_hd.o startup_stm32f10x_hd.s

解决方式选用gcc_ride7或TrueSTUDIO下的。

头文件路径:STM32F10x_StdPeriph_Lib_V3.5.0/Libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/

 

 

Openocd的环境问题

1 下载好openocd源码后解压,进入目录

需要配置对应的参数 ./configure ,后面可以加安装的路径--prefix=路径  ,还有配置对应的仿真器 --enable-jlink(使用jlink)

./configure --enable-jlink  --enable-ulink (不加路径,默认/usr/local)

最后会打印:

OpenOCD configuration summary
--------------------------------------------------
MPSSE mode of FTDI based devices        no
ST-Link JTAG Programmer                 no
TI ICDI JTAG Programmer                 no
Keil ULINK JTAG Programmer              yes
Altera USB-Blaster II Compatible        no
Versaloon-Link JTAG Programmer          no
OSBDM (JTAG only) Programmer            no
eStick/opendous JTAG Programmer         no
Andes JTAG Programmer                   no
USBProg JTAG Programmer                 no
Raisonance RLink JTAG Programmer        no
Olimex ARM-JTAG-EW Programmer           no
CMSIS-DAP Compliant Debugger            no
Altera USB-Blaster Compatible           no
ASIX Presto Adapter                     no
OpenJTAG Adapter                        no
SEGGER J-Link Programmer                yes
 

 

2 sudo make后,会出现很多警告错误,

src/svf/svf.c:663:7: error: this statement may fall through [-Werror=implicit-fallthrough=]
     i = -1;
     ~~^~~~
src/svf/svf.c:664:4: note: here
    case '\r':
    ^~~~
src/svf/svf.c:667:8: error: this statement may fall through [-Werror=implicit-fallthrough=]
     if (!cmd_pos)

其实是一些警告而已,在不改源码的情况下,选择忽略它们。

在Makefile 的GCC_WARNINGS的后面添加 -Wno-implicit-fallthrough,如下:

GCC_WARNINGS = -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -Wno-implicit-fallthrough

后面还会遇到一些需要忽略的警告,继续在Makefile的GCC_WARNINGS的后面添加-Wno-format-truncation -Wno-format-truncation -Wno-format-overflow

3 sudo make install后就可以在/usr/local/share下找到openocd的目录了

 

测试使用openocd -f ./interface/jlink.cfg -f ../target/stm32f1x.cfg后出问题了

需要使用swd协议。

修改jlink.cfg,添加transport select swd。

方案:拷贝jlink.cfg,jlink-swd.cfg,添加上述指令

# SEGGER J-Link
#
# http://www.segger.com/jlink.html
#
 
interface jlink
transport select swd
# The serial number can be used to select a specific device in case more than
# one is connected to the host.
#
# Example: Select J-Link with serial number 123456789
#
# jlink serial 123456789

烧写环境就搭好了。

 

参考:

https://blog.csdn.net/Mculover666/article/details/84900665

https://blog.csdn.net/Mculover666/article/details/84945211

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值