Hi,
I am running into an issue getting the FAT32_Format to work on the MIkroBasic Compiler for AVR. I downloaded and installed the package fine. I added a #define AVR line to the example code and changed the MMC chip select line in the code. The directory test works fine and creates the directories and text files just fine on a SD card. But when I un-comment the err = FAT32_format("dev0") line, the compiler gives a 411 327 Incompatible types ("complex type" to "simple type") main.mbas error. If I put less than 2 characters in the "dev0" field, I get a 0 360 Unresolved extern 'FAT32_Dev_SectorCount' __Lib_FAT32_lte.c error. All of the tick marks are present in the Library Manager under FAT32. Can someone help me here with what I may be doing wrong?
Thanks,
Ken
Update: I noticed while looking at the _lib_Fat32_Driver_lte.mbas file in the FAT32 Uses directory that the sub function FAT32_Dev_SectorCount is NOT called out in the declarations above the Implements. Is there a reason for this?
FAT32 format function not compiling
Re: FAT32 format function not compiling
Did you ever figure this out I'm getting the same error with format, makeDir ect....anything that needs a string passed in the FAT32 lib.
Thanks
Doug
Thanks
Doug
Doug
KD5NWK
KD5NWK
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: FAT32 format function not compiling
Hello,
Please take a look at this modified example. This is how you can pass string to functions:
FAT32 Libray example project will be updated as soon as possible.
Best regards.
Please take a look at this modified example. This is how you can pass string to functions:
Code: Select all
dim drive_name as string[4]
main:
drive_name = "dev0"
...
err = FAT32_Init()
err = FAT32_format(@drive_name)
Best regards.
Re: FAT32 format function not compiling
Still get the same sector error using @device_Name
mbasic pro 6.4.0
Doug
mbasic pro 6.4.0
Doug
Doug
KD5NWK
KD5NWK
Re: FAT32 format function not compiling
I also met the same problem.
- dejan.odabasic
- mikroElektronika team
- Posts: 2649
- Joined: 30 Apr 2012 14:20
Re: FAT32 format function not compiling
Hello,
Have you tested the attached example project?
Are you able to compile it without problems?
Best regards.
Have you tested the attached example project?
Are you able to compile it without problems?
Best regards.
Re: FAT32 format function not compiling
Hi
I found the FAT32 Format function disabled as told above (Basic for Arm, latest FAT32 lib), so I reactivated it. It made some problems clear wich I found on this odyssee.
First a big problem on SD Cards:
On a new card I can write as much files and folders I want in every folder or even root.
If I use Format_Fat32, the SD Card looks quite good at first sight, but no more than 126 files and/or directories are allowed on the card (not in folder, on the whole card). Looks like a bug in FAT. This problems occurs in several threads.
If I use Windows formatting, quick or full, the SD card will NOT come back to life, problem stays, so something significant has to be corrupted.
If I use SD Formatter V4.0 from Panasonic/Trendy the SD-Card is restored. This program deletes ALL sectors.
So please check the Format function, I broke the program down to a few lines. Works fine if format is off, is corrupted when formatted before use.
Some corrections to the help file:
If you use Format_FAT32, you have to use a vector instead a string or char variable.
Only Capitals are accepted (This also for MakeDir) or function will not execute
Dim Vol_Name as char[11]
...
Vol_name="ABCDEFGHIJK"
SDerror = FAT32_Format(@Vol_Name)
Best regs
I found the FAT32 Format function disabled as told above (Basic for Arm, latest FAT32 lib), so I reactivated it. It made some problems clear wich I found on this odyssee.
First a big problem on SD Cards:
On a new card I can write as much files and folders I want in every folder or even root.
If I use Format_Fat32, the SD Card looks quite good at first sight, but no more than 126 files and/or directories are allowed on the card (not in folder, on the whole card). Looks like a bug in FAT. This problems occurs in several threads.
If I use Windows formatting, quick or full, the SD card will NOT come back to life, problem stays, so something significant has to be corrupted.
If I use SD Formatter V4.0 from Panasonic/Trendy the SD-Card is restored. This program deletes ALL sectors.
So please check the Format function, I broke the program down to a few lines. Works fine if format is off, is corrupted when formatted before use.
Some corrections to the help file:
If you use Format_FAT32, you have to use a vector instead a string or char variable.
Only Capitals are accepted (This also for MakeDir) or function will not execute
Dim Vol_Name as char[11]
...
Vol_name="ABCDEFGHIJK"
SDerror = FAT32_Format(@Vol_Name)
Best regs
Re: FAT32 format function not compiling
Addition to my last Post
On a correct formatted SD card:
If you write more than 1024 Files in Root directory, the SD Card gets corrupted the same way as above.
If you write mor than 1023 Files in a subfolder, the SD Card stays OK but the complete folder content is gone.
Thats a limitation I guess you can live with but it should be told for it does not comply to FAT 32 rules.
Best regs
Frank
On a correct formatted SD card:
If you write more than 1024 Files in Root directory, the SD Card gets corrupted the same way as above.
If you write mor than 1023 Files in a subfolder, the SD Card stays OK but the complete folder content is gone.
Thats a limitation I guess you can live with but it should be told for it does not comply to FAT 32 rules.
Best regs
Frank
Re: FAT32 format function not compiling
Hello again
It just took me 2 days to figure out the problem:
I monitored the FAT entries and tried to force the errors:
Format function is working properly, ignore above post, accidently worked this way, the problem ist:
Making a new directory and new files when the 4096byte limit (SD 4Gbyte, 8 Sec/Cluster) is reached.
1.) i.e. Format Disk, Windows or FAT32_Format
You are now able to write 128 root directory entries, program goes on hold on
fhandle = FAT32_Open(@File_Name, FILE_WRITE_F32)
no chance to lookup up for error in fhandle, program stuck
SD Card with Hex editor
FAT table has the correct update and references Cluster 2 (root) to Cluster 131 as next root cluster (128Files Cluster3-130), absolutely correct.
All data from Cluster 2 up is lost and set to 0x00, maybe because of stuck open command, I don't know
2.) i.e. Format Disk, Windows or FAT32_Format
FAT32_makeDir(@DIR_name)
FAT32_ChangeDir(@DIR_name)
You are now able to write 126 directory entries, program goes on hold on
fhandle = FAT32_Open(@File_Name, FILE_WRITE_F32), again no chance to lookup up for error in fhandle, program stuck
SD Card with Hex editor
FAT table has the correct update and references Cluster 3 (New directory) to Cluster 130 as next root cluster (126Files Cluster4-129), absolutely correct.
Root still intact, Sub directory lost it's dot and dotdot entry and all data from Cluster 3 (new Directory) up is lost and set to 0x00
3.) Use SD Formatter from http://www.sdcard.org the SD will be formatted with 64 Secs/cluster.
You will get exactly the same behaviour as above when you reach 1024 Files and / or directories > 32kbyte in one folder entry.
This effect only takes place when you are creating files or directories which exceed the limit of the directory cluster. It looks like you are updating the FAT with reference as it should be but do not use the new sector or maybe use a wrong sector for these two commands, maybe also make_swap, have not tested it until now. Fat is working absolutely fine when writing to files, FAT referencing works, clusters correctly addressed.
It would be great if you can release the FAT32_Format, Makedir, Makeswap and File_write commands as .mbas so we have a chance to look this up and maybe change it.
Thanks
It just took me 2 days to figure out the problem:
I monitored the FAT entries and tried to force the errors:
Format function is working properly, ignore above post, accidently worked this way, the problem ist:
Making a new directory and new files when the 4096byte limit (SD 4Gbyte, 8 Sec/Cluster) is reached.
1.) i.e. Format Disk, Windows or FAT32_Format
You are now able to write 128 root directory entries, program goes on hold on
fhandle = FAT32_Open(@File_Name, FILE_WRITE_F32)
no chance to lookup up for error in fhandle, program stuck
SD Card with Hex editor
FAT table has the correct update and references Cluster 2 (root) to Cluster 131 as next root cluster (128Files Cluster3-130), absolutely correct.
All data from Cluster 2 up is lost and set to 0x00, maybe because of stuck open command, I don't know
2.) i.e. Format Disk, Windows or FAT32_Format
FAT32_makeDir(@DIR_name)
FAT32_ChangeDir(@DIR_name)
You are now able to write 126 directory entries, program goes on hold on
fhandle = FAT32_Open(@File_Name, FILE_WRITE_F32), again no chance to lookup up for error in fhandle, program stuck
SD Card with Hex editor
FAT table has the correct update and references Cluster 3 (New directory) to Cluster 130 as next root cluster (126Files Cluster4-129), absolutely correct.
Root still intact, Sub directory lost it's dot and dotdot entry and all data from Cluster 3 (new Directory) up is lost and set to 0x00
3.) Use SD Formatter from http://www.sdcard.org the SD will be formatted with 64 Secs/cluster.
You will get exactly the same behaviour as above when you reach 1024 Files and / or directories > 32kbyte in one folder entry.
This effect only takes place when you are creating files or directories which exceed the limit of the directory cluster. It looks like you are updating the FAT with reference as it should be but do not use the new sector or maybe use a wrong sector for these two commands, maybe also make_swap, have not tested it until now. Fat is working absolutely fine when writing to files, FAT referencing works, clusters correctly addressed.
It would be great if you can release the FAT32_Format, Makedir, Makeswap and File_write commands as .mbas so we have a chance to look this up and maybe change it.
Thanks