cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Explorer
Explorer
11,764 Views
Registered: ‎05-15-2009

sysace_fopen hang

Jump to solution

Hello,

 

I'm trying to write a file into CF, however the software application hangs in sysace_fopen(fileName, "w"); instruction.The file is to be created at instruction call.

 

Any ideas of what the problem could be?

 

Best,

JM

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Explorer
Explorer
14,176 Views
Registered: ‎05-15-2009

Hello,

I have managed to succeed on writing to the CF :) . Apparently the problem was on CF formatting. Simply placed the CF onto the USB CF card reader, downloaded mkdosfs from http://www1.mager.org/mkdosfs/mkdosfs.zip, and runned from the windows command prompt:

 

c:\mkdosfsfolder> mkdosfs f:\

 

Note that in my case, the CF drive is F:\ when attached to the PC. So, bottom line, remember to format the CF, even if it's the default CF card that comes with the evaluation board, in my case, the ML402.

 

Hope this helps anyone with this same issue.

Best,

JM

 

 

View solution in original post

0 Kudos
8 Replies
Highlighted
Visitor
Visitor
11,720 Views
Registered: ‎06-11-2009

Hi,

 

I had exactly the same issue with EDK 10.1 SP 3. I did not find the reason but a simple fix I used was to call the sysace_readdir(...) function before sysace_fopen function.

 

Hope this helps,

Regards,

 

Pierre-André

0 Kudos
Highlighted
Explorer
Explorer
11,697 Views
Registered: ‎05-15-2009

Hello,

Thank you, however it didn't fix. I'm also using EDK 10.1 with SP3. Here's what I have in software:

 

main()
{

 

    xil_printf("\033[H\033[J"); //clears the screen
    xil_printf("Hello!\n\r");

unsigned char buffer[] = "sasfsfsdfgasdgdfgsdf\n\r";

 

    dirent de[MAX_DIR_ENTRIES];
    char* path = "a:\\web";
    int numDirEntries = 0;


    char fileName[] = "a:\\test2.txt";
    SYSACE_FILE* file; // file descriptor
    int n = 0;

 

    numDirEntries = sysace_readdir(path, de, MAX_DIR_ENTRIES );
    file = sysace_fopen(fileName, "w");
    if (file)
    {
        sysace_fwrite(buffer, 1, sizeof buffer, file);
        xil_printf("# of bytes written: %d\n\r", n);
                sysace_fclose(file);

    }
    else
    {
        xil_printf(" - Error: could not write to CF\n\r");
    }

 

}

 

However, only "Hello" is printed and nothing is written in the CF. Any suggestions?

 

Best,

JM

0 Kudos
Highlighted
Visitor
Visitor
11,695 Views
Registered: ‎06-11-2009

Hi,

 

It turned out that it the issue was not really solved neither for me... However, I found several types of errors that could make the initialization function hang. For instance, an incorrect format of the CF card (as explained on http://www.xilinx.com/support/documentation/data_sheets/ds080.pdf,page 10) makes the function hang without error. Basically, if you format the CF with XP and the card is small (for instance 32MB), the card is unusable with the SystemACE controller !

 

What I do now (and it works, is)

 

- Use a CF formatted with mkdosfs with mkdosfs -f 1 -F 16 -s 2 -R 1 <device>

- Initialize the SystemAce controller with :


    XSysAce pCF;
       
    XStatus s = XSysAce_Initialize(&pCF, XPAR_SYSACE_COMPACTFLASH_DEVICE_ID);       
   
    if(s != XST_SUCCESS)
    {
        xil_printf("Error during CF init\r");
    }

    s = XSysAce_SelfTest(&pCF);   
    if(s != XST_SUCCESS)
    {
        xil_printf("Error during CF self test\r");
    }

    if(!XSysAce_IsCFReady(&pCF))
        xil_printf("CF not ready\r");

 

And after that, the card works (except that I can not write to it... which I am currently investigating...)

 

Hope this helps,


Regards,

Pierre-André

0 Kudos
Highlighted
Explorer
Explorer
11,693 Views
Registered: ‎05-15-2009

Hello pyrrhus,

Thank you very much. I'm running the code with the xmd debugger and I checked that sysace_fopen is passing, the problem is in sysace_fwrite(). As soon as I realize in fact where it hangs I get back to you. I'm using the 32MB CF that came with my virtex 4.

 

Please, post if you also find out the problem.

 

Best,

JM

0 Kudos
Highlighted
Explorer
Explorer
14,177 Views
Registered: ‎05-15-2009

Hello,

I have managed to succeed on writing to the CF :) . Apparently the problem was on CF formatting. Simply placed the CF onto the USB CF card reader, downloaded mkdosfs from http://www1.mager.org/mkdosfs/mkdosfs.zip, and runned from the windows command prompt:

 

c:\mkdosfsfolder> mkdosfs f:\

 

Note that in my case, the CF drive is F:\ when attached to the PC. So, bottom line, remember to format the CF, even if it's the default CF card that comes with the evaluation board, in my case, the ML402.

 

Hope this helps anyone with this same issue.

Best,

JM

 

 

View solution in original post

0 Kudos
Highlighted
Visitor
Visitor
11,655 Views
Registered: ‎06-11-2009

Hello,

 

I also managed to write to the CF... The options I manually set with mkdosfs were not completely correct and using it without any options resulted in completely working CF !

 

Thank you for the idea !

 

Regards,

Pierre-André

0 Kudos
Highlighted
Observer
Observer
10,729 Views
Registered: ‎09-15-2009

Hello,

 

I'm facing a very similar (if not the same) problem with EDK 11.2 and a XUPV5.

 

Using BSB I created a system as simple as it can be: Microblaze, SysACE, UartLite. Now I'm trying to test read/write operations in the CF that came with the board (1GB).

 

The .mss file was changed accordingly. The partitions of CF were deleted (so that now it has only one) and formated with mkdosfs, as already mentioned.

Both the "TestApp_Peripheral_microblaze_0" application and the XSysAce_SelfTest succeeded.

 

The problem is when I try to use sysace_fopen. Then nothing happens, not even the print command *before* sysace_fopen....

 

This is the code I'm using:

 

 

#include "xparameters.h" #include "stdio.h" #include "sysace_stdio.h" int main(void) { char FileName[] = "a:\\test.txt"; SYSACE_FILE *infile; int numread,i; char readBuffer[10]; print("-- Entering main() --\r\n"); infile = sysace_fopen(FileName, "w"); if(infile){ xil_printf("Reading file : %s\n\r", FileName); numread = sysace_fread(readBuffer, 1, 10, infile); xil_printf("data %s\r\n", readBuffer); } else{ xil_printf("Can't open file : %s\n\r", FileName); return 0; } sysace_fclose(infile); print("\r\n\n"); return 0; }

 

Does anyone knows what's still going wrong?

Thanks in advance,

Carmela

 

 

 

0 Kudos
Highlighted
Explorer
Explorer
10,510 Views
Registered: ‎05-15-2009

Make sure you are allocating enough heap and stack spaces.

 

Best,

JM

0 Kudos