Skip to main content
Visitor II
March 4, 2022
Question

Storage access on an STM32 microcontroller

  • March 4, 2022
  • 2 replies
  • 4471 views

Hi All,

I have noticed that when connecting both of my boards [b-g474e-dpow1, stm32g474ret6u] and [NUCLEO-F429ZI, stm32f429zi] they are recognized as a storage device on windows per the picture below for the b-g474e-dpow1 board.

0693W00000KbSwCQAV.pngMy question is, these 1.51MB are part of the memory of the onboard microcontroller [stm32g474ret6u] or the STlink debugger or both?

We have an application that requires reading data points from a .txt file and place these values sequentially on a port. The user will (somehow) upload the .txt [approx 8kB] file to the microcontroller memory and when done, it will send all these points to a port when commanded.

Any recommendations for an efficient implementation for this problem?

The NUCLEO-F429ZI can provide a USB-OTG PHY. Is it possible to configure it so it behaves as a USB flash drive so the user can upload this .txt file?

Regards

    This topic has been closed for replies.

    2 replies

    Super User
    March 4, 2022

    > My question is, these 1.51MB are part of the memory of the onboard microcontroller [stm32g474ret6u]

    No. It's all done in the ST-LINK. The ST-LINK will flash the firmware, so in the end the .bin file will sit in MCUs flash.

    Yes, you can implement a USB MSC device (=flash drive) in the MCU. There are other ways like attaching a micro-SD card or using the serial connection as long as you have the ST-LINK attached.

    hth

    KnarfB

    VVarg.1Author
    Visitor II
    March 4, 2022

    Hi KnarfB

    Thanks for your reply. Understood with the memory.

    Can you educate me on what's inside the .bin file? Is it the compiled code to download to the flash?

    Super User
    March 4, 2022

    A .bin file is a 1:1 flash image of all machine code and (initialized) data.

    hth

    KnarfB

    Graduate II
    March 4, 2022

    Can probably port an MSC Device example to the NUCLEO

    STM32Cube_FW_F4_V1.25.0\Projects\STM324x9I_EVAL\Applications\USB_Device\MSC_Standalone

    There's probably also RAMDISK examples, many years back I posted a MSC example for the STM32F429I-DISCO using the SDRAM

    VVarg.1Author
    Visitor II
    March 4, 2022

    Hi @Community member​ , Thanks for your reply.

    I'll search for the examples you mentioned and hope to bring them up.

    By RAMDISK, you refer to an implementation using MSC? Or is it different

    Thanks

    Graduate II
    March 4, 2022

    A MSC USB Device, looking to the PC like a MSC, with the data stored on the STM32 side SDRAM. ie read/write map to sectors stored in SDRAM. Initial formatting could be done via FATFS MKFS, or PC could format.

    ST has some equivalent examples of this in other STM32 Cube/HAL repositories.

    Other examples of MSC USB Host, where the STM32 mounts a USB Flash Drive, as I recall this is called FWUpgrade on STM32F4-DISCO and STM3F429I-DISCO

    Normally the MSC USB Device implementations map to the SDIO/SDMMC interface to allow read/write-thru onto a MicroSD card or eMMC chip.