cancel
Showing results for 
Search instead for 
Did you mean: 

Azure USBX storage / fileX / ramdisk: how to make windows reload the content of the device?

Johannes
Senior

Hello Everyone:

I use azure RTOS USBX storage (MSC) and FileX.. My STM32H735 acts as a USB storage device using a RAM-Disk. I have FileX running, which allows me to add files to the RAM-Disk from inside the STM32H735

Problem: Windows caches the content of the RAM disk. Once I add a file from within STM32, windows does not detect that.

What do I have to do, to make windows re-load the content of the storage device?

Unplugging USB is not a solution

There is USBD_Storage_Status, which is used to return SCSI sense codes

I tried multiple like 0x02 0x28 0x00 (device not ready, medium might have changed)

If I start with this status, windows properly detects, that there is no medium in the device and says "please insert medium"

If I switch to the sens code 00: NO SENSE (all fine), windows properly loads the content of the drive.

But if I switch back to "no medium", windows still keeps the drive content in a cache.

How to force windows to reload?

Disabling USB and re-enabling USB might help, but I have a multi endpoint USB (Mass storage and CDC_ACM). I don't want to disable USB completely

Maybe there is an example out there for a mass storage with a removable medium.

Thank your for your help

Johannes

2 REPLIES 2
Johannes
Senior

Sorry. Found it myself.

The SCSI sense response must be "0x02 0x3A 0x00" medium not present.

Then windows does not show the device. When switching back to 0x00 0x00 0x00, windows the content and shows the drive again.

ux_device_msc.c

/**
  * @brief  USBD_STORAGE_Status
  *         This function is invoked to obtain the status of the device.
  * @param  storage_instance : Pointer to the storage class instance.
  * @param  lun: Logical unit number is the command is directed to.
  * @param  media_id: is not currently used.
  * @param  media_status: should be filled out exactly like the media status
  *                       callback return value.
  * @retval status
  */
UINT USBD_STORAGE_Status(VOID *storage_instance, ULONG lun, ULONG media_id,
                         ULONG *media_status)
{
  UINT status = UX_SUCCESS;
 
  /* USER CODE BEGIN USBD_STORAGE_Status */
  UX_PARAMETER_NOT_USED(lun);
  UX_PARAMETER_NOT_USED(media_id);
 
  if(mediumPresent) {
	  *media_status=0;
	  status=UX_SUCCESS;
  }
  else {
	  status=0x00003A02; //medium not present
	  *media_status=status;
  }
  /* USER CODE END USBD_STORAGE_Status */
 
  return status;
}

dryet
Associate II

Hello, 

I don't know if this post is still active, but I want to iplement the same thing (running USBX MSC which uses RAM as storage) and I wonder if you have used filex to define STORAGE_READ and other MSC functions or is your usbx code running on you own RAM allocation?

Thank you in advance.