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

Thread: MTP Responder for SPIFFS

  1. #1
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585

    MTP Responder for SPIFFS

    Just finished the initial library for using MTP Responder with SPIFSS on the Teensy 4.1.

    The library takes the core MTP implementation from @WMXZ MTP_t4 library and reworks the Storage class on the library to use SPIFFS on the external FLASH chip of the Teensy 4.1.

    The library has been posted on a GitHub repository: MTPspiffs_t41. You will need to download the following libraries that MTPspiffs_t41 is dependent on:


    There is one buggy thing left to fix. When you copy a file to the Flash from the PC you can not immediately delete. Appears to need a reboot for it to work consistently. So far this is the only thing I have seen that does not work 100% correctly. All other features seem to be working. There is one caveat with SPIFFS - no subdirectories.

    In addition to use MTPspiffs above 450MHz it requires a change to the core file usb.c per @WMXZ:
    modify usb.c:
    function: usb_transfer_status
    changed #if 0 to #if 1
    MTPspiffs allows you to do the same as MTP Resopnder:
    • copy files to and from the PC
    • delete files
    • open files on the Flash from the PC
    • etc



    Have fun testing.
    Last edited by mjs513; 05-26-2020 at 03:21 PM.

  2. #2
    Member JaredReabow's Avatar
    Join Date
    May 2020
    Location
    oxford , UK
    Posts
    64
    Great! Thanks for the work

  3. #3
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,350
    Seems to be working - on Win 10 without the external driver tool {see MTPdrive below }. I can copy and read a file from there. Notepad can navigate to open a file.

    No Subdirectories:: Right click new is only 'folder' - gave it a name - it doesn't show - and it isn't there on restart - that seems somewhat consistent with the earlier test of MTP.

    T_4.1 at 600 Mhz with edits. The build even told me to select the right USB

    usb.c:
    Code:
    uint32_t usb_transfer_status(const transfer_t *transfer)
    {
    #if 1
    This "#elif defined(USB_MTPDISK)" precedes where "#elif defined(USB_MTPDISK_SERIAL)" was added.

    The default is properly set in : ...\libraries\MTP_t4\src\Storage.h - but that may be for non-SPIFFS

    Just opened "MTPdrive" - It maps the 'mtp teensy' to a drive letter.
    Code:
    Z:\>dir
     Volume in drive Z is Teensy [Ext FLASH] @ MTPdrive(TRIAL)
     Volume Serial Number is 600D-CAFE
    
     Directory of Z:\
    
    05/27/2020  06:14 AM                48 mtpindex.dat
    05/27/2020  06:14 AM            12,466 Prior sketches.txt
    05/27/2020  06:14 AM               119 test
    05/27/2020  06:14 AM               119 test
    05/27/2020  06:14 AM               466 test2
    05/27/2020  06:14 AM               466 test2
    05/27/2020  06:14 AM             1,416 justOne
    05/27/2020  06:14 AM             1,416 justOne
    05/27/2020  06:14 AM             1,416 justOne.txt
    05/27/2020  06:14 AM             1,416 justOne.txt
                  10 File(s)         19,348 bytes
                   0 Dir(s)      15,395,328 bytes free
    Doing 'dir c:\ > z:\justOne.txt' results in two files - until the Teensy is restarted:
    Code:
    Z:\>dir
     Volume in drive Z is Teensy [Ext FLASH] @ MTPdrive(TRIAL)
     Volume Serial Number is 600D-CAFE
    
     Directory of Z:\
    
    05/27/2020  06:22 AM                48 mtpindex.dat
    05/27/2020  06:22 AM             1,416 justOne.txt
    05/27/2020  06:22 AM             1,416 justOne
    05/27/2020  06:22 AM               466 test2
    05/27/2020  06:22 AM               119 test
    05/27/2020  06:22 AM            12,466 Prior sketches.txt
                   6 File(s)         15,931 bytes
                   0 Dir(s)      15,395,328 bytes free

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,750
    @defragster
    IFAIK, it should be 'No directory' file system on SPIFFS.

  5. #5
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585
    @defragster

    Glad you tested it and it seems to be working for you. As I said the only thing changed from the @WMXZ'z MTP_t4 lib to the MTPspiffs_t41 lib was the storage class in order to support spiffs. Which was fun exercise.

    The default is properly set in : ...\libraries\MTP_t4\src\Storage.h - but that may be for non-SPIFFS
    Little confuse here - what default are you talking about. The defaults I see in Storage.h are for using SDFat which is for MTP_t4?

    Looking at your directory listing it appears you are using a third party driver for MTP: @ MTPdrive(TRIAL). Looks like you are using this: https://mtpdrive.com/features.html. Might be a cool app to invest in if you want to connect your Apple (which I have a problem with) or other smart phone If you are using the windows MTP driver (comes with it) you see something like this:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	7 
Size:	27.4 KB 
ID:	20308
    Notice - no drive mapped to device.

    Not sure why you are seeing double file names in you first directory listing. Haven't see that.

    Have you tried dragging files to and from the Teensy yet?

  6. #6
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,619
    Again looks great I need to play with it!

    It can come in real handy!

  7. #7
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,350
    Quote Originally Posted by mjs513 View Post
    @defragster

    Glad you tested it and it seems to be working for you. As I said the only thing changed from the @WMXZ'z MTP_t4 lib to the MTPspiffs_t41 lib was the storage class in order to support spiffs. Which was fun exercise.

    Little confuse here - what default are you talking about. The defaults I see in Storage.h are for using SDFat which is for MTP_t4?

    Looking at your directory listing it appears you are using a third party driver for MTP: @ MTPdrive(TRIAL). Looks like you are using this: https://mtpdrive.com/features.html. Might be a cool app to invest in if you want to connect your Apple (which I have a problem with) or other smart phone If you are using the windows MTP driver (comes with it) you see something like this:

    ... Notice - no drive mapped to device.

    Not sure why you are seeing double file names in you first directory listing. Haven't see that.

    Have you tried dragging files to and from the Teensy yet?
    YES - it worked.

    ... I made note of storage.h because it was noted on 'some' github - but was not in the same library as 'edit' line above it - of course with 4 or 8 associated libs - following the install path and knwowing what did what was a bit tenuous

    The initial test was as shown in p#5 with no drive letter. Yes, a file was dragged over and opened with notepad.

    It was boring without a drive letter to CmdLine add/create files - so THEN the MTPdrive was run that exposed the Teensy as "Z:".

    So the double 'dir' of files an issue with [Win ... MTPdrive ... Teensy] as a unit somewhere. I'd have to revisit the other MTP thread - seems that is the same I saw there ... 4 months back

    >> Jan 2020 ... MTP-Responder-Contribution

    Some dupe there - but unique sizes? Above p#3 both have the same size.

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585
    @defragster
    Thanks for explaining got confused reading it with only one cup of coffee in me

    Think the dups are with using MTPdrive because I haven't run into that issue with testing just with windows. It is possible that MTPdrive is looking for some other MTP id set - just guessing. As for the Serial Number that's actually a hardcoded into the MTP class for both the SPIFFS or the SDFat version. Wonder if we could use the Teensy S/N - just have to figure out how to get it - any ideas?

  9. #9
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585
    Quote Originally Posted by KurtE View Post
    Again looks great I need to play with it!

    It can come in real handy!
    Thanks @KurtE. At least for now there is someway to transfer files from the Flash. Have to come up with a real-world example.

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,350
    Quote Originally Posted by mjs513 View Post
    Thanks @KurtE. At least for now there is someway to transfer files from the Flash. Have to come up with a real-world example.
    Yeah - missed the best point - Files can come and go from Flash easily!

Posting Permissions

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