今天在通過stlink燒錄一個長時間未用的STM32F407VET6 Black Board的時候, 出現錯誤
Internal command error
Flash download failed target dll has been cancelled
板子上缺失兩個boot跳線帽, 將跳線帽加上, 短接Boot0與GND, Boot1與GND (默認接線), 之后問題依舊.
檢查stlink連接狀態, 在Options for target的配置中, 檢查debug中的Use, 使用的是ST-link Debugger, 點開右側的Settings, 在SW Device中能看到ARM Core Sight SW-DP設備, 所以ST-link連接是對的.
打開STM32 ST-LINK Utility, 點擊連接, 依然出現Internal command error, 根據提示, 修改target->settings下的Mode為 Connect under reset, 依然不行.
偶然發現在按開發板上的reset鍵后, 在STM32 ST-LINK Utility中點擊連接能連上, 此時嘗試燒錄一個hex, 依然報Internal command error.
嘗試Full chip erase, 這次沒有出現失敗, 全部地址都被擦寫為FF. 在這之后再嘗試連接, 以及燒錄hex, 一切正常. 在Keil MDK中進行燒錄, 也恢復正常.
燒錄后運行一段時間, 再次出現Internal command error錯誤.
考慮到這塊開發板上有這么多外設, 懷疑是供電問題. 將ST-Link的3V3線斷開, 用USB連接開發板的MiniUSB口, 之后再燒錄, 恢復正常.
在網上搜到一個說明 https://os.mbed.com/users/hudakz/code/STM32F407VET6_Hello/shortlog/
Warning
Please notice that VDD_TARGET is not connected. That works with the ST-Link programmer but
could potentially damage the target micro controller in case it's running at a lower voltage (e.g. 2V5)
than the programmer (e.g. 3V3). That's why it's recommended to connect also the VDD_TARGET line when
an external programmer such as a Segger J-Link is hooked up to program the board.
Provide power for the STM32F407VET6 board through a 3.3V pin, 5V pin or over a USB cable.
(The VDD_TARGET pin on the NUCLEO board CON4 does not work as source of power).
Connect the NUCLEO board to your PC over a USB cable.
To program the STM32F407VET6 board, click on the Compile button and save the binary to the NUCLEO
virtual disk
注意其中的第二段: 通過3.3V腳, 5V腳或者USB給 STM32F407VET6 板子供電, VDD_TARGET腳不能用於供電
另外, 記錄一下ST-link與STM32F407VET6 Black Board的接線方式 - 注意: 連接MiniUSB后, ST-link只需要連3根線, 3V3這根不連.