记录在ubuntu上使用开源工具搭建stm32开发环境遇到的问题

当代程序员开发程序少不了IDE,离开了IDE要死去不少程序员吧。在stm32开发中,常用的IDE有keil,iar等。

keil这个IDE功能强大,包括1文本编辑器,2编译工具链(包含调试器),3一键配置烧写器(st-link/jlink等),4芯片硬件仿真(虚拟机)等。太过于强大,但是收费。

现在我们使用开源工具来替换keil,进行stm32开发。

1/我们使用vi编辑器

2/我们使用gcc

3/我们自己安装烧写器的驱动后,自己发指令控制烧写器

4/无

遇到的问题,使用如下命令控制烧写器烧写程序到开发板,出了问题,发现第一次可以正常烧写,连续烧第二次,程序烧不进去

openocd -f /usr/local/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/share/openocd/scripts/target/stm32f4x.cfg -c init -c halt -c "flash write_image erase /home/cf/libopencm3-examples/examples/stm32/f4/stm32f429i-discovery/miniblink/LED.hex" -c reset -c shutdown

报错如下:

Error: flash write algorithm aborted by target

Error: error executing stm32x flash write algorithm

Error: flash write failed = 000000c0

Error: error writing to flash at address 0x08000000 at offset 0x00000000

将命令进行改成如下,烧写正常。具体原因还不清楚,需要了解相关规范才能清楚

openocd -f /usr/local/share/openocd/scripts/interface/stlink-v2.cfg -f /usr/local/share/openocd/scripts/target/stm32f4x.cfg -c init -c "reset halt" -c "flash write_image erase /home/cf/libopencm3-examples/examples/stm32/f4/stm32f429i-discovery/miniblink/LED.hex" -c reset -c shutdown

原文链接:,转发请注明来源!