Real-Time Library: Flash File System 1 Flash File System - Basics – The RL-FlashFS allows to create, save, read and modify files – The library functions provide high level access to file system functionalities – Usage with the MicroLib runtime library is not supported 4-2 What is MicroLib MicroLib is a highly-optimized library for ARM-based embedded applications written in C. When compared to the standard C library included with the ARM Compilation Tools, MicroLib provides significant code size advantages required for many embedded systems. 4-3 Flash File System - Basics Supported memory devices: External RAM External Flash (SPI) Internal Flash Memory Cards like SD and MMC cards (used in SPI mode) Default drives: “R:“ external RAM (“Ram Drive“) “S:“ external Flash (“SPI Flash device“) “F:“ internal Flash (“Embedded Flash drive“) “M:“ external Memory Cards (“Memory Card Drive“) 4-4 Flash File System - Basics Up to 4 GByte memory space is supported Supported file system for memorycards are FAT16 or FAT32 All devices can be used parallel Required components: The File system may be used with or without RL-RTX The file system integrates with RL-TCP RL-FlashFS library file Configuration file File_Config.c TFTP server Webserver upload The File system integrates with RL-USB Mass Storage Class (MSC) 4-5 Memory Organization A Flash device is usually divided into flash sectors (Block) – A Flash sector is a memory page which is written cell after cell – The size of a memory cell depends on device architecture 8-bit (byte) 16-bit (half word) 32-bit (word) 4-6 Memory Organization – A big file is separated into multiple blocks – Smaller files are stored together in one block Deleting a file: The whole flash sector has to be erased Data within this sector which is not to be deleted will be saved within another sector Changing a file: Changed data is stored into a new sector The file pointer is actualized The sector with the old file data is erased 4-7 RAM Device Configuring the file system to use the internal RAM of a typical ARM based microcontroller. Not practical in real life - RAM is volatile (unless battery backed) Basic Configuration file: File_Config.c Libraries: ARM7 & ARM9: FS_ARM_L.lib Cortex-M3: FS_CM3.lib 4-8 RAM device 4-9 RAM RAM Device has to be split into logical sectors – Usage without Device Description Table – Device layout is generated automatically by configuration (File_Config.c) – RAM devices need special low-level read/write function – High-level handling is equal to Flash devices 4-10 Flash File system functions 4-11 Flash File system functions 4-12 SD CARD Hardware Wear levelling and error correction Giga bytes of low cost storage 100Mbit/sec data transfer rate Write protection Optional copyright protection Standard communication protocol Independent from the underlying flash technology Typically 100K Writes endurance Low cost 4-13 SD CARD 4-14 Using Memory Cards Memory cards can be used in SPI mode or Native mode Uses the FAT file system Supports no directories or subdirectories Maximum of 512 directory entries File Information Record of each file stores time information too fs_get_time() fs_get_date() 4-15 SD CARD SPI MODE Uses a SPI Driver for low level functions - spi_init() Initialize the SPI controller spi hi speed() Change between high and low SPI mode spi_hi_speed for SPI data transfer spi_send() Writes and reads a byte on the SPI interface 4-16 SD CARD - MCI MODE Uses a MCI Driver for low level functions mci_init() Initialize the MCI controller mci_read_sect() Reads a sector from the Flash Memory Card (512 byte) mci_write_sect() Write a sector to the Flash Memory Card (512 byte) mci_read_config() Reads Memory Card configuration Memory Card is handled in hardware Communication in Native mode is faster than in SPI mode – MCI Driver: MCI_LPC23xx.c 4-17