cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer USB programming failed

MEige.1
Associate III

I'm using a STM32F105 and can program the firmware with an ST-Link to get firmware with USB DFU device driver on the device.

The device gets recognised if I connect it with USB and I can connect and read the memory without issues.

If I try to program a new firmware over USB it all looks good but after the verify step I get an error: Download verification failed.
When I check the firmware is not updated at all. It's weird because in the log I see that the sectors get ereased and download is complete but it seems nothing is written to the flash.

See print screen below.

Scherm­afbeelding 2023-12-19 om 11.49.26.png

14 REPLIES 14

Sorry but I don't follow you.

Of course I can use ST-Link to erase and program but I want to use USB DFU for software updates so the client does not need a ST-Link to update.

With the ST-link connected I can erase but if I try with a USB connection I get an error.

Error: Mass erase operation failed.Please verify flash protection

 I also don't see the sectors table in the Erasing & programming tab if connected with USB.

AFAIK, There is no working bootloader in your MCU (other than the one invoked by pulling the BOOT0 pin high). The CubeMX DFU project is just a skeleton and you are responsible for the actual implementation of Flash operations.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice
liaifat85
Senior III

Here is a discussion about the error download verification failed: https://community.st.com/t5/stm32cubeprogrammer-mcus/stm32cubeprogrammer-error-download-verification-failed/td-p/256342

You can also check this STMCUBE  IDE tutorial to find out if you're missing something.

https://www.theengineeringprojects.com/2021/10/first-project-using-stm32-in-stm32cubeide.html

 

Hi Meige maybe im not clean

1.STLink use to erase only no program and disconnect it = empty mcu

2.Boot system bootloader and connect over USB (system not your) if you dont know howto work with system boot read AN2606 or as here

And ofcourse you plan update sw , but first you need understand how on clean mcu

MEige.1
Associate III

I removed the software update class and just check VBUS during boot and jump to the device system bootloader if USB power is detected because I only use USB for software updates...

int main(void)
{
  /* USER CODE BEGIN 1 */

  // Check if we can detect VBUS
  // if so we jump to device system bootloader

  // Configure GPIO pin : PA9
  GPIO_InitTypeDef GPIO_InitStruct = {0};
  __HAL_RCC_GPIOA_CLK_ENABLE();
  GPIO_InitStruct.Pin = GPIO_PIN_9;
  GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

  if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_9) == GPIO_PIN_SET)
  {
	  // VBUS is present
	  JumpToBootloader();
  }
  else { 
	  // if we do not detect VBUS on PA9 we deinitialize the pin configuration.
	  HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9);
  }
...

void JumpToBootloader(void) {
    void (*SysMemBootJump)(void);

    volatile uint32_t addr = 0x1FFFB000; // System memory bootloader address
    SysMemBootJump = (void (*)(void)) (*((uint32_t *)(addr + 4)));

    // Reset peripherals, disable interrupts
    // we have no peripherals or interrupts started jet!

    // Set main stack pointer
    __set_MSP(*(uint32_t *) addr);

    // Jump to bootloader
    SysMemBootJump();
}