Po Ting
Well-known member
Any chance this can be done on a 3.2 with external SD?
Yes it already could.
However SDIO interface is not avail in teensy 3.2, so it will transfer file at a significant slower rate.
Any chance this can be done on a 3.2 with external SD?
@ WMXZ
https://github.com/WMXZ-EU/MTP_t4
Missing preprocessor directives for Teensy 3.0/3.1/3.2/3.5 in MTP.h and MTP.cpp files.
In MTP.cpp: about LINE #519 #if defined(__MK66FX1M0__)
Replace with: #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
in MTP.h: about LINE #61 #if defined(__MK66FX1M0__)
Replace with: #if defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MK64FX512__) || defined(__MK66FX1M0__)
This is of course not tested on Teensy 3.0/3.1/3.2/3.5 but no compilation error.
// MTP object handles should not change or be re-used during a session.
// This would be easy if we could just have a list of all files in memory.
// Since our RAM is limited, we'll keep the index in a file instead.
void MTPStorage_SD::GenerateIndex()
void CMRB(void){
LEDON
usb_init(); // shuts down USB if already started, then restarts
delay(200);
Serial.begin(9600);
delay(200);
LEDOFF
//StartMTP();
usb_mtp_configure();
if (!Storage_init(&SD.sdfs)) {
Serial.println("Could not initialize MTP Storage!");
}
Serial.println("USB disconnected and reconnected to force MTP update");
}
// Changed Storage_init to accept pointer to initialized SdFs file system
bool Storage_init(SdFs *sptr) {
#if DO_DEBUG>0
Serial.println("Using SdFs");
#endif
#if USE_SDIO==0
SPI.setMOSI(SD_MOSI);
SPI.setMISO(SD_MISO);
SPI.setSCK(SD_SCK);
#endif
if (sptr == NULL) {// If NULL pointer initialize FS
if (!sd.begin(SD_CONFIG)) {
return false;
//sd.errorHalt("sd.begin failed");
} else {
sdptr = &sd;
FsDateTime::callback = dateTime;
return true;
}
} else {// we received a pointer to an intialized SD file system
sdptr = sptr;
return true;
}
// Set Time callback already done when File system initialized
}
@WMXZ
Was playing with MPT Responder (SD Card) to test rename functionality because I was getting some strange results with MTP rename. Specially it lets me rename one file without a problem but then if I go to rename a second file it looses the file name completely and the icon changes to a window icon with what looks like a drive icon? Is this a know issue.
@mjs513, It turns out that sd.rename is not working as expected (returns false). Have to do some debugging
OK,
@mjs513, was busy last two days debugging the code. Was a little bit intensive.
There was nothing wrong with sd.rename
but found that reading commands from PC got corrupted.
Also managing index file seemed to be corrupting.
At the moment I got rename working multiple times and move (within single storage seems also to work)
I updated the github, but I expect some strange actions to screw up.
Unfortunately, I have to report a problem (win10 T4.1)
If I copy a sequence of files from a directory to top-level directory using CTL-X and CTL-V and try to copy multiple files back again, system blocks (no USB commands from PC are shown)
First copy works (verified)
Work around: if MTP window blocks (on file move) use device manager to disable and enable Teensy portable device.
Somehow I screwed up the logic. (moving to root corrupted the object list)Considering everything else I personally don't see it as a too big of a problem![]()
Somehow I screwed up the logic. (moving to root corrupted the object list)
I think I got it now working using an easier logic.
So far moving between different uSD cards is not supported, as I had no time testing it.
Github updated.
@mjs513,
I added code to move files cross sd cards.
I seems to work with single files, but not with multiple files (in the latter case the is most likely some issues with the MTP protocol)
When copying multiple files cross sd cards, the first one is copied and the the MTP communication stops
D:\Users\Merli\Documents\Arduino\libraries\MTP_t4_littlefs\src/MTP_RAM.h:47:42: error: expected ')' before '*' token
explicit MTPD_RAM(MTPStorageInterface2 *storage2;) : storage2_(storage2) {}
Curious did you test moving one at time. Does it work with copying one and then another - not a show stopper for me.
Yes I did one at a time and it worked, but marking multiple files and then a doing a move failed.
Anyhow, moving files between storages is not the objective of my application. Will see how libmtp does it (unfortunately is not easy to revengineer)
To be honest wasn't looking for you to do anything more was just curious since I don't really have a setup using multiple SD cards right now to test.
SPIFlash: begin(CS#, SPI Port)
RAM: begin(buffer, sizeof(buffer)
QSPI: begin()