Problem with Write SD card

Moderators:, violet, salmanfarisvp

Post Reply
Posts: 1
Joined: Tue Dec 01, 2015 1:23 pm

Problem with Write SD card

Post by tangmubulibo1 » Tue Dec 01, 2015 1:56 pm

When I use the API "Lfile.write()" to write a 512 bytes command to the interface file which stored on SD card, the COS(Chip OS) of SD card can only received the first 128 bytes.
I read the API, as follows, and then I got the reason:

Code: Select all

#define LS_WRITE_BUF_SIZE 128

size_t LFile::write(uint8_t v)
    if(!_fd || _isDir)
        return 0;

    _buf[_bufPos++] = v;
    if(_bufPos == LS_WRITE_BUF_SIZE)
    return 1;
The function flush the data after store 128 bytes in a buffer, I think the flush time takes too long, so that the COS regard it as the writing has been finshed. I try to change the macro to 512, but the function no longer work.

I do not know whether the size of 128 byte is determined by hardware or not? Is there some ways to write 512 bytes together without pause?

Posts: 168
Joined: Tue Jan 25, 2011 11:16 am
Are you a staff member of seeedstudio?: no
Which products/projects are your favorite?: Seeeduino Film,Motion Frame,UartSbee

Re: Problem with Write SD card

Post by viswa » Mon Dec 07, 2015 12:23 pm


The SDK (i.e API) is developed by MediaTek. Advanced Technical support on API/ SDK is available at MediaTek LinkIt One Forums.

Could you please use the following example as a reference to implement writing data to SD Card: SD example.

Thanks and Warm Regards.

Post Reply