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

RTL: Flash File System

Hi

I'm using flash device.

Configuration:
Sector size 256 byte.

The fuction ffree() returns always 0 byte.

Is this possible?

  • Hi Stefan,

    I did try use Flash File System (FFS) on MCBSTR9 evaluation board (STR912F44) but can't get success. Once I add "fopen(..)" to the main(), then processor never starts main function. It loops somewhere before main. Compiler says 0 errors. Keil support does not respond to my messages. Are you got success to use FFS on ARM? What kind of ARM you use? Are you use external flash for FFS or internal?
    Thanks

  • Hi Mikhail

    I'm using ATMEL AT91SAM7S256.

    1. First Step with RAM drive:
    I made my first test application with RAM drive. So I was sure not having problems with flash writing routines.

    Remarks:
    - Do not initialise the file system with finit().
    - ffree() doesn't work with page size of 256 byte.

    Try this and we can go further on with flash drive.

    Best regards
    Stefan

    /* -----------------------------------------------------------------------
     * Funktion: main()
     */
    int main(void)
    {
            S32 tmpS32;
            FILE *f;
    
            // *********************************
            // Init FS (don't usw it with RAM)
            /*
            tmpS32 = finit();
            switch(tmpS32){
            case 0: printf("finit()... done\n"); break;
            default: printf("finit()... ???\n"); break;
            }
            */
    
            // *********************************
            tmpS32 = fcheck("R:");
            switch(tmpS32){
            case 0: printf("fcheck(R:)... done\n"); break;
            default: printf("fcheck(R:)... do format\n"); break;
            }
    
            // *********************************
            // Format (always with RAM)
            //if(tmpS32){
                    // Format:
                    tmpS32 = fformat("R:");
                    switch(tmpS32){
                    case 0: printf("fformat(R:)... done\n"); break;
                    default: printf("fformat(R:)... ???\n"); break;
                    }
            //}
    
            // *********************************
            printf("ffree(R:)... %d bytes\n",ffree("R:"));
    
    
            // *********************************
            // write
            f = fopen("R:Test.txt", "w");
            if(f == NULL) {
                    printf("writing error...\n");
            }
            else {
                    tmpS32 = fputs("GEE!!!", f);
                    tmpS32 = fclose(f);
            }
    
            // *********************************
            // read
            f = fopen("R:Test.txt", "r");
            if(f == NULL) {
                    printf("reading error...\n"); while(1);
            }
            else {
                    while(fgets(daten, sizeof(daten), f) != NULL) {
                            puts(daten);
                    }
                    tmpS32 = fclose(f);
            }
    
            // Loop:
            while(1){
                    //...
            }
    }
    
    

  • Hi Stefan,

    Thanks for the advice. I still have problem with flash file system. Followed code I can compile and run on STR912FW44.

    int main(void)
    {
     S32 tmpS32;
     FILE *f;
    
     f = NULL;
     // *********************************
     tmpS32 = fcheck("R:");
     if(tmpS32 == 0)
      tmpS32 +=1;           // to get a trace only
     else
      tmpS32 +=2;           // to get a trace only
     // *********************************
     tmpS32 = fformat("R:");
     if(tmpS32 == 0)
      tmpS32 +=1;           // to get a trace only
     else
      tmpS32 +=2;           // to get a trace only
     // *********************************
     while(1)
     {
     };
    }
    


    I set breakpoint to the fcheck() line and be able go trough by pressing F10. Both fcheck() and fformat() return zero. If I add few lines (fopen() and fclose()), I can compile, but program never reach main() function and lookup somewhere between startup file str91x.s and main() function. Followed is this code.

    int main(void)
    {
     S32 tmpS32;
     FILE *f;
    
     f = NULL;
     // *********************************
     tmpS32 = fcheck("R:");
     if(tmpS32 == 0)
      tmpS32 +=1;           // to get a trace only
     else
      tmpS32 +=2;           // to get a trace only
     // *********************************
     tmpS32 = fformat("R:");
     if(tmpS32 == 0)
      tmpS32 +=1;           // to get a trace only
     else
      tmpS32 +=2;           // to get a trace only
     // *********************************
     f = fopen("R:Test.txt", "w");
     if(f == NULL)
      tmpS32 = 4;
     else
      tmpS32 = fclose(f);
     // *********************************
     while(1)
     {
     };
    }
    

    Like adding fopen() function in turn adds some scatter code, not available for debug or trace. Mikhail

  • Hi Mikhail

    I'm sure the problem is the configuration. I had the same problem.

    Make sure <read/write area> (--> set in <options for target>)
    and
    <target device base address> (--> set in the file <file_config.c>)
    do not overlap each other.

    Example for my ARM:

    <read/write area> (--> set in <options for target>):
    Start=0x200000, Size=0x8000
    
    <target device base address>  (--> set in the file <file_config.c>):
    Target base address=0x208000
    Device size in bytes=0x8000
    

    Ckeck it and let me know about your memory layout. Best regards Stefan

  • Hi Stefan,
    my configuration:

    Read/Write Memory Areas
    on-chip:
    IRAM1 Start:0x4000000 Size:0x8000
    
    In the file "AFS_Config.c":
    #define RAM_DEV     1
    #define RAM_BADR    0x04008000
    #define RAM_SIZE    0x010000
    #define RAM_NSECT   8
    

    as you can see, there is no overlap. Stefan, are your test project work in simulator? Mikhail

  • Hi Mikhail

    Yes, application with RAM drive works on target and in simualtor.

    Have you tryed with smal RAM size configuartion yet?
    How is the memory layout of your ARM?

    Stefan

  • Hi Stefan,

    Memory layout for the STR912FW44 is:

    ROM bank0 0x0 0x7FFFF (size 0x80000)
    ROM bank1 0x80000 0x87FFF (size 0x8000)
    RAM 0x4000000 0x4017FFF (size 0x18000)
    

    Stefan, can you send me your test project with file system, so I can try it on simulator and compare with my project. Do not send lib files, just zip up your project with simple main() that you already post here. My address: mikhail.sokolov@baselineindustries.com

    thanks
    Mikhail