FreeRTOS+FAT SL, SD Card, initialization issue

HI. I want to use SD Card with FAT SL. First, I tested FAT window example project, FATSLandCLIWindows_Simulator. So I understand how it works. So I applied it to my system board(ARM) and checked it. Next, I make a initialization for SD Card, it works fine. They’re in same project. But I don’t know how can I connect them. They’re working independently now.. I want use filesystem functions on my SD Card like dir, write, open, etc… I tried searching and analyzing codes. This post is similar with my situation. https://sourceforge.net/p/freertos/discussion/382005/thread/272eac75/?limit=25#363a ‘ramdrvf.c’ file is only for using ram? If it is true, should I make a ‘SDdrvf.c’ file like ‘ramdrv_f.c’?? I think that it is related with F_DRIVERINIT in Media Driver API. I don’t know how ulDriverparameter is decided. I use FreeRTOS 8.0 and FAT SL 1.0. Please help me using FAT for SD CARD or other memory type except RAM. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

I’ve just reviewed that thread and am not sure what else to add. You can reuse the RAM disk file and structures, and then re-implement the functions that actually perform the reading and writing to make use of your SD card read and write functions. That might be confusing though if you have a structure that says ‘RAM’ with read and write functions that use an SD card driver. I would therefore suggest taking a copy of the RAM disk files, then rename the file name, and the structures used within the file, so they are called something relevant to the SD card. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

I’m sorry. My post was not enough to describe my situation and what I want. I’ll describe my situation and question again.
  1. The main question is how can I connect(or initialize) SD card for using in FAT SL file system like using RAM.
I did just initalize SD card hardware, and I can write something to SD card by SPI. This is not using FAT file system API, just reset and initalize SD card. So it is ready for use and wait. I understood that the first step to use FAT file system is ‘init volume’. How can I use init_volume function in FAT file system API for my SD card.. Something what I understand is wrong..? I don’t know how it works on SD card.
  1. Is it possible using FreeROTS+FAT SL APIs on flash memory?
It is easy to use on the RAM. For example, I can copy something to another place by memcpy(). But it is different on flash memory..

FreeRTOS+FAT SL, SD Card, initialization issue

You have to implement each of the functions on this page http://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusFATSL/MediaDriverAPIFunctions.shtml So the code you have to initialize the SD card hardware would go in FDRIVERINIT(), and the code to write data to the card will go in FWRITESECTOR(). As you point out though, writing data to the card is more involved than writing to RAM so you will have to replace the memcpy() calls with the commands needed by the SD card controller over the SPI bus. Search SPI on https://www.sdcard.org/developers

FreeRTOS+FAT SL, SD Card, initialization issue

Thank you. I read that page so many times.. it is very simple… I will try it~ Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

I spend whole day for this issue.. but I don’t know how it works, initialize memory. I read that it needs first address in flash memory or SD card on another post. But I don’t know how can use it.. Can you give me more tips for initiate flash memory file system ? I read web page and another docs. But I don’t know not in the least. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Can you be more specific about where the issue is, for example: Is it that you don’t know the SPI commands necessary to read and write to the card, or Is it that you don’t know how to arrange data on the SD card so it correctly represents the file system (because the data should be exactly as it is in the RAM disk memory array, just stored on the card rather than in RAM), or Is it that you don’t know how to link your SD read/write functions into the portable layer of the SD card? Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Hi. This is my situation.. I want to use file system for flash memory(e.g. SD card). My embedded system use FreeRTOS 8.0, so I chose FreeRTOSFATSL for file system on my board and bought license. Unfortunately, this is the first time to develop file system to me. So I’m not familiar with it. Then I studied it and analyze ‘FATSLandCLIWindows_Simulator’ project. But there is only codes for using RAM. I applied it to my embedded system. I made a some folders and files, and read & write something to those files in RAM on my board. But I don’t know how it applied to flash memory(SD card). So I searched way of using flash memory because my purpose is using flash memory. I chose SD card and studied how can use it. Then I can initialize it with several CMDs by SPI communication. It forced block size to 512 bytes. But this is not related with file system, hardware was just initialized independently. I think that it is ready for use.. and I know some CMDs for read or write sectors. perhaps, I can modify read or write sector functions in FAT for SD card. I want to use file system on my SD card like using it on RAM. For example, if I input ‘dir’, file system return directory and file list in SD card to me. There are many functions in FreeRTOS FAT and I want to use them. But I don’t know how can initialize(or link?, connect?) file system on SD card. I want kinds of sequence or sample codes for initialization. or please tell me if I have misunderstood something.. Regards. +) I think that I can use file system if it will be initialized. So please explain initialize sequence(or func) more specifically if you are okay..

FreeRTOS+FAT SL, SD Card, initialization issue

So starting at the beginning, with initialisation, you have to provide an implementation of F_DRIVERINIT() to initialise the card before you can use it. http://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusFATSL/MediaDriverAPI/FDRIVERINIT.shtml First get the RAM disk demo running on your target hardware. You may have to set the size of the RAM disk down to a couple of K bytes to fit it in the RAM you have available, so the file system won’t be usable, but that doesn’t matter it just needs to be compiling. To do that you can use the Win32 simulator demo as a reference, just include the same files and configuration file. Once it is compiling and running, step into the function vCreateAndVerifySampleFiles(). It in turn calls finitvolume(). finitvolume() passes in a single parameter, which is a pointer to the FDRIVERINIT() function – which in this case is called raminitfunc(). If you continue stepping through the code you will see the first line of fn_initvolume() is “mdrv = initfunc( 0 );” which is calling the function passed in as a parameter. Step into initfunc() and you will find yourself in ram_initfunc(). The top of that function does some RAM disk initialisation – replace that with the code you say you have that initialises the SD card (assuming that is working). ram_initfunc() then populates a structure with functions for reading and writing sectors – just leave those for now. You will have to come back and replace them with your own SD card read and write functions – but for now just get the code compiling and the SD card initialising. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Thank you for your detailed & kind answer 🙂 I can understand it and how do I make it. But I bump again.. I guess ‘ramdrv0’ is the first(start? or base?) address of the memory and I will replace it to SD card first memory address. Is it right? but I don’t know how do I get the address of my SD card. I searched datasheet of SD card and google. But failed.. I’m sorry, I know this is not related with FreeRTOS.. But if you have any idea with this issue, please help me. Thank you! Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

So unlike the RAM disk, the SD card is a block device – so data can only be read or written in blocks (or sectors) or 512 bytes. Rather than taking an address from the beginning of an array (as in the RAM disk) you take an address from the beginning of the SD card (sector 0). So to read an address you work out which sector the address falls within, and read the whole sector (from the start of the sector) to get a buffer that contains the data at the address you are actually interested in. Likewise when writing – read the whole sector back, modify the bytes you need to write to, then write the whole sector back to the disk. Maybe the following link will help? http://www.usna.edu/EE/ec463/notes/09SDCard_student.pdf Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

I’m sorry. I didn’t clear it.. It likes comeback to starting point. I want to know how do I make ‘t_RamDrv’ structure. typedef struct { char * ramdrv; unsigned long maxsector; int use; FDRIVER * driver; } tRamDrv; and ‘FDRIVER’ structure has serveral members and userdata, user_ptr, etc.. I want how they were decided… Please give me some comments about this structure and parameters. I have another questions. I bought both FreeRTOS and ‘FreeRTOS+FAT SL’ licenses. Also I bougth some reference document for FreeRTOS. Is there any reference of FreeRTOS+FAT SL? Your webpage and comments in the code files are too brief. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

I’m looking at that file and dont think the structure is needed at all because you can only have a single drive. The information in the structure can just be file scope variables. // Declare an FDRIVER structure at the top of the file. static FDRIVER my_driver; So raminitfunc() becomes sdinitfunc() and populated mydriver with the sdreadsector, sdwritesector, sdgetphy, sdrelease and userptr members, just as you can see being done in raminitfunct(). sdinitfunc() returns &my_driver. sdreadsector() is the sd card version of ramreadsector(), sdwritesector() is the sd card version of ramwritesector, etc. These functions you will have to implement yourself using your SPI interface and the SD card commands to read and write sectors.

FreeRTOS+FAT SL, SD Card, initialization issue

I’m looking at that file and dont think the structure is needed at all because you can only have a single drive. The information in the structure can just be file scope variables.
…like the attached file. A lot of the clutter, including the structure, is removed, leaving really just the init, read and write functions. Is that clearer? Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Hi. I have understood way to connect file system and SD card. It is really helpful to me your helps. I made new initialize, read, write, getphy functions for filesystem and finitvolume() function returns ‘0’. I made it. Next, I tried to format my SD card. fformat() is worked well and return NO ERROR. So I can open, read and write example txt file. But there is a problem.. My desktop PC or cell phone cannot read that SD Card. PC or cell phone say “this card did not formatted”. So, I formatted SD card on PC and insert it to embedded board. My system recognize it formatted already. But Some error occure when it try read or write file. The error is.. response from SD card is not returned accurately. SD card returns 0x00 first and 0xFE second and then other values comming when it receive some command. But it returns only 0x00 and next is not come.. I don’t know why it happen. It is works in embedded system but not work other system(PC, cell phone) when it formatted in embedded system. On the contrary, it works in PC or cellphone when it formatted on PC, but it does not work on embedded system. They were formatted FAT32 on both system. One more question.. attached files are master boot record of each system.(It is little Endian) upper one is formatted by FreeRTOS FAT+SL and lower one is by PC. FAT size 32 is represented ‘0x00000D3A'(=973930496 sectors = about 464GB) I missed something..? Please advise something related this issue. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Hello, I am writing to the creator of this thread. I am doing something similar to you and if you read this, can you please provide some updates as to what is the progress of your work regarding SD card and FreeRTOS+FAT. I am working with SD card but in SD mode and I am very far off from what you have achieved. Looking forward to your help. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Hi. I read your another thread too and I can understand your condition. Actually, My progress is same with my last post because I couldn’t find the reason of the problem and I should to do another work first(porting to another core). It was finished the other works, so now I’ll try to use it again. I will make a TFTP system with SD card this time. I think that you are almost finished. I can help you if you need. you can help me later too. We can be a good co-worker 🙂 Best Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Thank you very much for your reply Wonjae. Actually I am very far from where you have managed to reach. I am still struggling with how to read and write on the card and how is the addressing done and basic things like this. Can you please tell me which micro-controller were you using for this matter ? I really look forward to understand this all and hope I could learn from you a big deal. Please stay in contact. Thanks. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Owais. I used RM48 when I write this post. Now I’m using RM57(TI). Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae, Thanks for the response. I am using Atmel SAM4S CortexM. Have you ever worked with these microcontrollers? Can we set up a timing to discuss this matter it would be more convenient for me if we can arrange something like this. Please let me know if it is possible for you. I am now planning to directly go ajead with the FreeRTOS+FAT and integrate the SD card into it. Looking forward to your help. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Owais. I haven’t used other microcontrollers. But I think it is no problem if you can use SPI communication FreeRTOS and FAT SL on your system. I agree with your opinion, we can make an appointment. it is no hard. Write your statement or questions on this post or another new post, I can reply it if I know about it. Then other engineers also help you 🙂 Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae, I am actually using the HSMCI interface on SAM4S. Since I will be using the SPI interface for other purpose. I have already tested FreeRTOS on my system it is running fine. I just need to include the necessary files for the FAT SL inti the FreeRTOS environment and then integrate the SD related components. Can you please tell me where to start from. I have the initialization of SD working fine and I have other functions such as read and write blocks. Where should i put them into FAT SL? Thanks in advance. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Did you tried using window demo project? It is good for understanding the structure and system of FAT SL. Try it if you didn’t. It is using ram for storage, its configurations are in ‘ramdrv_f.c’. You can change it to your own codes for SD storage system. Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

I am actually looking into it right now. It consists of many files can I open it in Atmel Studio?

FreeRTOS+FAT SL, SD Card, initialization issue

It can be opend ‘Visual Studio’. Did you use it before..? You can see the guide at here. http://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusFATSL/Demos/FileSystemWin32Simulator_demo.shtml You can also open it by Atmel Studio but cannot execute. you can just read the codes. It is maybe enough to understand the system.

FreeRTOS+FAT SL, SD Card, initialization issue

No I haven’t used it before. I will go through it now. Moreover, I have looked into an example project in Atmel Studio for unit testing the HSMCI interface. Form there I have got the functions related to HSMCI interface for reading and writing blocks to the SD card. I wonder if I can use these in the FreeRTOS+FAT SL somehow, have you done the same? My card is initializing now and I get the card capacity and RCA (Relative Card Address). Next I want to try to initialize the card in FreeRTOS+FAT SL and see if it works the same way as it does without FreeRTOS+FAT SL. Any suggestions in this regard would be helpful.

FreeRTOS+FAT SL, SD Card, initialization issue

The answer is maybe in ramdrvf.c.. It is needed to connect SD functions with FAT SL function. Make a new FDRIVER structure and put your SD functions into the structure. ex) structurename.readsector = SDread; structurename is declared FDRIVER * and it has readsector, writesector..etc. you can find it. SD_read is your own function already you used for reading SD memory.

FreeRTOS+FAT SL, SD Card, initialization issue

Okay let me first included the necessary file into my project. I will continue from there on. One more thing, I just have the following functions related to HSMCI read and write can you please look into them and let me know if they would be sufficient for including int the F-DRIVER structure or do I need something else. uint32t hsmcistartreadblocks(void *dest, uint16_t nb_block) { uint32_t nb_data; nbdata = nbblock * hsmciblocksize; // Handle unaligned memory address if (((uint32t)dest & 0x3) || (hsmciblocksize & 0x3)) { HSMCI->HSMCIMR |= HSMCIMRFBYTE; } else { HSMCI->HSMCIMR &= ~HSMCIMR_FBYTE; } // Configure PDC transfer HSMCI->HSMCIRPR = (uint32t)dest; HSMCI->HSMCIRCR = (HSMCI->HSMCIMR & HSMCIMRFBYTE) ? nbdata : nbdata / 4; HSMCI->HSMCIRNCR = 0; // Start transfer HSMCI->HSMCIPTCR = HSMCIPTCRRXTEN; hsmcitransfertpos += nb_data; return OK; } uint32t hsmciwaitendofreadblocks(void) { uint32t sr; // Wait end of transfer // Note: no need of timeout, because it is include in HSMCI, see DTOE bit. do { sr = HSMCI->HSMCISR; if (sr & (HSMCISRUNRE | HSMCISROVRE | HSMCISRDTOE | HSMCISRDCRCE)) { HSMCI->HSMCIPTCR = HSMCIPTCRRXTDIS | HSMCIPTCRTXTDIS; hsmcireset(); return FAIL; } } while (!(sr & HSMCISRRXBUFF)); if (hsmcitransfertpos < ((uint32t)hsmciblocksize * hsmcinbblock)) { return OK; } // It is the last transfer, then wait command completed // Note: no need of timeout, because it is include in HSMCI, see DTOE bit. do { sr = HSMCI->HSMCISR; if (sr & (HSMCISRUNRE | HSMCISROVRE | HSMCISRDTOE | HSMCISRDCRCE)) { hsmcireset(); return FAIL; } } while (!(sr & HSMCISR_XFRDONE)); return OK; } uint32t hsmcistartwriteblocks(const void *src, uint16_t nb_block) { uint32_t nb_data; nbdata = nbblock * hsmciblocksize; // Handle unaligned memory address if (((uint32t)src & 0x3) || (hsmciblocksize & 0x3)) { HSMCI->HSMCIMR |= HSMCIMRFBYTE; } else { HSMCI->HSMCIMR &= ~HSMCIMR_FBYTE; } // Configure PDC transfer HSMCI->HSMCITPR = (uint32t)src; HSMCI->HSMCITCR = (HSMCI->HSMCIMR & HSMCIMRFBYTE) ? nbdata : nbdata / 4; HSMCI->HSMCITNCR = 0; // Start transfer HSMCI->HSMCIPTCR = HSMCIPTCRTXTEN; hsmcitransfertpos += nb_data; return OK; } uint32t hsmciwaitendofwriteblocks(void) { uint32_t sr; // Wait end of transfer // Note: no need of timeout, because it is include in HSMCI, see DTOE bit. do { sr = HSMCI->HSMCISR; if (sr & (HSMCISRUNRE | HSMCISROVRE | HSMCISRDTOE | HSMCISRDCRCE)) { hsmcireset(); HSMCI->HSMCIPTCR = HSMCIPTCRRXTDIS | HSMCIPTCRTXTDIS; return FAIL; } } while (!(sr & HSMCISR_TXBUFE)); if (hsmcitransfertpos < ((uint32t)hsmciblocksize * hsmcinbblock)) { return OK; } // It is the last transfer, then wait command completed // Note: no need of timeout, because it is include in HSMCI, see DTOE bit. do { sr = HSMCI->HSMCISR; if (sr & (HSMCISRUNRE | HSMCISROVRE | HSMCISRDTOE | HSMCISRDCRCE)) { hsmcireset(); return FAIL; } } while (!(sr & HSMCISRNOTBUSY)); //Assert(HSMCI->HSMCISR & HSMCISRFIFOEMPTY); return OK; } These are from the Atmel Studio example of HSMCI interface unit test. Thanks once again for your support.

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae, I have included all the source and include files from FreeRTOS+FAT SL into my project and it is compiling without any error, but this is without any implementation or initialization yet just the files are included and linked. Now I am looking at the FDRIVER structure defined in apimdriver.h I cannot understand where are these functions implemented (FDRIVERINIT FWRITESECTOR FREADSECTOR FGETPHY FGETSTATUS FRELEASE) and what should I do to replace them with my functions for example SD initialization etc. This is really very stressful but i hope you understand my situation and could help me further. Thanks for your support. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Owais.
  1. I can’t check your codes because I haven’t used HSMCI. but you know it already if you tested it without the file system.
  2. I can understand your streessful situation.. I was same with you. FDRIVER what you found is important. Make a new initialization function like raminitfunc() in ‘ramdrv_f.c’. Refer the codes in the file. Try it. It is almost finished. Good luck.
Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae and thank you very much for your continuous support, I have initialized a new function in of type FDRIVER and also I have declared the same in APImdriver.h as follows:
F_DRIVER * sd_init ( unsigned long driver_param );
and the sdinit function is implemented inside ramdrvf.c as follows :
F_DRIVER * sd_init ( unsigned long driver_param )
{
( void ) driver_param;

if( in_use )
return NULL;

s_driver.readsector = sd_mmc_start_read_blocks;
s_driver.writesector = sd_mmc_start_write_blocks;
s_driver.getphy = sd_getphy;
s_driver.release = sd_release;

//SD card version 2
uint8_t v2 = 0;

// Card need of 74 cycles clock minimum to start
hsmci_send_clock();

// CMD0 - Reset all cards to idle state.
if (!hsmci_send_cmd(SDMMC_MCI_CMD0_GO_IDLE_STATE, 0))
{
    printf("CMD0 failednr");
    return FAIL;
}

// Test SD card for voltage compatibility
if (!sd_cmd8(&v2))
{
    //return FAIL;
    printf("CMD8 failednr");
}

// Try to get the SD card's operating condition
if (!sd_mci_op_cond(v2))
{
    //It is not a SD card
    //return FAIL;
    printf("Not a valid SD cardnr");
}

// SD MEMORY, Put the Card in Identify Mode
// Note: The CID is not used in this stack
if (!hsmci_send_cmd(SDMMC_CMD2_ALL_SEND_CID, 0))
{
    printf("CMD2 failednr");
    return FAIL;
}
// Ask the card to publish a new relative address (RCA).
if (!hsmci_send_cmd(SD_CMD3_SEND_RELATIVE_ADDR, 0))
{
    printf("CMD3 failednr");
    return FAIL;
}
rca = ((hsmci_get_response() >> 16) & 0xFFFF);
printf("Card relative address is : %dnr", rca);

// SD MEMORY, Get the Card-Specific Data
if (!hsmci_send_cmd(SDMMC_MCI_CMD9_SEND_CSD, rca << 16))
{
    printf("CMD9 failednr");
    return FAIL;
}
hsmci_get_response_128(csd);
sd_decode_csd();

// Select the SD card and put it into Transfer Mode
if (!hsmci_send_cmd(SDMMC_CMD7_SELECT_CARD_CMD, rca << 16))
{
    printf("Failed to execute CMD7nr");
    return FAIL;
}

// SD MEMORY, Read the SCR to get card version
if (!sd_acmd51())
{
    //return FAIL;
    printf("ACMD51 failednr");
}

// TRY to enable High-Speed Mode
if (!sd_cm6_set_high_speed())
{
    //return FAIL;
    printf("High Speed not setnr");
}
else
{
    hsmci_select_device(0, clock, 4, high_speed);
    // Set power saving to maximum value
    //HSMCI->HSMCI_MR = HSMCI_MR_PWSDIV(0x07);
    //HSMCI->HSMCI_CR = HSMCI_CR_PWSEN;
    printf("Card switched to HS modenr");
}

// SD MEMORY, Set default block size
    if(!hsmci_send_cmd(SDMMC_CMD16_SET_BLOCKLEN,SD_MMC_BLOCK_SIZE))
{
    //return FAIL;
    printf("CMD16 failednr");
}
printf("Card relative address is : %dnr", rca);

in_use = 1;

return &s_driver;
}
Does this look somewhat correct? I realize there are some flags like FERRNOTFORMATTED and FNOERROR do i need to included these in the sdinit function? Secondly when I run the vCreateAndVerifySampleFiles() it tries to read from the sd card even though I have commented out the fwrite, fread, fputc and f_getc functions. Am I missing something here? Please advise. Thanks in advance. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Okay so now the initialization is done and I get the same result as I was getting when I ran the sd_init independently. I have the same RCA and the capacity of the card is also correct. Now I am having trouble with
f_format( F_FAT32_MEDIA );
It returns FERRONDRIVE I cannot understand why is it so. Any suggestion in this regard? Although the card that I have inserted is already formatted with FAT32 FS do I need to go through the format procedure again or can I skip this and proceed to creating files? At this point I have taken a lot of code from AS example and placed it in the sdmmcreadblock function which is equivalent to ramreadsector. I am not sure what is wrong. Also my function returns OK=1 at the end of execution could this create problems in the FreeRTOS+FAT SL? Please guide me how to proceed further. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

turns out that the FERRONDRIVE was caused due to the reason that my sd_getphy function was returning OK=1 whereas in FreeRTOS+FAT SL it is expected to be
    MDRIVER_RAM_NO_ERROR=0
I changed my function according so now there is a new error
    F_ERR_MEDIATOOSMALL
I ran the debug and found out that it is coming from
    return _f_postformat( &phy, fattype );
Any suggestion in this regard. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

okay now I have figured out why I was getting the following error
F_ERR_MEDIATOOSMALL
It turns out that the getphy function also returns the following
MDRIVER_RAM_NO_ERROR
I have changed it now and it doesn’t return the above error anymore. Now the situation is that since at some point in the following functions
f_initvolume(sd_init) 
f_format(F_FAT32_MEDIA)
The program runs the following functions
ram_readsector()
ram_writesector()
I have replaced these functions with my own functions specific for SD card. The read operation seem to be working fine as it does not generate any error whereas the write operation is making huge number of errors. I am not sure if this is a problem of my function or if the FreeRTOS+FAT SL is looking for something that I haven’t done. Any suggestions in this regard? Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Owais. Your progress is similar to me.
  1. The Format problem It is same in my system. I fromatted my SD card on PC, but FAT SL say it is not formatted. It works well on the board if I format again using FAT SL. But it cannot read in PC. They are same FAT32 format.. So I checked MBR, but I don’t know still what is reason. Please let me know if you find it. I posted it on this thread at 2014-07-11.
  2. It seems your reading function is working well. The errors occured from writing function are build error?
I think that your development way is correct.. Actually my system is still not perfect, so I don’t know my idea is accurate. Please give me your opinion. Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae, I have gone through your posts and read about the format problem but unfortunately I am far from there since I can only read the card at the moment but I am not sure how to make sure if the read function is working without any fault. I have just included some printfs in the read function to indicate any error but it seems to be working okay without any problem but i will be more sure once I can read something meaningful and display it somewhere. About the write function the problems are not related to build in fact they are related to actual transfer of data seems there are some errors while I read the Status Register I am not sure what the problem is. I am still looking into it maybe the write function that you have can help me in this regard can you please share your write function. It would be very helpful. Thanks. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Owais, I can’t guess what is reason of your writing fuction error. Is it works without file system? My reading function and writing fucntions are same.. the only difference is connecting to the own ‘reading’ or ‘writing’ fucntion.. Test your writing fucntion independently. Regards. Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello Wonjae, I am not sure either since I have used the same function as I am using for reading and just changed the command to Write single block and accordingly made adjustment in mode registers of the interface but still it is not clear where the problem is. Moreover I am thinking whether it is this simple to get it running, I mean if I add the write function that works will it ensure that everything else starts running smoothly like making a file and writing something into it and then reading it back again? Thank you for your support so far it has helped me a lot. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

In my opinion, it will be operated well automatically if you make a perfect initialization function. so check your functions independently first.. Regards, Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Okay thanks, I am looking into it and will post once I get it working. Thank you so much for your help. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

I can’t express my happiness … thanks everyone specially Wonjae for the continuous support. I have finally managed to fix the problem and now i can write on the SD card and even check the written files on my PC. It turns out as Wonjae said earlier that the initialization has to be correct and there was just a minor mistake in my initialization, I forgot to set the bus width to 4-bits by sending the ACMD6 command to the SD card controller when I realized this it was a matter of minute that everything started to work smoothly as if there was never a problem. Once again thank you everyone for bearing my stressful posts and helping me throughout. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Congratulations! Can you read the file in SD card wrote by FAT SL? Please give me a tip if you can use the SD card both PC and FAT SL system. It doesn’t work in my system as I posted already. Regards, Wonjae

FreeRTOS+FAT SL, SD Card, initialization issue

Hello and thanks, Yes I have to do some testing but as far as I know I can create files on the SD card and then I can read those files on my PC as well. I am using a pre-formatted card at the moment but I will do some testing with a non-formatted card and will let you know if it still works with the pc. Thanks for you help and I wish you best of luck. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Please post the working code for both platforms, along with a little description of the platform and interface, to the following FreeRTOS Interactive form (which I have just created). Thanks. http://interactive.freertos.org/forums/21199265-FreeRTOS-FAT-SL

FreeRTOS+FAT SL, SD Card, initialization issue

Hello, I am trying to upload an example that I worked out for FreeRTOS+FAT SL using SD card. I created an account last week on FreeRTOS interactive but now for some reason it says that my account has been suspended. Please look into this so that I may upload the example for Cortex-M. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

Sorry about that – a little while ago a lot of spam appeared on the site and the anti-spam settings were set up to a pretty aggressive level. It looks like you were an innocent victim. In any case I have manually unsuspended your account. Please let me know if you have any further issues. Regards.

FreeRTOS+FAT SL, SD Card, initialization issue

Hello, Thanks for fixing the matter with my account. However, I uploaded my example as a zip file along with some description which is not yet available on the interactive page. Please look into this and if there is some problem regarding the upload please let me know. Regards, Owais

FreeRTOS+FAT SL, SD Card, initialization issue

I would be grateful if you could upload the code again – sorry for the inconvenience.

FreeRTOS+FAT SL, SD Card, initialization issue

I have uploaded it again. Please check and approve.

FreeRTOS+FAT SL, SD Card, initialization issue

Done – thanks for taking the time. [curiously, white listing one of your posts made both of them turn up!]

FreeRTOS+FAT SL, SD Card, initialization issue

Yes, I can see them both now. Maybe the other one was also waiting in line. Anyhow they are both the same.