简体   繁体   English

在TrueStudio中上传到STM32时如何解决“无法打开文件”

[英]How to fix 'Unable to open file' when uploading to STM32 in TrueStudio

I am attempting to upload my written program for the STM32F411RE from my TrueStudio for STM32 IDE to the board itself. 我试图将我的STM32F411RE编写程序从TrueStudio for STM32 IDE上载到电路板本身。 The board is connected via the mini USB b cable and the intent is to program it via SWD. 该开发板通过mini USB b电缆连接,目的是通过SWD对其进行编程。

Setup 设定

Atollic provides a nice tutorial on how to perform this programming via it's TrueStudio IDE and the ST-Link_CLI (Command Line Interface), as described in the document at this link . Atollic提供了一个很好的教程,说明如何通过TrueStudio IDE和ST-Link_CLI(命令行界面)执行此编程, 如本链接中的文档所述 This requires the following steps, which I have followed and checked multiple times: 这需要执行以下步骤,我已按照以下步骤进行了多次检查:

  1. First and foremost the output (binary) file needs to be an intel .HEX and not the TrueStudio .elf default. 首先,输出(二进制)文件必须是intel .HEX,而不是TrueStudio .elf默认文件。 To change this go to Project properties -> c/c++ build -> settings -> tool settings tab -> other -> Output format and tick the option 'Convert build output', ensure that the Intel Hex option is selected in the dropdown. 要更改此设置,请转到Project properties -> c/c++ build -> settings -> tool settings tab -> other -> Output format然后勾选选项“转换构建输出”,确保在下拉列表中选择了Intel Hex选项。

    1


  2. To call the ST-Link_CLI from inside the IDE requires making an external tools configuration. 要从IDE内部调用ST-Link_CLI,需要进行外部工具配置。 To make this config I go to Run -> External Tools -> External Tools Configurations .... and create a new configuration, lets call it ST-Link_CLI. 要进行此配置,请转到Run -> External Tools -> External Tools Configurations ....并创建一个新配置,将其称为ST-Link_CLI。

    For the Working Directory I specify the directory of my ST-LINK_CLI 对于工作目录,我指定ST-LINK_CLI的目录
    ( C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility ) C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility
    whilst for the Location I specify this directory and the file name 而对于位置,我指定此目录和文件名
    ( C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility\\ST-LINK_CLI.exe ). C:\\Program Files (x86)\\STMicroelectronics\\STM32 ST-LINK Utility\\ST-LINK Utility\\ST-LINK_CLI.exe )。
    Lastly, I add the following parameters to identify the STM32 board, have it connect via SWD and under reset, whilst telling it to upload the .HEX file built by TrueStudio 最后,我添加以下参数来识别STM32板,使其通过SWD连接并处于复位状态,同时告诉其上载TrueStudio构建的.HEX文件
    ( -c ID=0 SWD UR LPM -P ${project_loc}\\Debug\\${project_name}.hex -v ). -c ID=0 SWD UR LPM -P ${project_loc}\\Debug\\${project_name}.hex -v )。

    2


Output 产量

When I then call this external tool configuration via the Run -> External Tools -> ST-Link_CLI link just created I get the output listed below: 然后,通过刚刚创建的Run -> External Tools -> ST-Link_CLI链接调用此外部工具配置时,得到以下输出:

STM32 ST-LINK CLI v3.4.0.0
STM32 ST-LINK Command Line Interface

ST-LINK SN: 066EFF525750877267092042
ST-LINK Firmware version: V2J33M25
Connected via SWD.
SWD Frequency = 4000K.
Target voltage = 3.3 V
Connection mode: Connect Under Reset
Reset mode: Hardware reset
Debug in Low Power mode enabled
Device ID: 0x431 
Device flash Size: 512 Kbytes
Device family: STM32F411xC/E

Loading file...
Unable to open file!

3

Clearly the ST-Link_CLI is succesfully called from inside the IDE, but it somehow cannot digest the .hex file (inside the debug folder) and upload it to the STM32 board. 显然,可以从IDE内部成功调用ST-Link_CLI,但是它无法以某种方式消化.hex文件(在debug文件夹内)并将其上载到STM32板上。

Even flashing a completely new generated project from CubeMX and setting the options above (including setting it to a .hex file) will not let this toolchain upload it to the board. 即使从CubeMX刷新一个全新生成的项目并设置上述选项(包括将其设置为.hex文件),也不会允许此工具链将其上传到开发板上。


Manual code flashing 手动代码闪烁

I have been able to succesfully upload the .HEX file built by TrueStudio via manually uploading it to the STM32 Board with the use of the ST-Link GUI, so I do not think the problem is in the ST-Link itself. 通过使用ST-Link GUI手动将TrueStudio构建的.HEX文件上传到STM32开发板上,我已经能够成功上传该文件,因此我认为问题不在于ST-Link本身。 I cannot however debug it in this manner, since I need the TrueStudio IDE tools for that and thus need the external tool configuration to work succesfully. 但是,我无法以这种方式调试它,因为我需要为此使用TrueStudio IDE工具,因此需要外部工具配置才能成功工作。

34

Instead I suspect the issue lies with my own setup, where is somehow is missing a call or has an option set incorrectly. 相反,我怀疑问题出在我自己的设置上,这是由于某种原因错过了通话或设置了错误的选项。 It could also be that the GUI and CLI clients operate in a completely different fashion allowing one to read and upload the file whilst the other cannot, but that seems unreasonable to me. 也可能是GUI和CLI客户端以完全不同的方式运行,允许一个客户端读取和上传文件,而另一个则不能,但这在我看来是不合理的。


I am kind of at a loss here however, as I cannot seem to figure out why others can make this work via the provided Atollic documentation and mine is throwing up these errors. 但是,我在这里有点茫然,因为我似乎无法弄清楚为什么其他人可以通过提供的Atollic文档进行这项工作,而我正在抛出这些错误。

You try to reinvent the wheel using the triangle. 您尝试使用三角形重塑轮子。

Everything is configured in the TrueStudio: 一切都在TrueStudio中配置:

在此处输入图片说明

Just in add the debug configuration and you are done. 只需添加调试配置即可。

What benefits would OpenOCD offer at this point 此时OpenOCD将提供什么好处

One essencial : debugging 一个基本:调试

given how much I have already learned about TrueStudio? 鉴于我已经了解了多少TrueStudio?

This knowledge (how to configure external tools etc) is rather useless in 99.9999% of circumstances. 这种知识(如何配置外部工具等)在99.9999%的情况下是毫无用处的。 It is only the configuration of the Eclipse. 它只是Eclipse的配置。 Not too complex actually needed here. 这里实际上并不太复杂。

In regards to my own code, I have not been able to get the ST-Link_CLI to work as an external tool the way I intended, [but I have been able to get the STCubeProgrammer (CLI) to work in the same respective manner as I was attempting to do with the ST-Link].( http://gotland.atollic.com/resources/applicationnotes/AN1801_cubeprogrammer_in_truestudio.pdf ). 关于我自己的代码,我无法使ST-Link_CLI像我打算的那样作为外部工具工作,[但是我已经使STCubeProgrammer(CLI)能够以与各自相同的方式工作。我正在尝试使用ST-Link]。( http://gotland.atollic.com/resources/applicationnotes/AN1801_cubeprogrammer_in_truestudio.pdf )。

Seeing as I literally used the same procedure as before but instead specifying the location and executable for the STCubeProgrammer (rather than the ST-Link), I suspect the issue may indeed be the ST-Link CLI (connection to TrueStudio). 鉴于我实际上使用了与以前相同的过程,而是指定了STCubeProgrammer(而不是ST-Link)的位置和可执行文件,因此我怀疑问题确实可能是ST-Link CLI(连接到TrueStudio)。

It now uploads successfully and immediately after boots me into the debug environment of TrueStudio :) 现在,它成功且立即将我引导到TrueStudio的调试环境中:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM