MTP file size limits.

Can you give me the exact copy of mtp-test-integrityV2.ino used? This program has 20 optional defines...

Would also really help to know which flash chips were used. I can try things, but would appreciate a head start to get close to the combination you tested.
 
I formatted a USB stick with 2 partitions, and so far I can't reproduce the problem. It seems to work fine. Here's a quick video demo, so you can see what I'm seeing.

 
Can you give me the exact copy of mtp-test-integrityV2.ino used? This program has 20 optional defines...

Would also really help to know which flash chips were used. I can try things, but would appreciate a head start to get close to the combination you tested.
Sorry for the delay Paul but was shut down last night.

The memboard that you gave us has the following chips on it:
Rich (BB code):
40001 name:sflash5 fs:2000d3ec pn:(4a-0)W25Q512JV*M (DTR)
store:4 storage:50001 name:sflash6 fs:2000d4c8 pn:(4a-1)W25Q512JV*Q
store:5 storage:60001 name:WINBOND1G fs:2000a620 pn:(5-0)W25N01GVZEIG
store:6 storage:70001 name:WINBOND2G fs:2000a714 pn:(5-1)W25N02KVZEIR

uses pins 3, 4 , 5 and 6.

The sketch (note bumped up version number) is attached.
1731067283964.jpeg


Win 11 explorer
1731067366994.png


Tried something this morning out of curiosity. In the serial monitor I selected the first usbdrive by doing a 27 and then did a directory(l) and it did see the usb stick
 

Attachments

  • mtp-test-integrityV3-241108a.zip
    10.9 KB · Views: 15
I formatted a USB stick with 2 partitions, and so far I can't reproduce the problem. It seems to work fine. Here's a quick video demo, so you can see what I'm seeing.
EDIT:
Nothing attached to hub:
1731070013674.png


Partitioned drive now attached (yes I can remove and replace no issue)
1731070095045.png


Attaching a 8GB Microcenter USB Stick shows no change (same image as above). This is a single partitioned drive.

Removing all USB sticks and then inserting 8GB USB stick:
1731070261463.png

inserting single partitioned 128gb drive:
1731070321780.png

now inserting the dual partition usb stick:

1731070409659.png


shows no change. I did power the hub just in case.

Now funny thing is that it is registering because I can do a directory listing from the menu after selecting the drive. Seems like for some reason it is not showing in win explorer so something is off. Suppose I can try on win 10 machine

UPDATE: Tried it on a win 7 machine and seeing the same thing in explorer.
 
Last edited:
I committed a fix for the SD card detection issue from msg #53 starting at 1:27 in the video.


This turned out to be 2 separate issues, but they could only strike in combination if SD.mediaPresent() gets called quickly after SD.begin() returns false.

The main problem indeed had a comment in the code (I believe from @KurtE "bugbug:: if it fails and builtin may need to start pinMode again..."). Indeed that is true, calling sdfs.restart() reconfigures the pins and the DAT3 pin needs to be put back to INPUT_PULLDOWN mode if it can't restart the SD card, otherwise we'll get stuck never trying again.

But sdfs.restart() always succeeds when the card really is present, so if DAT3 card detection is reliable, that stuck case never occurs. That's where the 2nd problem came in. A delay is needed after pinMode INPUT_PULLDOWN, to give time for the weak pulldown resistor to bring the pin's voltage low. If the calling code has timing where mediaPresent() is called quickly after begin() returns false, the pin can still be at logic high but the card isn't actually present, which triggers that 1st issue and leaves the DAT3 pin forever unable to detect when the card really is present.

By experimentation I found about 700ns delay plus whatever timing the rest of the code had was enough, using Teensy 4.1. I put in 5us delays after each pinMode INPUT_PULLDOWN, for some safety margin for MicroMod or Teensy 4.0 where SDIO gets connected by user-supplied wires.
 
using the following sketch (moded from post #62)
Code:
#include <SD.h>
#include <USBHost_t36.h>
#include <MTP_Teensy.h>

#define CS_PIN BUILTIN_SDCARD

USBHost myusb;
USBHub hub1(myusb);
USBDrive mydrive1(myusb);
USBDrive mydrive2(myusb);
USBDrive mydrive3(myusb);
USBDrive mydrive4(myusb);
USBDrive mydrive5(myusb);
USBFilesystem mydisk1(myusb);
USBFilesystem mydisk2(myusb);
USBFilesystem mydisk3(myusb);
USBFilesystem mydisk4(myusb);
USBFilesystem mydisk5(myusb);

void setup() {
  Serial.begin(9600);
  MTP.begin();
  SD.begin(CS_PIN);
  MTP.addFilesystem(SD, "SD Card");
  myusb.begin();
  MTP.addFilesystem(mydisk1, "USB Disk1");
  MTP.addFilesystem(mydisk2, "USB Disk2");
  MTP.addFilesystem(mydisk3, "USB Disk3");
  MTP.addFilesystem(mydisk4, "USB Disk4");
  MTP.addFilesystem(mydisk5, "USB Disk4");

}

void loop() {
  MTP.loop();
  myusb.Task();
  // do other things here...
  static elapsedMillis msec;
  if (msec > 500) {
    msec = 0;
    Serial.printf("mediaPresent = %s - %s\n",
                  (mydisk1.mediaPresent() ? "Yes" : "No"),
                  (mydisk2.mediaPresent() ? "Yes" : "No"),
                  (mydisk3.mediaPresent() ? "Yes" : "No"),
                  (mydisk4.mediaPresent() ? "Yes" : "No"),
                  (mydisk5.mediaPresent() ? "Yes" : "No"));
  }
}

It is showing all drives:
1731082115197.png

and removing and replacing usb drives work no issue.
 
Any chance I could talk you into trying the 4 LittleFS volumes with this simple program?

I found a bag of leftover 4-chip memory PCBs. Will solder chips to one of them this weekend. I have plenty of NOR flash chips, and I found several W25N01GVZEIG NAND flash chips.

Sadly, I found an empty bag that long ago had those W25N02KVZEIR chips. They may have been early samples from Winbond before this chip was at distributors. Mouser has plenty now. Ordered more just now, but will probably be a week until they arrive. Can you try without using the W25N02KV chip?
 
Any chance I could talk you into trying the 4 LittleFS volumes with this simple program?
1731105288772.png


Its picking all usb drives up but all the flash/nand disks are showing 0 for space used etc. Not sure why yet.

Code:
#include <SD.h>
#include <USBHost_t36.h>
#include <MTP_Teensy.h>
#include <LittleFS.h>

#define CS_PIN BUILTIN_SDCARD

USBHost myusb;
USBHub hub1(myusb);
USBDrive mydrive1(myusb);
USBDrive mydrive2(myusb);
USBDrive mydrive3(myusb);
USBDrive mydrive4(myusb);
USBDrive mydrive5(myusb);
USBFilesystem mydisk1(myusb);
USBFilesystem mydisk2(myusb);
USBFilesystem mydisk3(myusb);
USBFilesystem mydisk4(myusb);
USBFilesystem mydisk5(myusb);

LittleFS_SPIFlash   sFlash3; 
LittleFS_SPIFlash   sFlash4; 
LittleFS_SPINAND    sNand5;
LittleFS_SPINAND    sNand6;

void setup() {
  Serial.begin(9600);
  MTP.begin();
  SD.begin(CS_PIN);
  MTP.addFilesystem(SD, "SD Card");
  myusb.begin();
  MTP.addFilesystem(mydisk1, "USB Disk1");
  MTP.addFilesystem(mydisk2, "USB Disk2");
  MTP.addFilesystem(mydisk3, "USB Disk3");
  MTP.addFilesystem(mydisk4, "USB Disk4");
  MTP.addFilesystem(mydisk5, "USB Disk5");

  //Memboard configuration
   sFlash3.begin(3, SPI);
   MTP.addFilesystem(sFlash3, "sflash3");
   sFlash4.begin(4, SPI);
   MTP.addFilesystem(sFlash4, "sflash4");
   sNand5.begin(5, SPI);
   MTP.addFilesystem(sNand5, "sNand5");
   sNand5.begin(6, SPI);
   MTP.addFilesystem(sNand6, "sNand6");

  // sets the storage for the index file
  //MTP.useFileSystemIndexFileStore(0);
  Serial.println("\nSetup done");
}

void loop() {
  MTP.loop();
  myusb.Task();
  // do other things here...
  static elapsedMillis msec;
  if (msec > 500) {
    msec = 0;
    Serial.printf("mediaPresent = %s - %s\n",
                  (mydisk1.mediaPresent() ? "Yes" : "No"),
                  (mydisk2.mediaPresent() ? "Yes" : "No"),
                  (mydisk3.mediaPresent() ? "Yes" : "No"),
                  (mydisk4.mediaPresent() ? "Yes" : "No"),
                  (mydisk5.mediaPresent() ? "Yes" : "No"));
  }
}
 
I noticed that there is a sketch in the "Simplified Examples" folder called "Example_6_MTP_USB_SD_EXT4.ino" that used the TeensyEXT4 library. There did not seem to be much interest in it so maybe that sketch should be removed? What do you all think...
 
Good news, I found a leftover memory board with those same 4 chips.

Running the program from msg #86, sure enough I'm seeing the same issue with size and free space.
Thats great - makes life easier.

Total confused on that one since in message #78 its showing the sizes correctly but messed up on the USB.

Also noticed that seems to be a 9 drive limit in displaying windows explorer

Sorry - still waking up
 
I'm confused too. Started looking into this last night, beginning with the 2 NOR flash chips. Looks like Littlefs_SPIFlash isn't detecting them. Haven't looked at mtp-test-integrityV3-241108a yet, but I don't understand how it could be working when this simpler program isn't.
 
I'm confused too. Started looking into this last night, beginning with the 2 NOR flash chips. Looks like Littlefs_SPIFlash isn't detecting them. Haven't looked at mtp-test-integrityV3-241108a yet, but I don't understand how it could be working when this simpler program isn't.
Yeah I agree - was trying to compare last night as well and couldn't figure it out. It should from what I was able to see. I even tried the simple example just with one flash and didn't work either.
 
Please give this sketch a try.

Code:
#include <SD.h>
#include <USBHost_t36.h>
#include <MTP_Teensy.h>
#include <LittleFS.h>

#define CS_PIN BUILTIN_SDCARD

USBHost myusb;
USBHub hub1(myusb);
USBDrive mydrive1(myusb);
USBDrive mydrive2(myusb);
USBDrive mydrive3(myusb);
USBDrive mydrive4(myusb);
USBDrive mydrive5(myusb);
USBFilesystem mydisk1(myusb);
USBFilesystem mydisk2(myusb);
USBFilesystem mydisk3(myusb);
USBFilesystem mydisk4(myusb);
USBFilesystem mydisk5(myusb);

LittleFS_SPINAND    sNand3;
LittleFS_SPINAND    sNand4;
LittleFS_SPIFlash   sFlash5;
LittleFS_SPIFlash   sFlash6;


void setup() {
  Serial.begin(9600);
  MTP.begin();
  SD.begin(CS_PIN);
  MTP.addFilesystem(SD, "SD Card");
  myusb.begin();
  MTP.addFilesystem(mydisk1, "USB Disk1");
  MTP.addFilesystem(mydisk2, "USB Disk2");
  MTP.addFilesystem(mydisk3, "USB Disk3");
  MTP.addFilesystem(mydisk4, "USB Disk4");
  MTP.addFilesystem(mydisk5, "USB Disk5");

  //Memboard configuration
  sNand3.begin(3, SPI);
  MTP.addFilesystem(sNand3, "sNand3");
  sNand4.begin(4, SPI);
  MTP.addFilesystem(sNand4, "sNand4");
  sFlash5.begin(5, SPI);
  MTP.addFilesystem(sFlash5, "sflash5");
  sFlash6.begin(6, SPI);
  MTP.addFilesystem(sFlash6, "sflash6");

  // sets the storage for the index file
  //MTP.useFileSystemIndexFileStore(0);
  Serial.println("\nSetup done");
}

void loop() {
  MTP.loop();
  myusb.Task();
  // do other things here...
  static elapsedMillis msec;
  if (msec > 500) {
    msec = 0;
    Serial.printf("mediaPresent = %s %s %s %s %s\n",
                  (mydisk1.mediaPresent() ? "Yes" : "No "),
                  (mydisk2.mediaPresent() ? "Yes" : "No "),
                  (mydisk3.mediaPresent() ? "Yes" : "No "),
                  (mydisk4.mediaPresent() ? "Yes" : "No "),
                  (mydisk5.mediaPresent() ? "Yes" : "No "));
  }
}

On that memory board, at least the one I have here, the 2 NAND flash chips have CS pins connected to pins 3 and 4, and the 2 NOR flash chips have CS pins connected to pins 5 and 6.

The sketch in msg #86 is trying to use NOR flash on pins 3 and 4 which have NAND flash, and trying to use NAND flash on pins 5 and 6 which have NOR flash. It's also calling begin() twice on sNand5, but not at all on sNand6.

We're missing mediaPresent() in LittleFS, which causes uninitialized hardware to show up but of course it can't work. I'll fix this momentarily...
 
Last edited:
On that memory board, at least the one I have here, the 2 NAND flash chips have CS pins connected to pins 3 and 4, and the 2 NOR flash chips have CS pins connected to pins 5 and 6.

The sketch in msg #86 is trying to use NOR flash on pins 3 and 4 which have NAND flash, and trying to use NAND flash on pins 5 and 6 which have NOR flash.
Yep that got it - completely missed that. Thought it was the other way around should have know.

Right now trying to get a couple of Bosch sensors working with the Teensy.

1731185275427.png
 
Last edited:
I forgot until just now that we have LittleFS_SPI which automatically tries NOR, NAND and FRAM, and also LittleFS_QSPI for Teensy 4.1's QSPI pads.

Maybe we should publish example programs with the instances like this?

Code:
LittleFS_SPI   sNand3;
LittleFS_SPI   sNand4;
LittleFS_SPI   sFlash5;
LittleFS_SPI   sFlash6;

Large code size, but will automatically work with any type of chip we support.
 
Morning - still working on coffee.

I forgot until just now that we have LittleFS_SPI which automatically tries NOR, NAND and FRAM, and also LittleFS_QSPI for Teensy 4.1's QSPI pads.
You know don't think we ever realized that we could do that. So gave it a try and seems to work no problem.
1731238906446.png


Large code size, but will automatically work with any type of chip we support.
Looked at the change in code size and doesn't appear to be much difference.

Using LittleFS_SPI for NAND and flash
Code:
Memory Usage on Teensy MicroMod:
  FLASH: code:151472, data:14176, headers:8428   free for files:16340996
   RAM1: variables:40000, code:145944, padding:17896   free for local variables:320448
   RAM2: variables:28800  free for malloc/new:495488

versus using individual classes
Code:
Memory Usage on Teensy MicroMod:
  FLASH: code:151520, data:14176, headers:8380   free for files:16340996
   RAM1: variables:38080, code:145992, padding:17848   free for local variables:322368
   RAM2: variables:28800  free for malloc/new:495488

Maybe we should publish example programs with the instances like this?
Think we would be adding a ton more examples if we did that. We could add a note to the existing examples when you get done moding MTP
 
You know don't think we ever realized that we could do that. So gave it a try and seems to work no problem.
That's what happens when there is little or no documentation.
 
Back
Top