cancel
Showing results for 
Search instead for 
Did you mean: 

Flashing a blank STM32

ym21
Visitor

I have an STM32L4R5ZI-P on a custom PCB. When designing the PCB I did not think far ahead enough and do my due diligence when it came to assigning and wiring pins on the STM32 in order to flash it. My design incorporates  USB D connected to my PCB which supplies power, and such, along with connections to USB_DM and USB_DP on my STM32. I did not wire BOOT0 or NRST. After looking online a bit, I heard that I must pull BOOT0 high and NRST low, allowing the STM32 to enter boot mode and then I can flash my STM32 via the DM and DP pins (using the CubeIDE and CubeProgrammer, etc.). I was just planning to jump BOOT0 to 3.3V and NRST to GND and then use my DM and DP pins on the USB to program is somehow using my PC. Am I thinking about this correctly? Is there an easier way to flash my virgin STM32 on my custom PCB? I do have a NUCLEO evaluation board for my specific STM32L4, which I have programmed and ran code on already. I was wondering if I can utilize the ST-LINK that is on the NUCLEO board to flash the virgin STM32 on my custom PCB. Any advice or pointers will help. Thank you

7 REPLIES 7
TDK
Super User

Yes, you can jump to bootloader by pulling BOOT0 and then applying power and using the USB DFU bootloader from STM32CubeProgrammer.

Don't jump NRST to GND. That will prevent it from doing anything. Floating is okay. Would be better to have 0.1 uF cap on there.

 

Not having a way to debug the board (i.e. a SWD ST-Link connection) will not lead to a productive development environment.

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

When you say "USB DFU bootloader", are you referring to the DP and DM pins that I have connected on my USB? To facilitate a productive development environment, can I snap off the ST-LINK from my NUCLEO board and somehow use that to debug my PCB MCU?

Yes, the USB DFU bootloader uses the USB connection, so the DM/DP pins on the board.

You'd need to connect the programmer to the SWD pins on the board. If they're exposed and you can do so, that'll work.

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

Thank you for the response. I apologize, but I am new to this space and I would just like to clarify.

So in order to flash a virgin STM32 on a custom PCB, I only need USB_DM and USB_DP pins, along with BOOT0 pulled high in order to flash it? In addition, to debug, I would need to jump the SWD pins on the virgin STM32 on my PCB to the ST-LINK module (that I can snap off of my NUCLEO board) on my NUCLEO board in order to debug the virgin STM32? Are there any other pins that are necessary to connect on my virgin STM32, like USART or LPUART? 

> So in order to flash a virgin STM32 on a custom PCB, I only need USB_DM and USB_DP pins, along with BOOT0 pulled high in order to flash it?

Yes. There are other ways to flash the chip, but this will do it for an STM32L4xx chip.

> In addition, to debug, I would need to jump the SWD pins on the virgin STM32 on my PCB to the ST-LINK module (that I can snap off of my NUCLEO board) on my NUCLEO board in order to debug the virgin STM32?

Yes. You don't have to snap it off, you can disconnect it from the target chip by removing the two SWD jumpers.

> Are there any other pins that are necessary to connect on my virgin STM32, like USART or LPUART? 

The st-link VCP pins (UART TX/RX) are not necessary, but they can be helpful. Some people route them to the printf statement to aid debugging.

I always recommend using a standard debugging header that connects directly to the programmer with a ribbon cable. For example, the 14-pin connector on STLINK-V3MINIE, which has all of the pins we discussed, including SWD and VCP/UART.

STLINK-V3MINIE | Tool - STMicroelectronics

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

What if I jump the SWDIO, NRST, SWDCK, and DETECT pins on my virgin PCB STM32 to the ST-LINK debugger on my NUCLEO board? Will that allow me to program and debug my virgin MCU at the same time?

Thank you for your help so far.

And GND, yes.

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