Forum Rule: Always post complete source code & details to reproduce any issue!
Page 5 of 5 FirstFirst ... 3 4 5
Results 101 to 116 of 116

Thread: MTP Responder Contribution

  1. #101
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    204
    Quote Originally Posted by WMXZ View Post
    For Teensy3 you can use the descriptor file made by yoonghm on his GitHub site.
    Im more interested in Teeny4
    Has anyone been able to get the yoonghm MTP code to work recently?

    I'm on Arduino 1.8.10 and Teensyduino 1.49. I downloaded the latest Grieman SdFat (not the beta) to go with the yoonghm MTP code, per the instructions. I copied over the usb_desc.h and corrected the TRANSIMIT to TRANSMIT. I restarted the Arduino IDE. I selected USB Type -> MTP Disk (Experimental). It doesn't work for me.

    It compiles but the Teensy does not appear in Windows (I'm still Win7). I also get no Teensy showing up under the Port menu, other than "(emulated serial)", which doesn't actually do anything (no serial comms).

    Does the yoonghm MTP code work for any of you? Do you get both the MTP functionality *and* the serial?

    Thanks,

    Chip

  2. #102
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Chip Im still struggling to get on T4 Serial + MTP. MTP works but Serial does not behave on Arduino SerialMonitor but only on Putty.
    I may try tomorrow on T3 (similar to Chris) and then working backwards.

  3. #103
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    204
    @WMXZ, I just got Chris's usb_desc.h entries working with your MTP library with SdFat-beta (as you describe) with your example sketch on a T3.6.

    I get both the SD card to appear in Windows *and* I seem to get a real serial port. So that's cool! Smiles all around!

    Now, I just have to integrate the MTP functionality into a much larger project where I use an older SD library for logging. I'm not too excited about replumbing my logging code to use the newer SD library nor an I excited about trying to get both the new and the old libraries to play nice with each other.

    We'll see...

    Chip

  4. #104
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    @ WMXZ
    Im more interested in Teeny4
    I got the Teeny4 MTP and Native Serial port running just needs more testing and cleanup

  5. #105
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    Teensy 4.0 MTP + Native Serial port
    EDIT:
    Well I speak too soon the Serial port seems laggy

    MS WIN10
    Arduino-1.8.10
    Teensy Loader 1.49

    ----\arduino-1.8.10\hardware\teensy\avr\boards.txt
    Code:
    teensy40.menu.usb.mtp=MTP Disk (Experimental)
    teensy40.menu.usb.mtp.build.usbtype=USB_MTPDISK
    teensy40.menu.usb.mtp.fake_serial=teensy_gateway
    # EDIT TEENSY 4.0 MTP+Serial by Chris O.
    teensy40.menu.usb.mtpserial=MTP Disk (Experimental) + Serial
    teensy40.menu.usb.mtpserial.build.usbtype=USB_MTPDISK_SERIAL
    edit: ---\arduino-1.8.10\hardware\teensy\avr\cores\teensy4\usb_desc. h
    Code:
    #elif defined(USB_MTPDISK) // \cores\teensy4 usb_desc.h
      #define VENDOR_ID             0x16C0
      #define PRODUCT_ID            0x04D1
      #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_INTERFACE         2
      #define NUM_ENDPOINTS         4
      #define SEREMU_INTERFACE      1 // Serial emulation
      #define SEREMU_TX_ENDPOINT    2
      #define SEREMU_RX_ENDPOINT    2
      #define SEREMU_TX_SIZE        64
      #define SEREMU_RX_SIZE        32
      #define SEREMU_TX_INTERVAL    1  // TODO: is this ok for 480 Mbit speed
      #define SEREMU_RX_INTERVAL    2  // TODO: is this ok for 480 Mbit speed
      #define MTP_INTERFACE         2 // MTP Disk
      #define MTP_TX_ENDPOINT       3
      #define MTP_RX_ENDPOINT       3
      #define MTP_EVENT_ENDPOINT    4
      #define MTP_TX_SIZE_480       512
      #define MTP_RX_SIZE_480       512
      #define MTP_TX_SIZE_12        64
      #define MTP_RX_SIZE_12        64
      #define MTP_EVENT_SIZE        16
      #define MTP_EVENT_INTERVAL    1
      #define ENDPOINT2_CONFIG  ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT // Serial emulation
      #define ENDPOINT3_CONFIG  ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK
      #define ENDPOINT4_CONFIG  ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT  // ????
    
    #elif defined(USB_MTPDISK_SERIAL) // \cores\teensy4 usb_desc.h
      #define VENDOR_ID             0x16C0
      #define PRODUCT_ID            0x04D1
      // from (USB_SERIAL_HID)
      #define DEVICE_CLASS          0xEF
      #define DEVICE_SUBCLASS       0x02
      #define DEVICE_PROTOCOL       0x01
      #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','/','S','e','r','i','a','l'}
      #define PRODUCT_NAME_LEN      22
      #define EP0_SIZE              64
      #define NUM_ENDPOINTS         5
      //#define NUM_USB_BUFFERS     22
      #define NUM_INTERFACE         3
      #define CDC_IAD_DESCRIPTOR    1
      #define CDC_STATUS_INTERFACE  0
      #define CDC_DATA_INTERFACE    1 // Native Serial port
      #define CDC_ACM_ENDPOINT      2
      #define CDC_RX_ENDPOINT       3
      #define CDC_TX_ENDPOINT       3
      #define CDC_ACM_SIZE          16
      #define CDC_RX_SIZE_480       512
      #define CDC_TX_SIZE_480       512
      #define CDC_RX_SIZE_12        64
      #define CDC_TX_SIZE_12        64
      #define MTP_INTERFACE         2 // MTP Disk
      #define MTP_TX_ENDPOINT       4
      #define MTP_RX_ENDPOINT       4
      #define MTP_EVENT_ENDPOINT    5
      #define MTP_TX_SIZE_480       512
      #define MTP_RX_SIZE_480       512
      #define MTP_TX_SIZE_12        64
      #define MTP_RX_SIZE_12        64
      #define MTP_EVENT_SIZE        16
      #define MTP_EVENT_INTERVAL    1
      #define ENDPOINT2_CONFIG  ENDPOINT_RECEIVE_UNUSED + ENDPOINT_TRANSMIT_INTERRUPT    // Native Serial port
      #define ENDPOINT3_CONFIG  ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK           // Native Serial port
      #define ENDPOINT4_CONFIG  ENDPOINT_RECEIVE_BULK + ENDPOINT_TRANSMIT_BULK           // MTP Disk
      #define ENDPOINT5_CONFIG  ENDPOINT_RECEIVE_INTERRUPT + ENDPOINT_TRANSMIT_INTERRUPT // MTP Disk
    \libraries\MTP\example
    Important to have this: while (!Serial && millis() < 1000) {} // wait for Serial Monitor with 1s. timeout.
    Instead of while: (!Serial); // This Will Never run if serial Port is not open.
    Code:
    #include "Arduino.h"
    
    #if 1
    #include "MTP.h"
    
    MTPStorage_SD storage;
    MTPD       mtpd(&storage);
    #endif
    
    void logg(uint32_t del, const char *txt)
    { static uint32_t to;
      if (millis() - to > del)
      {
        Serial.println(txt);
        to = millis();
      }
    }
    
    void setup()
    {
      // while (!Serial);
      while (!Serial && millis() < 1000) {}  // wait for Serial Monitor with 1s. timeout.
    
      Serial.println("MTP test");  Serial.flush();
      storage.init();
      SD.ls();
    }
    
    void loop()
    {
      mtpd.loop();
      logg(1000, "loop");
    }
    Last edited by Chris O.; 01-19-2020 at 10:16 PM.

  6. #106
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by Chris O. View Post
    Teensy 4.0 MTP + Native Serial port
    EDIT:
    Well I speak too soon the Serial port seems laggy

    MS WIN10
    Arduino-1.8.10
    Teensy Loader 1.49
    That what I have and addressed in other thread

  7. #107
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    WMXZ
    I just noticed your other thread Weird behavior of SerialMonitor and I am running into the same issues.

    I cannot use automode for download (i.e. butto-press is required)
    Also cannot upload code without button press.

    TD-SerialMonitor is only showing data in blocks (every 10 seconds data are printed)
    About 2.5 second on my PC if I use Teensy Ports in Arduino IDE tools menu.
    No issues if I select Serial Ports COMx in tools menu.

  8. #108
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    I'm curious how hard would it be to add the renaming file functionality in the MTP library?
    Now we can copy files from MicroSD <--> PC and delete files.

  9. #109
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by Chris O. View Post
    I'm curious how hard would it be to add the renaming file functionality in the MTP library?
    Now we can copy files from MicroSD <--> PC and delete files.
    which functionalities?

  10. #110
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    Media Transfer Protocol 1.1 spec:
    Opcode ----- Operation --------- Name Explanation
    0x1019 ----- MoveObject ------- Rename a file or directory

  11. #111
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by Chris O. View Post
    Media Transfer Protocol 1.1 spec:
    Opcode ----- Operation --------- Name Explanation
    0x1019 ----- MoveObject ------- Rename a file or directory
    OK, will try

  12. #112
    Junior Member
    Join Date
    Oct 2018
    Posts
    13
    I still can't get MTP to work on Linux with the t4.

    The t3.6 worked using yoongmh's library, wolfmanjm's edits and SdFat, but then I upgraded to IDE 1.8.10 and Teensyduino 1.49 and it all went belly up.

    The mtp-test example with the latest mtp-t4 library (21st Jan) compiles with the following warnings now:

    Code:
    In file included from /home/dean/arduino-1.8.10/hardware/teensy/avr/cores/teensy4/WProgram.h:45:0,
                     from /tmp/arduino_build_409530/pch/Arduino.h:6,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/SdFat-beta/src/common/../SdFatConfig.h:45,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/SdFat-beta/src/common/SysCall.h:33,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/SdFat-beta/src/SdFat-beta.h:31,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP_config.h:8,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP_Storage.h:40,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP.h:35,
                     from /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP.cpp:30:
    /home/dean/arduino-1.8.10/hardware/teensy/avr/cores/teensy4/wiring.h: In instantiation of 'constexpr decltype (((a < b) ? forward<A>(a) : forward<B>(b))) min(A&&, B&&) 
         [with A = long unsigned int; B = int; decltype (((a < b) ? forward<A>(a) : forward<B>(b))) = long unsigned int]':
    /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP.cpp:351:55:   required from here
    /home/dean/arduino-1.8.10/hardware/teensy/avr/cores/teensy4/wiring.h:73:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       return a < b ? std::forward<A>(a) : std::forward<B>(b);
                ^
    /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP.cpp: In member function 'uint32_t MTPD::SendObjectInfo(uint32_t, uint32_t)':
    /home/dean/arduino-1.8.10/hardware/teensy/avr/libraries/MTP_t4/src/MTP.cpp:475:9: warning: unused variable 'size' [-Wunused-variable]
         int size = read32(); len -=4;
    IDE cannot connect to the t4 and I have to press the button. The programme seems to upload (bright red LED) and then nothing. If I attempt to open Nautilus, it hangs. I then disconnect the USB from the t4, Nautilus opens as normal. Reconnect the t4 with Nautilus open and the t4 isn't there.

    Thanks for the effort you are putting in, hope you can get it sorted.

  13. #113
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by xenington View Post
    I still can't get MTP to work on Linux with the t4.

    The t3.6 worked using yoongmh's library, wolfmanjm's edits and SdFat, but then I upgraded to IDE 1.8.10 and Teensyduino 1.49 and it all went belly up.

    The mtp-test example with the latest mtp-t4 library (21st Jan) compiles with the following warnings now:

    ....

    IDE cannot connect to the t4 and I have to press the button. The programme seems to upload (bright red LED) and then nothing. If I attempt to open Nautilus, it hangs. I then disconnect the USB from the t4, Nautilus opens as normal. Reconnect the t4 with Nautilus open and the t4 isn't there.

    Thanks for the effort you are putting in, hope you can get it sorted.
    Warnings are OK, I have them too.

    IDE issues are complicated as MTP is officially not yet supported for T4. So expect button press for download. Killing SerialMonitor before download may help.

    Don't use Linux, but it was working on a Linux machine using Nautilus.

  14. #114
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by Chris O. View Post
    Media Transfer Protocol 1.1 spec:
    Opcode ----- Operation --------- Name Explanation
    0x1019 ----- MoveObject ------- Rename a file or directory
    Seems more complicated (need to hack more the MTP_storage code), also, while I understand to move file or directory it is not clear how to rename a file or directory.
    This is as the move object does not change object description and index.
    So I lowered the priority of this feature.

  15. #115
    Senior Member
    Join Date
    Dec 2013
    Posts
    253
    Seems more complicated (need to hack more the MTP_storage code), also, while I understand to move file or directory it is not clear how to rename a file or directory.
    I think you are correct, this is all thanks to >Wikipedia error<. Since now that I downloaded the specification for Media transport protocol v1.1 I don't see a way of rename a file with that Opcode 0x1019.

  16. #116
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,457
    Quote Originally Posted by Chris O. View Post
    I think you are correct, this is all thanks to >Wikipedia error<. Since now that I downloaded the specification for Media transport protocol v1.1 I don't see a way of rename a file with that Opcode 0x1019.
    could use 0x9804 SetObjPropValue (it is used by Viveris)

Posting Permissions

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