0

I am using stm32H753xx and Cube FatFs library. After our e-MMC has been soldered to our board, I want to bring-up.

My startup codes is here:

    res = f_mount(&fat_fs, "0:", 0);
if (res != FR_OK) {
    res = f_mkfs("", FM_ANY, 0, work, sizeof(work));
    if (res != FR_OK) {
        while(1) {
            LOGGER_REPORT(FORMAT_REQUEST_FAILED);
            vTaskDelay(pdMS_TO_TICKS(1000));
        }
    }
    res = f_mount(&fat_fs, "0:", 0);
    if (res != FR_OK) {
        while(1) {
            LOGGER_REPORT(FORMATTED_BUT_NOT_MOUNTED);
            vTaskDelay(pdMS_TO_TICKS(1000));
        }
    }
}

I generally expect an error at mounting phase if bringing-up of a memory device is very first time and this implies why I made my software branch to f_mkfs functions if f_mount fails. But f_mount is returning FR_OK and software is skipping here.

Afterwards, I am doing some api calls to detect latest directory in the root and to create new one by giving a name in way that would be latest+1. ( latest is like ./70/ new one ./71/ anyway) There are some api calls here f_opendir, f_readdir, f_closedir respectively and all of them returns succesfully but, whenever I want to create new dir by calling fs_mkdir, it returns FR_NO_FILESYTEM. If I call f_mkfs after f_mount above, a FAT is creating and software works but I can not call f_mkfs ile that and could not figure it out where I have to put this code to make it run only once at very initial bring-up of e-MMC.

0 Answers0