Trouble extending Mass Storage Device MTP Disk

Status
Not open for further replies.

prickle

Active member
The MTP Responder https://github.com/yoonghm/MTP works great using the provided MTP Disk (Experimental) usb type selection.

However, if I try extending the MTP disk functionality with other usb devices I get odd problems.

This is on Windows 7 ultimate sp1, using Teensy 3.6. I have tried clearing the USB cached devices, changing the USB descriptors and reinstalling many times but issues persist.

For instance, if I try this addition to usb_desc.h

Code:
#elif defined(USB_MTPDISK_SERIAL)
  #define VENDOR_ID		0x16C0
  #define PRODUCT_ID		0x04D7
  #define BCD_DEVICE		0x0215
  #define MANUFACTURER_NAME	{'T','e','e','n','s','y','d','u','i','n','o'}
  #define MANUFACTURER_NAME_LEN	11
  #define PRODUCT_NAME		{'T','e','e','n','s','y',' ','M','T','P',' ','D','i','s','k'}
  #define PRODUCT_NAME_LEN	15
  #define EP0_SIZE		64
  #define NUM_ENDPOINTS         5
  #define NUM_USB_BUFFERS	30
  #define NUM_INTERFACE		3
  #define MTP_INTERFACE		3	// MTP Disk
  #define MTP_TX_ENDPOINT	4
  #define MTP_TX_SIZE		64
  #define MTP_RX_ENDPOINT	4
  #define MTP_RX_SIZE		64
  #define MTP_EVENT_ENDPOINT	5
  #define MTP_EVENT_SIZE	16
  #define MTP_EVENT_INTERVAL	10
  #define CDC_IAD_DESCRIPTOR	1
  #define CDC_STATUS_INTERFACE	0
  #define CDC_DATA_INTERFACE	1	// Serial
  #define CDC_ACM_ENDPOINT	1
  #define CDC_RX_ENDPOINT       2
  #define CDC_TX_ENDPOINT       3
  #define CDC_ACM_SIZE          16
  #define CDC_RX_SIZE           64
  #define CDC_TX_SIZE           64
  #define ENDPOINT1_CONFIG	ENDPOINT_TRANSMIT_ONLY
  #define ENDPOINT2_CONFIG	ENDPOINT_RECEIVE_ONLY
  #define ENDPOINT3_CONFIG	ENDPOINT_TRANSMIT_ONLY
  #define ENDPOINT4_CONFIG	ENDPOINT_TRANSMIT_AND_RECEIVE
  #define ENDPOINT5_CONFIG	ENDPOINT_RECEIVE_ONLY

Along with this addition in boards.txt
Code:
teensy36.menu.usb.serialmtp.build.usbtype=USB_MTPDISK_SERIAL
teensy36.menu.usb.serialmidimtp=Serial + MIDI + MTP Disk

MTP disk is present and is usable but the serial port appears broken, appearing as "unknown" in the ports menu.
Other combinations I have tried always appear to leave one of the interfaces broken.

Also, here is my clumsy attempt to write an MTP driver for Serialflash devices. This is also not working quite right yet, files transfer but the windows explorer does not refresh to show them until a replug. It was working but stopped at some point so not sure if it is just that I broke my Windows USB stack.
https://github.com/prickle/MTP
So now I'm stuck. I don't know what I'm doing so no surprise really. Can anybody please suggest where I might be going wrong?
 
AFAIK, there is more to adding new USB device than adding text to usb_desc.h
In the forum, some years ago, there was an example on how to add own devices
 
Cut-paste error above, the relevant entry in boards.txt is
Code:
teensy36.menu.usb.serialmtp=Serial + MTP Disk
teensy36.menu.usb.serialmtp.build.usbtype=USB_MTPDISK_SERIAL
What I was really wanting is
Code:
teensy36.menu.usb.serialmidiaudiomtp=Serial + MIDI + Audio + MTP
teensy36.menu.usb.serialmidiaudiomtp.build.usbtype=USB_MIDI_MTP_SERIAL_AUDIO
which I tried first but breaks worse. In this case transfers to MTP freeze after transferring a small number of packets leaving incomplete files. To debug this I tried simpler configurations and just having serial with MTP as above is enough to fail.

Note that the original MTP with Teensy HID emulated serial still works for me, as does other serial based selections without MTP. I can have either serial or MTP but not both.
 
Thanks for the reply, I had not seen that thread but it has left me a little bit confused. It speaks of XX_DESC_OFFSET and CONFIG_DESC_SIZE defines in the usb device entries. These do not seem to be mentioned or present in the current installed usb_desc.h. Are they still relevant or perhaps no longer required?

However, the thread also suggests looking for #if defined(USB_XXX) in the usb type drivers, this sounds promising. I will examine the serial driver to see if it needs another #if defined() in order to pick up the modified type entry. Cheers!
 
Too bad, not it. The serial picks up on
Code:
#if defined(CDC_STATUS_INTERFACE) && defined(CDC_DATA_INTERFACE)
which are defined in the failing entry. It seems to me the defines should be working and the driver is being brought in. On further reflection, I think if the driver was being excluded serial would not work or show up at all rather than being present but not functional as it is.

My vague theory is that one of the endpoints is being clobbered somehow. I haven't a clue how to investigate this further. Is the entry I composed in the first post valid or did I make a mistake there?
 
I never made any further progress on this despite spending too much time on it. I would very much like to see it working, but debugging it seems beyond my ability. Having exhausted myself with it, I thought I would wait for the topic to come up again, secretly hoping somebody else would perhaps fix it in the meantime. No such luck.

I would love it if somebody could help to take a look at MTP combined with other USB types? Even in it's current state I found it a very useful functionality. It seems to be almost working..
 
I need to be able to at least switch between MTP and Serial+MIDI, I don’t need them simultaneously but the user needs to be able to go into “disk mode”. So I will be putting some hours into this.

Could you share your latest code/files and explain where you’re at? I will absolutely share my work as well.
 
Status
Not open for further replies.
Back
Top