Chibios and FATFS SDHC support

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chibios and FATFS SDHC support

Post by Giovanni »

See my second point, I think that is the problem.

The code looks OK but without trying it I cannot be sure. I wish to was able to tell if some code is OK by just looking at it :)

Giovanni
fastlink30
Posts: 42
Joined: Tue Aug 12, 2014 1:25 pm

Re: Chibios and FATFS SDHC support

Post by fastlink30 »

Tectu wrote:
Jeroen3 wrote:I''m at 4e11d82, "Fixed bug #514". (git)

As far as I know that repo state even uses the 'old' FatFS library. The new one is 0.10b.
Personally don't have issues to use SDHC cards. I didn't have issues with them in the past and with the latest master.


~ Tectu


I tried to use the 0.10b (ffrom original site) , but receive some errors during compilation, need 'patched' version? where i found?
or i must do ssomething (not only overwrite the old llibrary)?

Compiling fatfs_diskio.c
Compiling fatfs_syscall.c
Compiling ff.c
c:/ChibiStudio/chibios/os/various/fatfs_bindings/fatfs_diskio.c:111:9: error: conflicting types for 'disk_read'
In file included from c:/ChibiStudio/chibios/os/various/fatfs_bindings/fatfs_diskio.c:11:0:
c:/ChibiStudio/chibios/ext/fatfs/src/diskio.h:37:9: note: previous declaration of 'disk_read' was here
c:/ChibiStudio/chibios/os/various/fatfs_bindings/fatfs_diskio.c:152:9: error: conflicting types for 'disk_write'
In file included from c:/ChibiStudio/chibios/os/various/fatfs_bindings/fatfs_diskio.c:11:0:
c:/ChibiStudio/chibios/ext/fatfs/src/diskio.h:38:9: note: previous declaration of 'disk_write' was here
make: *** [build/obj/fatfs_diskio.o] Error 1
make: *** Waiting for unfinished jobs....
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chibios and FATFS SDHC support

Post by Giovanni »

Please try using FatFS provided with ChibiOS, there could be patches.

Giovanni
fastlink30
Posts: 42
Joined: Tue Aug 12, 2014 1:25 pm

Re: Chibios and FATFS SDHC support

Post by fastlink30 »

with the fatfs-0.9-patched.zip (in the etc\ directory) not have problem with compilation, but thinked can use the 0.10b from the orginal site
but still have problem with mmcard, anyway today i have time to look what happen

thanks
Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: Chibios and FATFS SDHC support

Post by Jeroen3 »

I've got more card features running. And I wanted to ask if ~220 KB/s of file copy operation is reasonable?
Running with 3 open files. Copy A->B with files of 1 to 10 MB. And a continuous data logging file in the background.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chibios and FATFS SDHC support

Post by Giovanni »

Consider that FatFS is done to be small not necessarily fast, it lacks any kind of buffering so the library continuously reads/writes FAT blocks. It is unlikely that you will reach the transfer rate of the naked SPI port.

Giovanni
Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: Chibios and FATFS SDHC support

Post by Jeroen3 »

Correct, It doesn't have buffering. That would be waste of the already limited resources.
I don't need it to be ultra fast, I was just wondering if this is a reasonable speed. Seems like it is.

It also seems like the card itself is the limiting factor since the chRegistry says copying 10 MB uses 1 unit of cpu, 1 ms, of the copying thread.
Or everything is running in interrupt mode.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chibios and FATFS SDHC support

Post by Giovanni »

Everything runs on DMA and IRQs so very little CPU time is involed.

Giovanni
Jeroen3
Posts: 35
Joined: Wed Apr 02, 2014 10:14 am

Re: Chibios and FATFS SDHC support

Post by Jeroen3 »

Meanwhile, I can confirm writing and reading from an 8GB SanDisk SDHC card works*.
However, getting metadata doesn't. It won't read the filesize correctly anymore. It does with a FILINFO.
It seems after f_open, the fsize isn't being set correctly if the file is beyond 4 GB.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Chibios and FATFS SDHC support

Post by Giovanni »

That is probably a FatFS limitation.

Giovanni
Post Reply