Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Trouble extending Mass Storage Device MTP Disk

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    11

    Trouble extending Mass Storage Device MTP Disk

    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?

  2. #2
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,157
    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

  3. #3
    Junior Member
    Join Date
    Dec 2016
    Posts
    11
    I saw this
    https://forum.pjrc.com/threads/28716...-Functionality
    which directed me to the instructions at the start of usb_desc.h which I followed to produce the entries above. I probably stuffed it up somehow. Can you please provide a link to the forum posts? I don't seem to be able to find much else.

  4. #4
    Junior Member
    Join Date
    Dec 2016
    Posts
    11
    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.

  5. #5
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,157
    If you wanted to add new descriptor see for example https://forum.pjrc.com/threads/26024...a-new-USB-type
    if you to modify a descriptor this thread gives you also what you need to know
    caveat: I never modified/added USB_types

  6. #6
    Junior Member
    Join Date
    Dec 2016
    Posts
    11
    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!

  7. #7
    Junior Member
    Join Date
    Dec 2016
    Posts
    11
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •