0


首先,我很抱歉我的英语很差。
我正在学习如何使用 STM32F3Discovery 板。我编写了一个简单的程序来打开所有板载 LED,使用 STMCubeMX 生成配置代码。
我写的代码就是下面的八行。

  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_8, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_9, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_12, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_13, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_14, GPIO_PIN_SET);
  HAL_GPIO_WritePin(GPIOE, GPIO_PIN_15, GPIO_PIN_SET);

这里有一个 Eclipse 项目的副本。
我正在尝试使用 openocd 对板进行编程,所以我运行

openocd -f /usr/share/openocd/scripts/board/stm32f3discovery.cfg -f /usr/share/openocd/scripts/interface/stlink-v2.cfg

然后

​telnet localhost 4444 
​reset halt
flash write_image erase blink.elf
​reset

openocd 的输出是

Open On-Chip Debugger
> reset halt
target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x2b061a1a msp: 0x48054b04
> flash write_image erase blink.elf
auto erase enabled
couldn't open blink.elf
in procedure 'flash'
> flash write_image erase blink.elf
auto erase enabled
device id = 0x10036422
flash size = 256kbytes
target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000003a msp: 0x48054b04
wrote 2048 bytes from file blink.elf in 0.224231s (8.919 KiB/s)
> reset

但是没有一个led是打开的!
我应该怎么办?

4

1 回答 1

0

couldn't open blink.elf消息表明该文件blink.elf可能不在当前目录中。

确保从包含blink.elf您要编程的固件映像的文件夹中执行 openocd 命令。

于 2019-07-16T22:07:42.777 回答