Skip to content

Fatfs exfat AOS project pull request#1

Open
NickF19 wants to merge 46 commits intomasterfrom
fatfs-exfat
Open

Fatfs exfat AOS project pull request#1
NickF19 wants to merge 46 commits intomasterfrom
fatfs-exfat

Conversation

@NickF19
Copy link
Copy Markdown
Owner

@NickF19 NickF19 commented Sep 9, 2024

Pull request of the AOS project for the Miosix exfat project. This is a pull request within the fork, since miosix repository is a mirror and patches will be applied.

Moving the fatfs files to filesystem/fatfs to then do the porting to R0.15 and use it for both FAT32 and exFAT.
Updated the ffconf.h to R0.15 patch 3 of fatfs, keeping the modification done for Miosix.
Updated the ff.h defines and structures to support the R0.15 ff.cpp and overall changes.
As the old modifications, the integer typedefs are moved in integers.h
ff.h: Updating fn as the pointer to sfn.
ff.cpp: Adding and changing defines for flags and adding used macros by new porting of fatfs
ff.cpp: udating the Module private work area, Module private fuctions, locks, synchronize and FAT access sections.
FATFS: to map the intrusive_ref_ptr by Miosix instead of the BYTE for the drives.
DIR: Now instead of directly having the FATFS as attribute has the FFOBJID struct as fatfs-R.015 uses
Addedand changed some define, to map the usage by fatfs-R.015, as the naming changes for FAT32. Added also GPT and table related defines used later on
BUF related macros and defines changes to map to the usage of fs and not dobj.
Also some minor changes
Chec_crc: porting and modifications
Put_utf: For now maintaining the put_utf function, in future will consider using unicode.h features
lock functions porting to R0.15
Porting to R0.15 of others directory related and handling functions.
Porting and changes to such functions for fatfs R.015 porting.
TODO: find_volume will require changes since it is mostly used with the FRESULT return value signature
Porting to R.015 of the f_* functions up to f_truncate.
Porting to R0.15 and changes to the remaining  f_* functions
Last part of code involved by the R.015 porting.
New commits to complete the remained make errors, signatures changes and others eventual changes not already applied in this commit stream up to now.
Now, the DIR_ objects includes the FFOBJID and not directly the FATFS* fs pointer
Signature changes: Returned to use the FATFS* fs parameter in some changed functions;

enq_lock: Added a DIR_* parameter to avoid using the *FatFs global variable;

find_volume: Changed to return a FIND_RETURN data type, used since the f_mkfs function relies on the fmt value while the others rely on the FRESULT. To avoid adding redundant if/else to map the fmt to a possible FRESULT, a the FIND_RETURN structure had been created instead. Code has been changed accordingly simply by select the .res or .fmt field.

f_mkfs: Changed the signature in accordane to the usage of the FATFS* fs parameter.

Others: Many changes to remove compilation errors for the ff.cpp file.
f_chgdrive: No more in use, since multi partition and multi volume will in future be managed by Miosix and not directly by fatfs
disk_status and disk_initialize is now not used anymore and not consider, following the old changes due to not using fatfs disk status and initialize functionality.
ff.h: Removed a replicated define in ff.h
ff.cpp: Removed some unused variables and added missing find_volume.
find_volume: The return for fmt == 2 was wrongly returning FR_NO_FILESYSTEM, and in case of part == 0 the function should return fmt.
Also changed some things about the return with fmt == 3, mapping to FR_NO_FILESYSTEM error.
f_read and f_write where not updated to the R0.15 fatfs version, now they are updated and changed accordingly to Miosix
Also create_name was not updated to the R0.15 version and now it is. Also it has the correct usage of the Miosix functionalities.
Re-adding the changes lost during rebase about the _FS_LOCK.
_FS_LOCK now no more a number. Just defined or not
find_volume now uses partition 0 by default, not requiring passing it as argument.
Fixes: Many fixes due to regression. Now find_volume initializes many things that were initialized by mount_volume (not used since interfere with the mount of the Fat32 partition by fat32).
Also the lfn buffer where pointing to a pending pointer, now fixed.
Still WIP since there are still errors in mounting correctly the Fat32 partition.
The porting introduced other regressions now solved.

fs->drv: Switched from using the fs->pdrv to the fs->drv since this is the one used and initialized correctly in the past by Miosix. Using pdrv made arise a BusFault due to the disk_read and disk_write.

f_mkdir: INIT_BUF was missing. That made also arise a BusFault.

find_volume: Using find_volume instead of mount_volume needs the usage of the initialization code in the find_volume call as old Miosix did in precedence.

NOTE: fmt mount format variable in find_volume has incoherent usages through check_fs and the defined values for the different FAT types. This also was changed using a variable fmtSet. This might need some adjustment since it is confusing and can possibly lead to problems
Minor fixes:
Ordering of some function declaration as find_dir and exfat's checksum.
get_fat now using the FFOBJ instead of FATFS since in exfat cases it needs to change some obj attribute.
Removed a putUtf to fatfs put_utf since it was using TCHAR
Solved a minor issue of #ifdef introduced by moving some EXFAT-oriented functions for correctly compile.
WIP on it since, it needs to return in case of incorrect FAT partition. The find_volume should stop the process if a wrong partition for FAT or exFAT is found.
Class for the directory, file and filesystem.
WIP on it since for now it is just taken from the FAT32 ones.
Now the classes for exFAT and FAT32 check that the filesystem object has the correct partition_type
Two missed functions in the porting, now re-added
Adding exfat.cpp in Makefile
Fixes: Some variables now no more static, return val in get_fattime, using FSIZE_t for the exFAT support
Removed static from some variables.
Checking now at compile time that LBA64 is enabled if EXFAT.
Fixed mounting issue: There was a problem in the trymount done again with exfat mounting, now solved with correct return partition type check

Fixed mkdir: There was duplication of the dir_register which registered multiple times the directory and then corrupted the partition.
There was an issue with the remove_chain which caused to remote the chain for also valid entities within dir_register
Now the fat32 and exfat compilation is done only in case of exfat or fat32 file for the different signatures in ff.cpp
Solved an issue that made all file look like existing because of miscalculated hash over the uninitialized pointer lfnbuf of the FATFS structure
LoopMount had issues with the sclust for path resolution and for the find_volume.
Now solved.

Also fixed how the exfat flag is used during compilation.
Moved _FS_EXFAT flag to miosix_settings for the filesystem offset as 64 or 32bit
Uninitilized LFN in DIR_ directories dj, sdj was causing changes to the mutex of the ExFatFs, therefore making chrash on next operation.
Now the lock functions are now replaced by their shared versions
Implemented lseek64, truncate64 and modified FileBase accordingly.
Issue with the MountpointFs
Added the lseek check in case of MountpointFs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant