2025-07-07 6:40 AM
Hi all,
this is my first project with the STM32H5 and the new FileX/UsbX, before I was using G0 and F4 chips and knew my way around the FatFS and USBD software packages...
A new project made the use of the H5 necessary because it has a USB and SDMMC peripheral.
I want to configure the H523RCT6 as a USB mass storage device that gets detected by a PC and provide mass data storage via the SD-card (SDMMC1 peripheral). As soon as the PC puts a file on the SD card I need to detect it and stream it via UART to a different device...
My problem is that I can't find a configuration that allows me to simultaneously use the SD-card as mass storage for the PC and detect when the contents were changed on the card.
Right now every possibility I considered are suboptimal or do not work.
Option 1: periodically init the FileX on the SD-card, check for files and transmit them via UART, then de-init FileX and init USB MSC. The problem here is that I cannot detect when the USB transfer is finished. I could implement some timeout on the USB peripheral (e.g. if idle for more than 10s) to de-init the USB and re-init the FileX, but I could not find a De-init function for the UsbX, only MX_USBX_Device_Init() in app_usbx_device.h... If I de-init the USB while the PC wants to transfer a file and the file is lost I have a problem... this must not happen.
Option 2: somehow fake the USB mass storage and use a buffer in the uC RAM for the PC to write to and then manually write the data to the SD-card so I don't need to de-init and re-init the USB and FileX -> I couldn't find an option to do that without the disk size being too small. The PC needs to see at least 4GB of storage attached to initiate the file transfer and I cannot afford to lose data due to some buffer overflow in RAM.
I am using CubeIDE and CubeMX. I am happy for any suggestions.
Thanks!