cancel
Showing results for 
Search instead for 
Did you mean: 

Flash hex file to stm32f412 with uart using stm32cubeprogrammer

Vaishnavi
Associate II

Tried flashing stm32f412 custom controller using uart but facing error while going to boot mode.

I need to flash my hex file to custom stm32f412 board but unable to connect using uart and facing issue while erase memory

1 ACCEPTED SOLUTION

Accepted Solutions

The system bootloader needs this UART config otherwise it won't work.

SofLit_0-1728466660725.png

In conclusion, you need to redesign your PCB or make a patch on your board.

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.

View solution in original post

16 REPLIES 16
SofLit
ST Employee

Hello @Vaishnavi and welcome to the community,

Sorry your question is not clear.

Are you using the system bootloader over UART to upload your application or with ST-Link?

As per the image you shared you are using ST-LINK with STM32CubeProgrammer not the UART, could you please provide more details about the interface you are using to upload your application?


 

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.

Hello @SofLit 

I tried with both uart and stlink to flash stm32f412 using stm32cube programmer but both are not working fine

uart:  Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again... 

stlink:  15:01:09 : Erasing memory corresponding to segment 0:
15:01:09 : Erasing internal memory sector 0
15:01:09 : Error: failed to erase memory
15:01:09 : Error: failed to erase memory

I have attached snapshot of it

As you are using a custom board you need to check your schematics and refer to the getting started HW: https://www.st.com/resource/en/application_note/an4488-getting-started-with-stm32f4xxxx-mcu-hardware-development-stmicroelectronics.pdf

For Boot mode using UART, you need to refer to the AN2606 "STM32 microcontroller system memory boot mode"

What UART instance you are using for the bootloader?

Are you using these Tx/Rx pins?:

SofLit_0-1728466660725.png

Are you configuring the MCU to enter to the system bootloader (BOOT pin(s)) and applying the reset before programming the MCU? Did you select UART as interface in the STM32CubeProgrammer?

For STLINK programming try to connect under Hardware reset:


 
Updating Media

 

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.

I'm using UART2 for flashing i.e., PA2-Tx, PA3-Rx and selected UART as interface

Connected BOOT0 to VCC and applying reset before flashing

Unable to connect with UART interface 

Getting Error: Activating device: KO. Please, verify the boot mode configuration and check the serial port configuration. Reset your device then try again... 

 

I have attached snapshot


@Vaishnavi wrote:

I'm using UART2 for flashing i.e., PA2-Tx, PA3-Rx and selected UART as interface


But as I indicated in my previous comment USART2 is using PD6 and PD5 for communication not PA2 and PA3!

Please review the  AN2606 / section 34 STM32F412xx devices

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.

In my custom board I don't have PD6 and PD5 pins, Is there any other way to flash my hex file using UART

Or I need to redesign my board?

The system bootloader needs this UART config otherwise it won't work.

SofLit_0-1728466660725.png

In conclusion, you need to redesign your PCB or make a patch on your board.

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.

Thank u for your time @SofLit

Will do rework on my custom board

Hello @SofLit 

Can I flash my hex file with stlink, I'm using PA13-SWDIO and PA14-SWCLK

But unable to flash getting error, after connecting 

15:01:09 : Erasing memory corresponding to segment 0:
15:01:09 : Erasing internal memory sector 0
15:01:09 : Error: failed to erase memory
15:01:09 : Error: failed to erase memory

And application is closing automatically