STM32 USB DFU Circuit – Design and Implementation

stm32updateusb

I would like to program a custom board based on STM32F446RET MCU by using the default STM32 USB DFU bootloader. I did the following connections:

  • board VCC to USB cable and VBUS_FS
  • board GND to USB cable
  • UDB_DP to USB cable
  • USB_DN to USB cable

When reset BOOT0=3.3V and BOOT1=GND

The MCU seems to enter in the bootloader (the main program does not start) but STM32Programmer is not able to connect to the USB device

Am I missing something?

EDIT 1:

The circuit is very close to this one:

Schematic of the described circuit

EDIT 2:

I discovered the source of the problem, but not the solution. Here's more details. There is a USB A receptacle on the board and:

  • if I use a USB-A to USB-A cable to connect the board to the PC everything works.
  • if I use a USB-A to USB-C cable to connect the board to the PC it does not work.
  • if I use two cable adapters: USB-A to USB-A (male) and USB-A (female) to USB C, it works

It seems like that when USB C is used we need an additional circuit (the same that it is inside the cable adapter). Which circuit? I'm not able to find anything on the internet

Best Answer

You are trying to connect incompatible connections together.

I don't know why your device has a Type-A receptacle, but it is reserved for USB hosts only. Maybe you want to plug in a USB storage device when the STM32 is a host. So it might be correct for normal use.

But when programming, the STM32 is a USB device, not a host.

USB cables with Type-C plug on one end and Type-A plug on the other are meant to connect a Type-A host with receptacle to a Type-C device with receptacle. The Type-C plug identifies as the host side, so if you plug it into a laptop, it will not work.

So the correct cable for connecting a PC to device will have a Type-C plug and Type-A receptacle, and the Type-C plug identifies itself as device to the PC.

The next problem is, you need an illegal USB cable with Type-A plugs on both ends.

This kind of cable should not exist as it will allow two hosts to be connected togther and it will short their power supplies. Unfortunately these cables exist, as many devices have incorrectly used a Type-A receptacle.

Fortunately, USB3 specs allow existence of such a cable for debugging use, but only if it omits the VBUS supply connection, so these are safe to use.

So, if you need the PC to power the STM32 board, you need an illegal cable which do exist and are available, but you might also end up with the legal cable which omits the supply connection, you need to power the STM32 board externally. Or make a DIY custom cable for programming.