USBD MSC - fs_ioc_get_id ("U0:") returns error

Hello, I would like to configure my STM32F769 so that the connected USB stick can be used by windows explorer as a mass data storage device.

I have already tried it with the example programs. So it is possible to display an SD card or a memory area in the explorer. But a USB stick does not work. The function fs_ioc_get_id ("U0:") always returns an error 0xFFFFFFFD. It seems that the I/O control interface routines do not support a USB stick.

It is not the hardware, in other programs I can write to the USB stick normally when it is connected to the device. Only that forwarding as MSC is not possible.

Has anyone here ever done this before and could help?

My Code looks like this:

#define MEDIA_DRIVE     "U0:"

any_Thread()
{
    USBD_Initialize(0U);
    USBD_Connect(0U);
    ...
}
	
	
void USBD_MSC0_Initialize (void) 
{
  uint32_t param_status;
 
  usbd_msc0_media_own = MEDIA_OWN_USB;  // Initially media is owned by USB
  media_ok            = false;          // Current media status (not initialized = not ok)

  if (finit (MEDIA_DRIVE) != fsOK) {    // Initialize File System
    return;                             // Exit if failed
  }
  drv_id = fs_ioc_get_id (MEDIA_DRIVE); // Get ID of media drive
  if (drv_id < 0)           { return; } // If ID is invalid exit
 
  param_status = 0U;                    // Parameter for function call is 0
                                        // Initialize media
  if (fs_ioc_device_ctrl (drv_id, fsDevCtrlCodeControlMedia, &param_status) != fsOK) {
    return;                             // Exit if failed
  }
 
  if (fs_ioc_lock (drv_id)) {           // Lock media for USB usage
    return;                             // Exit if failed
  }
 
  media_ok = true;                      // Media was initialized and is ok
}

Parents Reply Children
More questions in this forum