Skip to main content
Associate III
June 26, 2024
Question

Format External Flash

  • June 26, 2024
  • 2 replies
  • 1172 views

Hello team,

                  Is there any way to format the external flash of microcontroller, the reason is that that flash is acting as USB MSC Device. As soon as it connects to PC a popup will arise for disk format. Am planning to do complete mass erase of flash , along with that do i need FATfs system so that windows can recognize it as a device. Kindly guide me sample code or example for the same.

 

 

Thanks & regards,

Shikamaru

2 replies

MOBEJ
ST Employee
July 17, 2024

Hello @Shikamaru  ,

you can use STM32CubeProgrammer , it is an excellent tool for programming and erasing internal & external flash memory. Here’s how you can use it to perform a mass erase and format the external flash:

  1. Download and Install STM32CubeProgrammer:

  2. Connect Your Microcontroller:

    • Connect your STM32 microcontroller to your PC using a USB cable or ST-LINK programmer.
  3. Open STM32CubeProgrammer:

    • Launch the STM32CubeProgrammer application.
  4. Select the Target:

    • In the "ST-LINK Configuration" tab, select the appropriate interface (e.g., ST-LINK, USB, UART) and connect to your target microcontroller.
  5. Mass Erase:

    • in the "Erasing & Programming" tab Select the "Full chip erase" option to perform a mass erase of the flash memory

MOEZBEJ_0-1721224765407.png

Br

 

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.
Pavel A.
Super User
July 17, 2024

flash is acting as USB MSC Device. 

No, it is the STM32 acting as USB MSC Device towards the host (PC) and interpreting the host requests. The flash is acting as "dumb memory" (unless it is a SD/MMC card).

> do i need FATfs system so that windows can recognize it as a device.

No, the Windows (host) will act as the flesystem. You need filesystem on the STM32 side (FATFS or other) only if the STM32 program itself is the user of the storage. (but they can take turns: STM32 can mount the storage and deal with the files while the host is not looking).