2024-03-15 06:21 AM - edited 2024-03-15 06:23 AM
Hello there!
I have a custom board to control a motor, which I have tested so far using SWD, but now I need it to use the USB DFU to upload new code.
As far as I get it, to make the DFU work, I have to put some code in the microcontroller. Following some online tutorials, where I use STM32CubeProgrammer to upload a .bin file, which I did successfully, when I unplug it and put Boot0 to high, Windows gives a warning of "USB device not recognized", and in device manager, "Device Descriptor Request Failed". I have assigned the driver manually to "STM Device in DFU Mode", but there has been no change. (I tried this process with a blue pill, and it worked :\ )
I have also tried to use STM32CubeIDE to install the DFU mode with a simple blink, where in Middleware and Software Packs - USB Device - Class for FS IP, I put in Download Firmware Update Class (DFU), but I am not certain if this is enough, or if I should put something else in the code.
I didn't find much information about how to make DFU work with CubeIDE, so I am kind of lost here. Should it work out of the box, or I really need to put some code in? If so, how?
The microcontroller part of my board is in the image below, in case it's a hardware problem, but I don't think it is anymore.
2024-03-15 06:45 AM
Dear @FelipeLw ,
Welcome in STCommunity .
Here are few hints , you need to manage dynamically the Pull-up of 1.5K on D+ PA12 - R31, Once USB is requested and USB cable present to active it using a GPIO . Having it static as shown in Self powered application may not work. Hope It helps you.
Cheers,
STOne-32.
2024-03-15 07:02 AM - edited 2024-03-15 08:56 AM
Hi,
DFU mode is (boot0 hi at start/reset) for starting the (internal) bootloader .
STM32CubeIDE is for program, compile...debug.
So use CubeProgrammer, mode (blue box-> set to USB UART) , then try connect with your cpu in boot mode.
ed.
(You need not to write any program for this, bootloader is on chip.)
(You need to write a program for this on USB, bootloader is on chip for USART1 only.)
2024-03-15 07:27 AM
Dear @AScha.3 ,
I'm curious how you know that STM32F103 has DFU built-in Bootloader ? it is has only UART ones. You can refer to AN2606 for more details.
Hope it helps.
STOne-32.
2024-03-15 08:38 AM
Sorry, @STOne-32 ,
I forgot... :) only connectivity line has:
2024-03-15 12:19 PM - edited 2024-03-15 12:38 PM
I have researched after reading your post, and found an example using the same uC. Here it is used a transistor to switch the pull up from the PA15/JTDI pin. I did this with my board, but since I don't have a transistor in hand right now (and would not like to solder in all of my boards), I soldered a wire from PA15 to the resistor instead of the constant Vcc I had before. I don't think it would be a problem because with 3v3 and 1k5 ohms, the current would be 2mA, so it should be ok? I appreciate any feedback.
Unfortunately now windows don't recognize the usb at all. Is there any code I need to load in the uC? Is PA15 really the right pin? Is there anything else wrong?
From @AScha.3 reply, I have to write a program for USB, but how? Is there any example?
2024-03-15 12:59 PM
The 1k5 pullup on DP+ works fine on my boards .
Bootloader example...see:
https://github.com/rogerclarkmelbourne/STM32duino-bootloader