Writing to USB Drive hangs when buffer declared EXTMEM

deppata

New member
Hi,

I am using the Teensyduino Beta 1.57 on a great, full featured Teensy 4.1

I am implementing a file transfer as soon as a pen drive ist inserted to the USB Host. It works, slowly but stable.

Declaration section of the Code:

Code:
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBDrive USBDrive1(myusb);
USBDrive USBDrive2(myusb);
USBFilesystem USBFS(myusb);

//create a buffer for file transfer 

char CopyBuffer[65536]; // works

// EXTMEM char CopyBuffer[65536] // does not work

In the code i iterate through a folder on local SD to copy all containing Files to USB. Source and Destination have identical names on both drives.

Code:
		File newFile = USBFS.open(TransferFile.c_str(), FILE_WRITE);
		File oldFile = SD.open(TransferFile.c_str(), FILE_READ);
		
// quite slow

		int i;
		while (oldFile.available())
		{
			digitalWrite(LEDPinYellow, HIGH);
			digitalWrite(LEDPinGreen, LOW);

			i = oldFile.readBytes(CopyBuffer, 65536); 

			digitalWrite(LEDPinYellow, LOW);
			digitalWrite(LEDPinGreen, HIGH);

			newFile.write(CopyBuffer, i);

		}
		digitalWrite(LEDPinYellow, LOW);
		digitalWrite(LEDPinGreen, LOW);

		oldFile.close();
		newFile.close();


When I declare the Copy Buffer with EXTMEM, Reading from SD works, but the write Operation to USB Pen Drive hangs.
 
Back
Top