Ok this is it. Here is a working version of LWext4 for the GIGA R1. It is by far incomplete but covers most basic FATFileSystem functions except formatting.
It can be found here:
GIGAEXT4V1
You will also need my version of:
Arduino_USBHostMbed5
Lastly you will probably need The LibPrintf Library which can be installed with the Arduino library manager.
One POSIX function that does not work is "access()" which needs the header file "unistd.h". That header file conflicts with the sleep() function.
See error below:
from /tmp/arduino_build_104370/sketch/DirectoryDemo.ino.cpp:1:
/home/wwatson/.arduino15/packages/arduino/tools/arm-none-eabi-gcc/7-2017q4/arm-none-eabi/include/sys/unistd.h:209:10: error: conflicting declaration of C function 'unsigned int sleep(unsigned int)'
unsigned _EXFUN(sleep, (unsigned int __seconds ));
^
In file included from /home/wwatson/.arduino15/packages/arduino/hardware/mbed_giga/4.0.10/cores/arduino/mbed/drivers/include/drivers/HighResClock.h:22:0,
from /home/wwatson/.arduino15/packages/arduino/hardware/mbed_giga/4.0.10/cores/arduino/mbed/mbed.h:82,
from /home/wwatson/.arduino15/packages/arduino/hardware/mbed_giga/4.0.10/cores/arduino/mbed.h:8,
from /home/wwatson/Arduino/libraries/Arduino_USBHostMbed5/src/USBHost/USBHostTypes.h:20,
from /home/wwatson/Arduino/libraries/Arduino_USBHostMbed5/src/USBHostHub/USBHostHub.h:24,
from /home/wwatson/Arduino/libraries/Arduino_USBHostMbed5/src/Arduino_USBHostMbed5.h:2,
from /home/wwatson/Arduino/libraries/GIGAEXT4V1/src/ext4IOutility.h:25,
from /home/wwatson/Arduino/libraries/GIGAEXT4V1/examples/DirectoryDemo/DirectoryDemo.ino:9:
/home/wwatson/.arduino15/packages/arduino/hardware/mbed_giga/4.0.10/cores/arduino/mbed/platform/include/platform/mbed_power_mgmt.h:195:20: note: previous declaration 'void sleep()'
static inline void sleep(void)
^~~~~
Using library GIGAEXT4V1 at version 0.0.1 in folder: /home/wwatson/Arduino/libraries/GIGAEXT4V1
Using library Arduino_USBHostMbed5 at version 0.3.1 in folder: /home/wwatson/Arduino/libraries/Arduino_USBHostMbed5
Using library LibPrintf at version 1.2.13 in folder: /home/wwatson/Arduino/libraries/LibPrintf
exit status 1
Error compiling for board Arduino Giga R1.
I had to create an exists() function to accomplish the same results as th accesss() function but just checking for a files existence only. That is just stating the file in the exists() function and returning true if it does or false if it does not.
There are three main files in the src directory with there header files:
- GIGAext4FS.cpp/.h - This holds the GIGAext4 class methods that interface to LWext4 which is in the "ext4" subdirectory.
- EXT4FileSystem.cpp/.h - This is an adapted version of the FATFileSystem that accesses the GIGAext4 class.
- ext4IOutility.cpp/.h - These are overhead utility functions for doing things like mounting and umounting logical drives etc...
The ext4IOUtility files are just meant to be examples of accessing FAT32 and ext4 filesystems together or separately. The directory listing functions support relative paths and wildcards. Also, have not added time and date stamp functionality yet because I have not played with the GIGA's RTC system yet but that capability is there in ext4.
Accessing a logical drive is done by supplying a mandatory partition name to the beginning of a file or directory path name.
where:
// Partition device names.
const char mpID[TOTAL_LD][7] =
{ "/sda1/", // Partition 1 on ext4 USB drive.
"/sda2/", // Partition 2 on ext4 USB drive.
"/sda3/", // Partition 3 on ext4 USB drive.
"/sda4/", // Partition 4 on ext4 USB drive.
"/fat1/", // Partition 1 on FAT32 USB drive.
"/fat2/", // Partition 2 on FAT32 USB drive.
"/fat3/", // Partition 3 on FAT32 USB drive.
"/fat4/" // Partition 4 on FAT32 USB drive.
};
allows for 4 ext4 formatted partitions and 4 FAT32 formatted partitions.
Examples:
/sda2/sstsrc/.c - List all .c files in directory "sstsrc".
/fat1/a/b/../???test. - List all files with a file name that is seven charaters in length with "test" as the last 4 characters in the "a" sub directory.
fp = fopen("/sda4/test.txt","w+"); - Open "test.txt" in root directory of ext4 partition 4.
All file and directory usage must include a mount point ID before the path name.
There is more information it the README.md file of the GIGAEXT4V1 repository.
A WARNING: Not unmounting an ext4 formatted USB device before removing can cause data loss as information is written back to the drive when unmounted.
Here is an example of output from "DirecoryDemo.ino":
GIGA Directory Listing
Initializing GIGAext4FS...
Please wait...
Mounting drive sda Passed: 0
Usage: All path specs must start with a device spec /sda'x'/ or /fat'x'/
where 'x' is a partition number 1 to 4.
Relative path specs and wildcards are supported: "/sda2/sstsrc/*.c",
"/sda2/a/b/../*??*.cpp."
menu:
h) to display this help menu
l) list a directory
q) to umount and quit
Press a key (h, l, q) followed by <CR>: l
Enter a path spec: /sda1/
Directory Listing:
Volume Label: 64GUSBEXT4P1
Full Path: /sda1/
lost+found <DIR>
test.txt 32768000
datalog.bin 72
armaged.wav 56863276
DeffLepardAnimal.wav 43025216
SDTEST1.WAV 16787550
SDTEST2.WAV 16425698
SDTEST3.WAV 13617358
SDTEST4.WAV 17173152
StatusQuoWhateverYouWant.wav 60148386
ThePaperboysMolinos.wav 35638654
ThePaperboysMolinosI'veJustSeenaFace.wav 36380570
WhateverYouWant.wav 8388608
YoureLazyJimmyBarnesJoeBonamassa.wav 102877858
Bytes Total: 15518924800, Bytes Used:788922368
Bytes Free: 14730002432
Press a key (h, l, q) followed by <CR>: l
Enter a path spec: /sda3/
Directory Listing:
Volume Label: 64GUSBEXT4P3
Full Path: /sda3/
lost+found <DIR>
Bytes Total: 15518924800, Bytes Used:348807168
Bytes Free: 15170117632
Press a key (h, l, q) followed by <CR>: q
ext4 partition 0 successfully unmounted...
ext4 partition 1 successfully unmounted...
ext4 partition 2 successfully unmounted...
ext4 partition 3 successfully unmounted...
finished...
Lastly, performance of USBHostMSD is disappointing. Ext4 formatted devices are faster than FAT32 formatted devices using FatFS.
See this post:
https://forum.arduino.cc/t/lets-discuss-the-arduino-giga-vs-the-teensy-4-1/1209984/8
Not sure if I am going to do much more with this. Depends on it's practical usefulness