Skip to content

non-aligned pointer to read/write buffer  #10

Open
@SomeMaker

Description

@SomeMaker

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions