cancel
Showing results for 
Search instead for 
Did you mean: 

USB MTP object transfer only transfers 16 bytes of data

JRoyn.1
Associate II

Hello,

I’m struggling using STM32_USB_Device_Library V2.10.

I’m developing a device with storage, and I want to transfer files via USB to a Windows PC using MTP.

I currently have a simple setup using STM32H7B3 eval board. I have made a test project with STM32_USB_Device_Library using the USB HS.

I have come so far that the device is showing up on the PC, and I can read contents (files) from the dummy file system on the device (currently I just fake the file system). Files are showing up correctly in File Explorer. I have 5 files, from 1K to 5K size, on the device.

But when I try to transfer the files to PC, I only get 16 bytes of data. Size of file is showing correct in Windows Explorer for the device, but for the transferred file, it is only 16 bytes. It also does not contain correct data, only a chunk of the first data in the file.

I have used usbd_mtp_if_template.c as start, and implemented the functions for reading file system data.

The USBD_MTP_Itf_ReadData() looks like this:

static uint32_t USBD_MTP_Itf_ReadData(uint32_t Param1, uint8_t *buff, MTP_DataLengthTypeDef *data_length)
{
  uint8_t *pBuf = buff; 
  
  data_length->totallen = Param1 * 1000; //Just fake length
 
  uint16_t i;
  for(i = 0; i < data_length->rx_length; i++)
  {
      *pBuf = i;    //Just use fake data
      pBuf++;
  }
  
  data_length->readbytes = i;
  data_length->temp_length += i;
  
  return MTP_RESPONSE_OK;
}

Could someone please point me in the right direction, so this will work?

Regards,

Jan

0 REPLIES 0