这里遇到的问题都总结一下
编译头文件指令:
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