Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

problem with keil file system middleware

hi to all,
i am working on project that in it i need to read and write to micro-sd-card in unit of sector, for done that i decide use keil file system middleware and then use fs_ioc_read_sector and fs_ioc_write_sector function that provided by keil.
after following steps that keil provided(good job keil) now i can successfully read sector from sd card with fs_ioc_read_sector function, but when i use fs_ioc_write_sector function to write a sector to sd card it return an fs_error and it dose not write to sd card.
my mcu is lpc1788, i use 4-bit mci bus.
now can any one help me to find a solution for that??
my code is as below:

fsStatus stat;

uint32_t param_status;
if(finit ("M0:") != fsOK)
{
     return -1;
}

drv_id = fs_ioc_get_id ("M0:");

if(drv_id < 0U)
        return -1;

param_status = 0U;                    // Parameter for function call is 0
                                       // Initialize media
if (fs_ioc_device_ctrl (drv_id, fsDevCtrlCodeControlMedia, ¶m_status) != fsOK) {
    return -1;                             // Exit if failed
}

if (fs_ioc_lock (drv_id)) {           // Lock media for USB usage
    return -1;                             // Exit if failed
}

stat = fs_ioc_write_sector (drv_id, 1, buf, 1);

if (stat != fsOK) {                  // = fs_error
    return -1;
}
fs_ioc_unlock(drv_id);
return 1;