Forum Rule: Always post complete source code & details to reproduce any issue!
Page 12 of 12 FirstFirst ... 2 10 11 12
Results 276 to 298 of 298

Thread: MTP Responder Contribution

  1. #276
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Quote Originally Posted by WMXZ View Post
    Surprise:
    compiled with option smallest code and got it working with speed of 600 MHz.
    makes little sense to me, except optimization is removing some weird coding (side effects).

    Good is that having it working, one could investigate code differences and nail down bug.
    Ok that's weird but that its working is good at 600Mhz. But need to figure out the bug - unfortunately wouldn't really know where to start. Have to get to beta test thread and check. Know there was some interesting things at that point.

  2. #277
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    Another Update
    suspecting that USB transfer status is not stable at high CPU speeds
    I activated alternative code in
    file: usb.c
    function: usb_transfer_status
    changed #if 0 to #if 1

    program compiled again with faster and up 600 Mhz and MTP responds correctly

    @Paul: would it be wise to keep this always activated ?

  3. #278
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Was actually looking at usb.c this morning as well and didn't see that. I was focusing on whether there was a need to implement buffers for rx and tx. Also noticed if I remember on USB transfers it disable interrupts for USB1 and wasn't sure if that you impact MTP so just left it since I never played with implementation of USB before.

  4. #279
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57
    would someone with a fully working setup mind zipping their arduino install and library folder for me to try please?

  5. #280
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Quote Originally Posted by JaredReabow View Post
    would someone with a fully working setup mind zipping their arduino install and library folder for me to try please?
    These are the only three libraries you need:
    USB2-master.zip
    MTP_t4-master.zip

    Cant upload sdfat lib but just download the latest SDFat-beta library. Heres my config file:
    SdFatConfig.h

    That's all you really need. Basically I just redownloaded all the three libs and edit the sdfat config file per instructions. No changes to usb_desc for sermu

  6. #281
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57
    thanks, sadly that didnt work, however, i realised i did not have the 10ms delay with the mtpd.loop().
    When i put in that delay it works for all but copying too.

    As an aside, i cannot get .exists() to function with sdFs, the file always returns as false, any ideas?

  7. #282
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    Quote Originally Posted by JaredReabow View Post
    thanks, sadly that didnt work, however, i realised i did not have the 10ms delay with the mtpd.loop().
    When i put in that delay it works for all but copying too.

    As an aside, i cannot get .exists() to function with sdFs, the file always returns as false, any ideas?
    There is NO delay(10) . (it was for a while for testing only and it does not slow down the transfer)
    Advice: please follow procedure indicated by mjs513
    if seremu does not work, please follow the instructions to activate MTP_DISK_SERIAL. that is what I'm using

  8. #283
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57
    You misunderstand. I am not talking about serial or serum.
    I mean that for mtp mass storage, if I do not have the 10ms delay, the teensy freezes when I try access MTP drives.

  9. #284
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    Quote Originally Posted by JaredReabow View Post
    You misunderstand. I am not talking about serial or serum.
    I mean that for mtp mass storage, if I do not have the 10ms delay, the teensy freezes when I try access MTP drives.
    OK, let me be clear.
    There are only 2 versions MTP+SEREMU and MTP+SERIAL, both are based on usb1_mtp.c for MTP and usb.c for SEREMU or SERIAL
    There is no MTP alone.
    As you can see from this thread usb.c needs to be modified for higher speeds to wait for busy status to be cleared. (post #277)
    Have you done that?
    If it is still blocking, then you should reduce clock.
    BUT note, here it is working with MCU speed of 600 MHz

  10. #285
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57
    Hey @WMXZ, sorry I think there was crossed wires on our communication.
    I understand that it needs modification for higher speeds, I was only reporting my personal experience whilst experimenting.

  11. #286
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Quote Originally Posted by JaredReabow View Post
    Hey @WMXZ, sorry I think there was crossed wires on our communication.
    I understand that it needs modification for higher speeds, I was only reporting my personal experience whilst experimenting.
    You are getting strange results. Make sure you make the change in usb.c for high speed as you said. Second try it with the MTP_test sketch first before experimenting. If it works with that then it has be something you are doing while experimenting. If you post your test sketch I can give it a try and see if it freezes my teensy. Also I am using the usb_desc as installed by Teensyduino. So if you made any changes to those files you may be running into an issue

  12. #287
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    57
    Quote Originally Posted by WMXZ View Post
    Another Update
    suspecting that USB transfer status is not stable at high CPU speeds
    I activated alternative code in
    file: usb.c
    function: usb_transfer_status
    changed #if 0 to #if 1

    program compiled again with faster and up 600 Mhz and MTP responds correctly

    @Paul: would it be wise to keep this always activated ?
    After implementing this change, everything works properly on MTP disk, even with overclocking to 1ghz

  13. #288
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Yep. Glad you got it working. That change is mandatory otherwise you are stuck with a max of 450Mhz

  14. #289
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    @WMXZ
    I'm going through storage.cpp with the good intention to see if I can get it work with SPIFFS on the external Flash. Doing it function by function but running into some things I need some help with understanding.

    I got up to the ScanDir function and trying to understand what it's doing. It looks like its being called from StartGetObjectHandles which I would have thought should be returning the file handle? But guess what's confusing me is that you opening and writing records from the functions? Guess I really don't know what i am doing at this point

    EDIT: Also whats the purpose of parent-child? Is that the equivalent of directory-file?

  15. #290
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    @mjs513,
    To be honest, the overall structure of the MTP - storage philosophy was created by the original author.
    AFAIK,
    there was a basic design criteria: to keep a directory structure a linked records on disk and not in memory.
    and to scan directory only on demand. It turned out that Windows scans directories only shallow, while some Linux MTP hosts make a deep scan.
    -Anyhow, parent-child-sibling structure form a linked list that correspond to the directory tree.
    Each record contain relevant information on file for fast and consistent access to data.

    I guess, you have the MTP documentation at hand.

    At a point I wanted to implement my own tree-structure, but stopped as I needed quickly something that works.

  16. #291
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    @WMXZ
    Began to start sorting things out. But do you have a link for the MTP document.

    There are 2 things with SPIFFS - no sub-directories allowed and second I can get the all the file info with a simple list dir command. So guess I got my work cut out for me

  17. #292
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    Quote Originally Posted by mjs513 View Post
    @WMXZ
    Began to start sorting things out. But do you have a link for the MTP document.

    There are 2 things with SPIFFS - no sub-directories allowed and second I can get the all the file info with a simple list dir command. So guess I got my work cut out for me
    can you access https://www.usb.org/document-library...ters-agreement ?

  18. #293
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Got it thanks

  19. #294
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    Quote Originally Posted by mjs513 View Post
    Got it thanks
    Great,
    You realize that actual mtp implementation has still some debug information, checking with document what every step does was very helpful for me.

  20. #295
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Thanks think I will turn it on to see what its doing and maybe add some more debugging. Also am looking at original implementation in the post #1 just for reference.

    Well another time consuming project

  21. #296
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    @WMXZ
    Just thought I would give you all a bit of an update on this. I have to rework the Storage piece for SPIFFs and am at the point where I can see the files that I created on the FLASH using MTPResponder. Still have work to do on copying and pasting files but most of that is my implementation. Also had to create a couple of additional functions for the SPIFFS calls But just to show you that it can be done here is a screen shot of the SPIFFS directory on the FLASH chip:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	7 
Size:	14.6 KB 
ID:	20250

    Hopefully another few days and will have something that works better.

  22. #297
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,640
    @mjs513,
    thanks for update.
    looking forward to see another storage implementation.

  23. #298
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,105
    Quote Originally Posted by WMXZ View Post
    @mjs513,
    thanks for update.
    looking forward to see another storage implementation.
    Got it working 99.9%. See this thread: https://forum.pjrc.com/threads/61101...196#post241196. Made it separate so won't get this thread too crazy.

Posting Permissions

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