I am using fatfs on stm32 and I want to find the address of first sector of a file which is opened using f_open function. Thus I can use that sector address to access the file as a address offset using low level DMA methods available. How can I get the raw address of the file on disk?
Asked
Active
Viewed 828 times
1 Answers
1
In Chan's FatFS you can known the file starts cluster, it's in fp->sclust
variable. You can know cluster size with this expression:clusterSize = fp->fs->csize * SS(fp->fs);
and you can also need the funcion clust2sect(fp->fs, fp->clust)
.
You can watch the implementation of Diskio_drvTypeDef.disk_read
to see how to convert to adress.

JMA
- 494
- 2
- 13
-
Actually the files start cluster is in `fp->obj.sclust` as long as you haven't read from that file (otherwise its in `fp->clust`) – crizztus Jan 09 '18 at 16:20