Skip to main content
Associate III
October 28, 2025
Solved

How to update firmware via VCP

  • October 28, 2025
  • 6 replies
  • 729 views

Hello everyone.

How do I update the firmware via VCP on STM32F407VET6? Is it possible to do so? If so, what needs to be changed and added? Do I have to recreate the bootloader?

I don't know where to start here.

Thank you :)

Best answer by Andrew Neil

@No_Name wrote:

It seems that I have to create a protocol and a special bootloader for firmware updates via VCP 


Correct.

Although, as noted, you don't have to do all that from scratch - there are plenty of existing building blocks you can use.

 


@No_Name wrote:

It seems that I have to ... using HAL Flash ?


You don't have to use HAL

 


@No_Name wrote:

is HAL Flash safe for updating firmware larger than 400> kb via a custom bootloader 0x8000000 64kb?


No more nor less "safe" than any other way of doing it.

And, as @Tesla DeLorean said, beware that you can't be executing code from the same flash that you're erasing/programming...

6 replies

Andrew Neil
Super User
October 28, 2025

@No_Name wrote:

Do I have to recreate the bootloader?


Yes.

The built-in System Bootloader uses DFU on USB - see: Application note AN2606Introduction to system memory boot mode on STM32 MCUs.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Graduate
October 28, 2025

Yes, it’s possible but you’ll need a custom bootloader that supports updates over the virtual COM port. You can base it on ST’s USB CDC examples, just make sure your bootloader can receive the new firmware over USB and write it to flash memory. You don’t have to start from zero, get USB CDC communication working first, then add the flash write logic to handle the firmware update.
author : john wick
Founder: simulated game

 
 
 
No_NameAuthor
Associate III
October 28, 2025

@Andrew Neil @john15 

Yes, I am using USB CDC for VCP. In which file is the bootloader system code stored?
syscalls.c?
sysmem.c?
system_stm32f4xx.c?

gbm
Principal
October 29, 2025

There is no ready-to-use VCP bootloader. You need to write it by yourself. Probably the easier option is to use DFU bootloader built into your MCU. Read AN2606 for more info.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
Andrew Neil
Super User
October 28, 2025

As @john15 said, you don't have to start from zero.

As well as USB CDC examples, there is Application Note AN4657, STM32 in-application programming (IAP) using the USART,  which shows you the flash write logic, and suggests a suitable protocol (YMODEM) to use over the comms link - just replace the UART transport with your USB CDC...

 

PS:

X-CUBE-IAP-USART is the supporting code for AN4657.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Shirley.Ye
ST Employee
October 29, 2025

Hello,

you can use the bootloader inside the System memory to update the FW via VCP.

 

Read AN2606 to configure for the bootloader. usually need to configure the boot pin.

then in the cubeprogrammer choose UART,connected. VCP is communicating in UART communication.

then you can update the firmware.

ShirleyYe_0-1761733792395.png

 

Andrew Neil
Super User
October 29, 2025

@Shirley.Ye wrote:

you can use the bootloader inside the System memory to update the FW via VCP.


Can you? 

 


@Shirley.Ye wrote:

Read AN2606 to configure for the bootloader.


There is no mention in AN2606 of configuring the USB bootloader to use VCP.

Are you thinking of using an external VCP (USB-to-UART converter) to connect to the STM32's UART bootloader?

I don't think that's what @No_Name is asking about?

I think @No_Name wants to implement VCP on the STM32F40's USB, and update the firmware via that?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Andrew Neil
Super User
October 29, 2025
A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
No_NameAuthor
Associate III
October 29, 2025

.

Andrew Neil
Super User
October 29, 2025

@No_Name wrote:

In AN2606, I couldn't find anything about VCP.


Indeed not - I think @Shirley.Ye was mistaken or misunderstood the question there.

 


@No_Name wrote:

I have watched this YouTube video: https://youtu.be/wirNEpE6Dd4?si=0Lg5UnYFfRsD4mT8, where he customizes the bootloader to enable DFU.


That's a custom bootloader - not the System bootloader.

 


@No_Name wrote:

my application on the host is built with a VCP driver for this purpose, and I'm looking for a way to update the firmware without having to switch the driver to DFU.


That makes sense.

So, as suggested earlier, you could look at AN4657, and just change the transport from UART to VCP.

Or look at the ST Open Bootloader.

Or any 3rd-party bootloader.

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
No_NameAuthor
Associate III
October 29, 2025

@Andrew Neil 

It seems that I have to create a protocol and a special bootloader for firmware updates via VCP using HAL Flash for firmware updates. I have never tried HAL Flash before, but is HAL Flash safe for updating firmware larger than 400> kb via a custom bootloader 0x8000000 64kb?