2025-10-28 1:40 AM
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 :)
Solved! Go to Solution.
2025-10-30 1:49 AM
@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...
2025-10-28 3:15 AM
@No_Name wrote:Do I have to recreate the bootloader?
Yes.
The built-in System Bootloader uses DFU on USB - see: Application note AN2606, Introduction to system memory boot mode on STM32 MCUs.
2025-10-28 3:47 AM - edited 2025-10-30 1:13 AM
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
2025-10-28 3:53 AM - edited 2025-10-28 3:54 AM
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.
2025-10-28 4:06 PM
Yes, I am using USB CDC for VCP. In which file is the bootloader system code stored?
syscalls.c?
sysmem.c?
system_stm32f4xx.c?
2025-10-29 1:19 AM
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.
2025-10-29 2:46 AM
@No_Name wrote:In which file is the bootloader system code stored?
as @gbm said, it's not in any source file - it's programmed into ROM at the factory.
Do you have a particular reason to do this via VCP rather than use the built-in DFU - which is, surely, the standard way to do firmware updates over USB?
2025-10-29 3:31 AM - last edited on 2025-10-29 4:02 AM by Andrew Neil
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.
2025-10-29 4:06 AM
@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?
2025-10-29 10:35 AM
There's also the ST Open Bootloader: How to use the ST Open Bootloader for STM32 Microcontrollers.