0

I am attempting to upload my written program for the STM32F411RE from my TrueStudio for STM32 IDE to the board itself. The board is connected via the mini USB b cable and the intent is to program it via 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. 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. 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.

    1


  2. To call the ST-Link_CLI from inside the IDE requires making an external tools configuration. To make this config I go to Run -> External Tools -> External Tools Configurations .... and create a new configuration, lets call it ST-Link_CLI.

    For the Working Directory I specify the directory of my ST-LINK_CLI
    (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).
    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
    (-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:

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.

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.


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. 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.

3 4

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.


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.

Nanne118
  • 125
  • 1
  • 13
  • It also says I cannot go into the debugger perspective inside the TrueStudio IDE, as there is no device present. I find this weird because the device is found when attempting to upload code to it per the post above. Could these issues be linked in some really freaky manner, where it says it cannot open the code but it is actually not finding the device or vice versa? – Nanne118 May 17 '19 at 12:49
  • Why don't use notmal way of programming and debugging using the openOCD? – 0___________ May 17 '19 at 13:00
  • I was trying to learn how to do it in Keil uVision first before I ran into code limits, \ so instead I used TrueStudio instead given the amount and detail of documentation available. What benefits would OpenOCD offer at this point, given how much I have already learned about TrueStudio? – Nanne118 May 17 '19 at 13:08
  • Because the way you have chosen does not make any sense. And I afraid this knowledge (about this tool CLI and integration with truestudio is rather useless) – 0___________ May 17 '19 at 13:25
  • 1
    @P__J__ I disagree. This tool is powerful. Especially if you want to set option bytes, which TrueStudio does not natively support. – Hein Wessels Oct 02 '19 at 07:22

3 Answers3

0

You try to reinvent the wheel using the triangle.

Everything is configured in the TrueStudio:

enter image description here

Just in add the debug configuration and you are done.

What benefits would OpenOCD offer at this point

One essencial : debugging

given how much I have already learned about TrueStudio?

This knowledge (how to configure external tools etc) is rather useless in 99.9999% of circumstances. It is only the configuration of the Eclipse. Not too complex actually needed here.

0___________
  • 60,014
  • 4
  • 34
  • 74
  • Unfortunately it seems I do not get those default options, as I am not using the RTOS module (CMSIS-Pack?). It is very insightful to see that RTOS provides this, that definitely would have saved me some time! I am also still intrigued by your OpenOCD suggestion and I will definitely pursue this at a later time: do you have any suggested resources for working this with the STM32? It seems OpenOCD comes in many flavours for different IDE's, would you recommend Eclipse or Visual Studio Code? – Nanne118 May 17 '19 at 13:52
  • You just did not learn what is needed. I use RTOS in all of my projects. This one on the screenshot is a freeRTOS 150000 lines of code one. Works as a charm. I actually use a bit better debugger (Jlink) but the idea is the same – 0___________ May 17 '19 at 13:56
0

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).

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).

It now uploads successfully and immediately after boots me into the debug environment of TrueStudio :)

Nanne118
  • 125
  • 1
  • 13
0

I simply commented "load" command in the startup script and debugging worked. I only had to load the hex using the st link first.

/# Load the program executable

#load       <---//added "#"
Moddasir
  • 1,449
  • 13
  • 33