Forum Rule: Always post complete source code & details to reproduce any issue!
Page 3 of 3 FirstFirst 1 2 3
Results 51 to 61 of 61

Thread: MTP Responder Contribution

  1. #51
    Junior Member obiwan45's Avatar
    Join Date
    Dec 2017
    Posts
    13
    THANK YOU.. Maybe its not working on Teensy 3.5 I guess

  2. #52
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,175
    That's normal. Only the Teensy 3.6 has the second USB port which can be configured as a USB host. That's clearly visible in the comparison table here : https://www.pjrc.com/teensy/techspecs.html.

  3. #53
    Senior Member
    Join Date
    Sep 2015
    Location
    Taiwan, Asai. (Traditional Chinese)
    Posts
    148
    just in case,
    it may need a micro SD card in the built-in slot to show the device?

  4. #54
    Junior Member
    Join Date
    Apr 2018
    Posts
    1
    Hi, just inquiring if it is possible to use the second USB port on the Teensy 3.6 with MTP? If so, can you advise how to make it work?

    Thanks in advance.

  5. #55
    Junior Member
    Join Date
    Oct 2018
    Posts
    2
    So with the MTP_Blinky.ino code running on a Teensy 3.6 is it supposed to show up on a Windows PC as a USB Drive or is there more to be done to make this happen?

  6. #56
    Junior Member
    Join Date
    Nov 2018
    Posts
    9

    Using MTP on Audio Adapter card slot

    Hi,

    Just discovered the MTP library and seems to be exactly what I need. But where can I change the settings in order to work with the SD slot of the Audio Adapter?

    I saw a lot of flags in 'SdFatConfig.h' to change set custom SPI configuration (only for STM32 and AVR boards).

    Since I use a Teensy 3.6, the same file enables SDIO and SDIOEX classes... where I have no clue, how to make it work on the audio adapter slot.

    Can someone help me? Thanks, Sebastien

    P.S. And if you ask why I don't simply use the built-in slot, it's for historical reasons: I started using the "upper" one, that was easier to handle. And now I mounted the Teensy+Adapter on a PCB and can't access the built-in slot anymore

  7. #57
    Senior Member
    Join Date
    Sep 2015
    Location
    Taiwan, Asai. (Traditional Chinese)
    Posts
    148
    @sschiesser

    I think something key was written in the MTP library, but the library is relative simple to edit
    guess you can probably modify somewhere in "https://github.com/yoonghm/MTP/blob/master/MTP.h"
    like changing line 37 :
    SdFatSdioEX SD;
    to
    SdFat SD;

    Also I didn't find call of SD.begin(); in the library,
    you probably will need to do SD.begin(yourCSpin); before calling MTP.loop();
    not sure would it work

  8. #58
    Junior Member
    Join Date
    Nov 2018
    Posts
    9
    Yes it did! I thought I first need to set new #define to enable changes, but finally I just needed
    Code:
    SPI.setMOSI(myMOSIpin);
    SPI.setSCK(mySCKpin);
    in setup() and
    Code:
    SD.begin(myCSpin);
    in loop().

    Thanks, s

  9. #59
    Junior Member
    Join Date
    Nov 2018
    Posts
    9
    Good evening (@CET)

    After successful test with the MTP_blinky, I tried to implement the library into my code and get an error I can't explain: when just adding
    Code:
    #include <MTP.h>
    anywhere in my code (in main.ino, main.h or any other file), I always get the error " 'SdFat' does not name a type".

    This error also happens when I remove <MTP.h> and write
    Code:
    #include <SdFat.h>
    SdFat SD;
    The libraries are correctly installed and the examples codes work... some idea?

    Best,
    Sébastien

  10. #60
    Junior Member
    Join Date
    Feb 2019
    Posts
    2
    For anyone having troubles getting the MTP code from yoonghm's repository to work, I've figured out what's going wrong with it.

    The "MTP Disk (Experimental)" USB type choice creates three interfaces: CDC control, CDC data, and MTP. However, the configuration descriptor that is generated claims only two interfaces to exist, and the interface descriptors themselves have numbers 0, 1, and 0 respectively. Either the incorrect count, or the duplicate interface number, is enough to get Windows (7, at least) to completely reject the device - of course without giving any indication anywhere of exactly why the device is being rejected.

    To fix, you need to edit the usb_desc.h file - the one you copied from the MTP library into your Teensyduino installation. Find the section that starts with:
    Code:
      #elif defined(USB_MTPDISK)
    Just under that, find:
    Code:
      #define NUM_INTERFACE         2
    and change the number to 3, then a few lines further down find:
    Code:
      #define MTP_INTERFACE         0 // MTP Disk
    and change the number to 2.

  11. #61
    Junior Member
    Join Date
    Feb 2019
    Posts
    2
    Ok, I spoke a bit too soon about that making the code work - it at least gets the device to appear, but pretty much nothing other than creating empty folders would actually work. There was a warning during compilation that I should have paid closer attention to:
    Code:
    C:\Program Files\Arduino\libraries\MTP/MTP.h: In member function 'virtual uint32_t MTPStorage_SD::Create(uint32_t, bool, const char*)':
    C:\Program Files\Arduino\libraries\MTP/MTP.h:375:38: warning: large integer implicitly truncated to unsigned type [-Woverflow]
           OpenFileByIndex(ret, FILE_WRITE);
                                          ^
    FILE_WRITE had a value of 0x4202, but that parameter (and everything else within the SDFat library that deals with file flags) is only a byte. Somehow the compiler was picking up a traditional Unix definition of the file opening flags (O_CREAT and all that) that has the bits scattered throughout an int, instead of the Arduino definition that squeezes them all into a byte. I traced this down to the file Arduino\libraries\SdFat\src\SdFatConfig.h:
    Code:
    /** If the symbol USE_FCNTL_H is nonzero, open flags for access modes O_RDONLY,
     * O_WRONLY, O_RDWR and the open modifiers O_APPEND, O_CREAT, O_EXCL, O_SYNC
     * will be defined by including the system file fcntl.h.
     */
    #if defined(__AVR__)
    // AVR fcntl.h does not define open flags.
    #define USE_FCNTL_H 0
    #elif defined(PLATFORM_ID)
    // Particle boards - use fcntl.h.
    #define USE_FCNTL_H 1
    #elif defined(__arm__)
    // ARM gcc defines open flags.
    #define USE_FCNTL_H 1
    #else  // defined(__AVR__)
    #define USE_FCNTL_H 0
    #endif  // defined(__AVR__)
    I have absolutely no idea what the right solution is here, so I just added a couple of lines right after that to force the Arduino definitions:
    Code:
    #undef USE_FCNTL_H
    #define USE_FCNTL_H 0
    I haven't tested this very thoroughly yet, but at least I can copy a text file to the Teensy and read it back now.

Posting Permissions

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