1

Overview

  • I need to program a recently purchased STM32F407ZGT6 board

  • In 'normal mode' my computer doesn't recognizing the board as a Ports (COM & LPT)/STMElectronics Virtual COM Port when connected via USB (I'm using a Windows 10 Pro). The LEDs turn on and I can get it into 'DFU mode'. When I try to debug the code, I get the "No ST-LINK detected!" message in either mode.

  • This is my first time connecting the board and also my first time dealing with STM32

  • Despite the instructions, I want to program the board using C directly from the STM32CubeIDE

Here is what I found

I found this question [1] where Device Manager reads the STM as Disk drives/STM32. My PC identifies it as mass storage and portable devices on Windows 10 Pro. When in DFU mode, I can see it as Universal Serial Bus Device/STM32 BOOTLOADER on Device Manager.

The tutorial [2] uses Flash Loader Demo and this older tutorial [3] uses STSW-STM32080, but both of the drivers are tagged as obsolete on the ST Website. STM32CuberProgrammer is indicated instead, but I would like to flash and debug directly from the IDE. Another forum reply [4] says that "you need a ST-link V2 programmer to program the brand new chip".

In summary

I can see the solution being one of the following options:

  1. correct answer I need to use the ST-LINK-V2 to program from the IDE and that's the only way
  2. I need to flash a bootloader via STM32CubeProgrammer to get it to work via IDE (is there a standard code for this?)
  3. I have to build the cross-compiler for MicroPython [5] before I get to program it in C

What are your thoughts? Any other driver or idea that I might be missing?


Update

I went on and got my hands on a ST-LINK V2. I made the connection via the JTAG/SWD connector (see schematic) and I also tried connecting directly with the pins:

ST-Link JTAG/SWD Pins
SWCLK 9 PA14
SWDIO 7 PA13
GND 10 GND
3.3V 1 3.3V
RST 3 PB4

The ST-Link is not recognized. The ST-Link blinks and the board is powered up, but that's it. Device manager before and after shows the same.

So I went on checking if I was missing any new driver/program. I installed the STSW-LINK004 (STM32 ST-LINK Utility v4.6.0.0) based on these instructions, but no luck, Utility cannot find it either. I've reseted the computer after each driver installation. If I connect my boardvia USB in DFU mode, it is still recognized as STM32 BOOTLOADER, if I do it with the ST-Link, nothing changes.

Update solution

It turned out the ST-Link was faulty and therefore not connecting. After finding another ST-LINK/V2, the computer can recognize the board under Universal Serial Bus devices/STM32 STLink.

mgmussi
  • 520
  • 1
  • 4
  • 19

1 Answers1

2

Debugging with STM32CubeIDE will always need an ST-LINK or other JTAG or SWD debug probe.

The bootloader allows you to program the microcontroller with a binary image, and that's it. The IDE will happily produce such a binary image, and possibly even have a wizard for transferring it via DFU. But that's only programming, no debugging And only be when the bootloader is running. If you did debug-like things like reading RAM contents, you'd get what the bootloader stores there while it is running, not the variables that your own program uses.

The ROM bootloader supports several ways of receiving new code to flash -- USB (DFU), CAN, I2C, SPI, UART. That last is not a USB Virtual COM port, it is honest-to-God UART using the USART peripheral in the microcontroller and RX/TX pins.

If you want a virtual COM port for your custom firmware to use to send data to the PC, you have to program the USB peripheral.

Ben Voigt
  • 277,958
  • 43
  • 419
  • 720
  • Thanks for putting this so cristally clear Ben. Coming from the Arduino world, this is a bit of a mindset shift. So just to confirm, there is no other way to debug via IDE other than using an ST-LINK/JTAG/SWD? Can I debug elsewhere using DFU? – mgmussi Jun 09 '22 at 19:53
  • @mgmussi: No, DFU doesn't support debug. Doesn't matter what PC-side tools. The basic problem is that a debugger has to work when YOUR CODE is running, and DFU only works when the ROM bootloader is running. This manifests as [a very limited command set in DFU](https://www.st.com/resource/en/application_note/cd00264379-usb-dfu-protocol-used-in-the-stm32-bootloader-stmicroelectronics.pdf): copying data in and out. The ST-LINK communicates with the "Serial wire JTAG debug port", not with the main microcontroller. – Ben Voigt Jun 09 '22 at 20:53
  • 1
    Now, there are many demo and evaluation boards available that have an ST-LINK built onto the board, so all you need for debug is a USB connection, for example https://www.st.com/en/evaluation-tools/stm32f4discovery.html. But your debug USB connection is actually to a second microcontroller on the board, which runs ST-LINK firmware and controls SWD pins connected to the main microcontroller where your code is running. – Ben Voigt Jun 09 '22 at 20:57