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

FlashDev / FlashPrg for STM32F107

Hello.

I'm trying to set up a MCBSTM32C to have a Flash File System using the RL-ARM FlashFS library, but i'm having a bit of trouble i hoped someone could help me sort out.

In the book "Building Applications with RL-ARM" under RL-Flash introduction, there's a section discussing how to set up a Flash-based filesystem.

It calls out for the file FS_FlashPrg.c and FS_FlashDev.h under the folder C:\KEIL\ARM\RL\FLASHFS\FLASH then a subdirectory named according to your flash or microcontroller.

Looking in that folder i have the following folders:

25F640S33
AM29x800BB
AM29x800BBx2
AM29x800BT
AM29x800BTx2
AT45DB321C
AT45DB642D
LPC_IAP_128
LPC_IAP_256
SST39x320x
STR71x
STR75x
STR91x

I'm not sure which one would correspond to the STM32F107VC... Do I have to write my own drivers for this controller? If so, is there literature i can obtain covering how to do this?

Thanks for any insight.

- Per

Parents
  • Ok, an update. I was able to set up Flash as a file system.. but i'm not sure it's working correctly.

    To make it work, I had found a reference manual for the 207 with 1024 KB flash, and they say this:

    Main memory
    Sector 0 0x0800 0000 - 0x0800 3FFF 16 Kbyte
    Sector 1 0x0800 4000 - 0x0800 7FFF 16 Kbyte
    Sector 2 0x0800 8000 - 0x0800 BFFF 16 Kbyte
    Sector 3 0x0800 C000 - 0x0800 FFFF 16 Kbyte
    Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbyte
    Sector 5 0x0802 0000 - 0x0803 FFFF 128 Kbyte
    Sector 6 0x0804 0000 - 0x0805 FFFF 128 Kbyte
    .
    .
    .
    .
    .
    .
    .
    .
    .
    Sector 11 0x080E 0000 - 0x080F FFFF 128 Kbyte
    

    So i placed the device start at 0x08000000, and sized it to 0x00020000 (128KB) and then in the FS_FlashDev.h I had only one sector starting at offset 0x00020000, and with size 128 KB.

    This works - i.e. i can open a file, write to it, and close it. But when I try to use ffind or fopen( ..., "r") on it, i cannot see it.

    Any ideas?

Reply
  • Ok, an update. I was able to set up Flash as a file system.. but i'm not sure it's working correctly.

    To make it work, I had found a reference manual for the 207 with 1024 KB flash, and they say this:

    Main memory
    Sector 0 0x0800 0000 - 0x0800 3FFF 16 Kbyte
    Sector 1 0x0800 4000 - 0x0800 7FFF 16 Kbyte
    Sector 2 0x0800 8000 - 0x0800 BFFF 16 Kbyte
    Sector 3 0x0800 C000 - 0x0800 FFFF 16 Kbyte
    Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbyte
    Sector 5 0x0802 0000 - 0x0803 FFFF 128 Kbyte
    Sector 6 0x0804 0000 - 0x0805 FFFF 128 Kbyte
    .
    .
    .
    .
    .
    .
    .
    .
    .
    Sector 11 0x080E 0000 - 0x080F FFFF 128 Kbyte
    

    So i placed the device start at 0x08000000, and sized it to 0x00020000 (128KB) and then in the FS_FlashDev.h I had only one sector starting at offset 0x00020000, and with size 128 KB.

    This works - i.e. i can open a file, write to it, and close it. But when I try to use ffind or fopen( ..., "r") on it, i cannot see it.

    Any ideas?

Children
  • Some more information ...

    If i try to use any memory area at 0x0802 5800 or higher, the program i have will hard fault with the call stack as follows.

    HardFault_Handler()
    <0800135e()>
    fs_ReadData()
      adr <invisible>
      cnt <invisible>
      buf <invisible>
    fs_Find_File()
      fname 0x00000000
      fcb 0x20000090
      fa 0x20000b9d8
      buf 0x2000b9b4
      bl 0x00000000
      prev <invisible>
      fid 0x0000bdf7
    __fopen()
      fname 0x0800048a
      openmode <invisible>
      i <invisible>
      fid 0x2000b9b4
      handle 0x00000000
      fcb 0x20000090
      rval <invisible>
    _sys_open()
      name <invisible>
      openmode <invisible>
    <080010f2()>
    main()
    

    if i do not include any addresses above this, it behaves as such:

    ...
            fptr = fopen("F:\\test.txt", "w");
            if ( fptr != NULL )
            {
                    r= fwrite("this is a test", 1, 14, fptr);
                    r= fflush(fptr);
                    r= fclose(fptr); // the code will run to here
            }
    
            fptr = fopen("F:\\test.txt", "r" );
            if ( fptr != NULL )
            {
                    r= fread(sz, sizeof(char), 14, fptr);
                    r= fflush(fptr);
                    r= fclose(fptr); // the code will NOT run to here
            }
    

    It seems the file is not written properly in the fwrite call?