cancel
Showing results for 
Search instead for 
Did you mean: 

USB MSD problem OS send error or not fully written

MichaelQuant
Associate II

I try to write my Bootloader using stm32l1 MCU and project from link but my mcu not powerful 32MHz max and have slow flash write memory

https://github.com/sfyip/STM32F103_MSD_BOOTLOADER/blob/master/Src/

Principle: emulate Fat32 file system and directly write new firmware to flash memory with decoding it from STORAGE_Write_FS() function. Everything works, but when file size >100KB, sometimes errors occur. 50% of write tests fail. Bootloader check CRC firmware, Windows sent error, or end copies but not full firmware write. Maybe you have ideas how to solve this problem?

3 REPLIES 3
T_Hamdi
ST Employee

Hello @MichaelQuant 

Would you be able to share your implementation of STORAGE_Write_FS() and specify the exact MCU reference you used?

The project link you provided is based on the STM32F1 series, but your application appears to use an STM32L1 MCU. Unfortunately, STM32L1 introduces several hardware limitations compared to STM32F1:

  • Slower flash write speed, which affects large firmware transfers

  • Limited CPU frequency (maximum 32MHz), reducing processing throughput

  • Tighter timing constraints due to the USB MSD protocol, which can cause write failures or timeouts.

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.
Hamdi Teyeb

So, everything is identical to the project on GitHub.

Only one change: I comment out the erasure when the program launch address is detected, and before USB initialization I manually erase the program range of the flash memory (because it takes 8 seconds and the PC cannot wait that long).

I use stm32l151ret6 with 512 KB of flash memory.

To increase the speed, I disable the firmware programming and send the data to usart, the speed increases three times, but this does not solve the problem, some pieces of data sometimes do not arrive.

FBL
ST Employee

Hi @MichaelQuant 

At this level, I'm sure we cannot help you further!

Provide minimum firmware to replicate based on our stack so that we can help you! You should not see any write errors even if it takes some minutes to process data to the host.

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.