You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The read/write driver sometimes passes an unaligned reference, which causes DMA to write data at an offset.
In FS_FAT_FileRd function if reading from other than the beginning of sector is required:
if (sec_cur_pos != 0u) {
FSVol_RdLockedEx
...
p_dest_08 += size_rd; //the pointer may not be aligned!
...
while (size_rem > 0u) //and if a whole sector should be read next
...
FSVol_RdLockedEx( p_file->VolPtr, /* Rd full sec's. */
(void *)p_dest_08 //then we transmit non-aligned address for reading
If we read/write sectors using DMA then data will be read at an offset.
I worked around it this way: in SD card driver I check if the address is aligned, if it is - pass it to DMA as is, otherwise - use a temporary buffer of one section size. then I just copy data from it to my non-aligned buffer
The same thing happens when you write
This may not be a file system problem but a driver problem.
And maybe you have a better solution
The text was updated successfully, but these errors were encountered:
Your workaround is how we resolve this as well.
Your BSP should have a properly aligned buffer for use when the FS driver passes a misaligned pointer.
The buffer size should be the sector size multiplied by an integer, BLK_CNT_MAX, which you define.
You should also return BLK_CNT_MAX from the FSDev_SD_Card_BSP_GetBlkCntMax() function in your BSP, so that the FS limits the number of blocks it will read at any one time to what your aligned buffer can hold.
If the pointer from the FS driver is alread aligned you can simply have the DMA read directly into it.
The read/write driver sometimes passes an unaligned reference, which causes DMA to write data at an offset.
In FS_FAT_FileRd function if reading from other than the beginning of sector is required:
If we read/write sectors using DMA then data will be read at an offset.
I worked around it this way: in SD card driver I check if the address is aligned, if it is - pass it to DMA as is, otherwise - use a temporary buffer of one section size. then I just copy data from it to my non-aligned buffer
The same thing happens when you write
This may not be a file system problem but a driver problem.
And maybe you have a better solution
The text was updated successfully, but these errors were encountered: