cancel
Showing results for 
Search instead for 
Did you mean: 

Query: STM32F4 programming with USB

Mike xx
Associate III

I can program my bespoke board using a repurposed USB port. It would normally be used by a mouse.

I was under the impression that if I powered up the board with BOOT0 pin held high the MCU would be in a state to connect to USB and do it's enumeration. However, using USB Device Tree Viewer I can see the 43 error.

If I then hold the NRST pin low for a few seconds, and then release enumeration follows and I am able to program the device.

Is this expected operation? I thought simply powering up the PCB with BOOT0 high would place the MCU in the correct state ready for programming?

6 REPLIES 6
SofLit
ST Employee

Hello,

You need to reset the MCU after holding high the BOOT pin .

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.

Thanks for confirming. I can't find any programming guide or application note that says that, hence the question.

Furthermore, I find for reliable connection I have to power up in reset, remove the reset link and then attach the USB cable to the socket.

In fact the whole process of connecting is a little unreliable depending on port and / or the USB hub.

Check you cable and your hardware.

You can either use reset or power cycle the MCU after pulling up the BOOT pin.

You can also refer to these articles:

DFU mode with system bootloader is not working, while USB does

FAQ STM32 boot process

How can I use STM32CubeProgrammer to access the USB-DFU bootloader on my STM32 board?

Hope that helps.

 

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.
TDK
Guru

Powering up with BOOT0 held high should be sufficient. Might be running into an issue with the crystal having a startup time.

If you feel a post has answered your question, please click "Accept as Solution".
Mike xx
Associate III

I find this using this bootloader process unreliable.

I can put a frequency meter on the 8MHz crystal. Whether it bursts into oscillation is hit and miss. With the application running, ie BOOT0 low, it always starts up.

If I hold the BOOT0 pin high with NRST high after power-up and the USB cable disconnected I can see the 8MHz crystal running

If I apply power with BOOT0 pin high and NRST low, then allow NRST go high there is no 8MHz oscillation until I connect the USB cable. It seems the longer the PCB is powered the process becomes more reliable.

I see a comment in AN2606 regarding temperature:

  "When (because of temperature variations or other conditions) the internal oscillator precision is altered above the tolerance band (1% around the theoretical value), the bootloader can calculate a wrong HSE frequency value. In this case, the bootloader DFU/CAN interfaces can malfunction, or not work at all."

That doesn't instil much confidence in reliable programming. I was hoping to remove the JTAG connector from the build, but JTAG seems the most reliable way to go.

Perhaps the crystal selection or design could be improved.

Guidelines for oscillator design on STM8AF/AL/S and STM32 MCUs/MPUs - Application note

What you're doing should work on ST boards.

If you feel a post has answered your question, please click "Accept as Solution".