Keil™, An ARM® Company

RL-ARM User's Guide

Sector Memory Map

This map specifies the Flash Device Sector layout. You must specify the sector size and sector base address for each Flash Sector. The RL-FlashFS does not require that specified Flash sectors be continuous. Gaps are allowed in the Device Memory space. You may freely reserve some Flash sectors for the application code. Reserved sectors are not used for storing files. Simply do not include such Flash Sectors in the FLASH_DEVICE description table.

However, it is not allowed to assign part of a Sector to the RL-FlashFS and the rest of that sector for some other usage. When such a sector is erased by the RL-FlashFS, the whole sector is erased, not just part of it. Therefore, the erase process also erases the sector area assigned to some other usage.

FS_FlashDev.h

The memory map is specified in the FS_FlashDev.h description header file. Every device has it's own description file. Those files are located in the \Keil\ARM\RL\FlashFS\Flash folder.

To generate the FS_FlashDev.h description file, copy flash sector layout information from the Flash Device datasheet. You may also convert ULINK flash programming algorithms to be used for the RL-FlashFS. They are in the \Keil\ARM\Flash folder. Device specific files are in a subfolder with a device name. Source files used for the conversion are named FlashDev.c and FlashPrg.c respectively.

You must specify a sector size in bytes and a sector base address relative to a Flash Device. Macro DFB converts this information into the RL-FlashFS compatible sector description.

The following example shows a Flash Sector layout configuration description for the Am29x800BT Flash Device:

#define FLASH_DEVICE                                  \ 
  DFB(0x10000, 0x000000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x010000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x020000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x030000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x040000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x050000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x060000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x070000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x080000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x090000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x0A0000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x0B0000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x0C0000),   /* Sector Size 64kB */    \ 
  DFB(0x10000, 0x0D0000),   /* Sector Size 64kB */    \ 
  DFB(0x04000, 0x0E0000),   /* Sector Size 16kB */    \ 
  DFB(0x08000, 0x0E4000),   /* Sector Size 32kB */    \ 
  DFB(0x02000, 0x0EC000),   /* Sector Size  8kB */    \ 
  DFB(0x02000, 0x0EE000),   /* Sector Size  8kB */    \ 
  DFB(0x02000, 0x0F0000),   /* Sector Size  8kB */    \ 
  DFB(0x02000, 0x0E2000),   /* Sector Size  8kB */    \ 
  DFB(0x08000, 0x0F4000),   /* Sector Size 32kB */    \ 
  DFB(0x04000, 0x0FC000),   /* Sector Size 16kB */    \ 

#define FL_NSECT    22

To improve the RL-FlashFS performance, the sector information is stored as a table in the code. The RL-FlashFS scans this table when accessing files from the Flash Device.

Converting FlashDev.c

Here are instructions to convert existing device description files for various Flash Devices, which are used by ULINK flash programming to the RL-FlashFS. There are two macros which must be specified in this file:

  • FLASH_DEVICE macro defines the sector layout,
  • FL_NSECT macro defines the number of flash sectors.


The following example describes a conversion for the Am29x800BT Flash Device:

  1. Copy FlashDev.c file from \Keil\ARM\Flash to a subfolder under \Keil\ARM\RL\FlashFS\Flash with the same subfolder name. This is a device name.
  2. Rename this file to FS_FlashDev.h
  3. Delete following lines:
    #include "..\FlashOS.H"        // FlashOS Structures
    
    struct FlashDevice const FlashDevice  =  {
      FLASH_DRV_VERS,             // Driver Version, do not modify!
      "AM29x800BT Flash",         // Device Name
      EXT16BIT,                   // Device Type
      0x000000,                   // Device Start Address
      0x100000,                   // Device Size in Bytes (1MB)
      1024,                       // Programming Page Size
      0,                          // Reserved, must be 0
      0xFF,                       // Initial Content of Erased Memory
      100,                        // Program Page Timeout 100 mSec
      3000,                       // Erase Sector Timeout 3000 mSec
    
    // Specify Size and Address of Sectors
    
    and lines at the bottom:
      SECTOR_END
    };
    
  4. Expand and Convert Sector description and convert it to a macro FLASH_DEVICE.
      0x10000, 0x000000,          // Sector Size 64kB (14 Sectors)
    
    This line needs to be expanded to 14 lines for 14 sectors using a DFB macro. Do not forget a macro continuation sign \.
      DFB(0x10000, 0x000000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x010000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x020000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x030000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x040000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x050000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x060000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x070000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x080000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x090000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x0A0000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x0B0000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x0C0000),   /* Sector Size 64kB */    \ 
      DFB(0x10000, 0x0D0000),   /* Sector Size 64kB */    \ 
    
  5. Repeat the expansion for each line from the file.
  6. Add an FL_NSECT macro with defined number of sectors.

If you have done everything correctly, your FS_FlashDev.h file should look like this.