@All - I have pushed up the latest working version of TeensyEXT4 and updated the README.md file.
Here:
https://github.com/wwatson4506/TeensyEXT4
A few notes on this library.
1) It is a mix of C and C++. Most of the library was written in C++ so it is riddled with printf() statements. Because of that I needed to do an override of _write().
Code:
extern "C" {
__attribute__((weak))
int _write(int file, char *ptr, int len)
{
int i;
for(i = 0; i < len; i++)
{
usb_serial_putchar(*(ptr+i));
if (*(ptr+i) == '\n')
usb_serial_putchar('\r');
}
usb_serial_flush_output();
return len;
}
2) Need to figure out the best place to put the USBHost declarations. Right now they are in 'usb_bd.cpp' :
Code:
// Setup USBHost_t36 and as many HUB ports as needed.
USBHost myusb;
USBHub hub1(myusb);
USBHub hub2(myusb);
USBHub hub3(myusb);
USBHub hub4(myusb);
// Instances for the number of USB drives you are using.
USBDrive myDrive1(myusb);
USBDrive myDrive2(myusb);
And that requires:
Code:
// TODO: This needs to change.
extern USBHost myusb;
...
myusb.begin();
To be in the sketch. Maybe some advice on this
3) I noticed that the read/write speeds were faster than what I normally see:
Code:
file_test:
rw size: 32768
rw count: 1000
ext4_write: 32768 * 1000 ...
write time: 4375 ms
write speed: 7312 KB/s
ext4_read: 32768 * 1000 ...
read time: 1752 ms
read speed: 18254 KB/s
This was using my slowest 16G thumb drive writing and reading a 32Mb file. Possibly due to the way lwext4 caches reads and writes? Not sure...
4) Tested usage of multiple partitions. lwext4 handles it ok. Just need to make sure each partition has a different mount point name. Let's say '/mp/' and 'mp1' for two partitions. So during mounting, directory and file operations you would use the appropriate mount point.
Mounting the partitions will look like this:
Code:
if (!test_lwext4_mount(&bdevs.partitions[0], bc))
Serial.printf("test_lwext4_mount() Failed\n");
else
Serial.printf("test_lwext4_mount() Passed\n\n");
For first partition. Or:
Code:
if (!test_lwext4_mount(&bdevs.partitions[1], bc))
Serial.printf("test_lwext4_mount() Failed\n");
else
Serial.printf("test_lwext4_mount() Passed\n\n");
For second partition.
Next step is setting up usage of lwext4 on SD cards. There is still a lot of work to be done with this and a lot to learn. I am open to any and all advice/help I can get from the experts
WIP...
Playtime now...