µC/FS Directories and Files

µC/FS is fairly easy to use once you understand which source files are needed to make up a µC/FS-based application. This chapter will discuss the modules available for µC/FS and how everything fits together.

Figure - uC/FS Architecture shows the µC/FS architecture and its relationship with the hardware. Memory devices may include actual media both removable (SD/MMC, CF cards) and fixed (NAND flash, NOR flash) as well as any controllers for such devices. Of course, your hardware would most likely contain other devices such as UARTs (Universal Asynchronous Receiver Transmitters), ADCs (Analog to Digital Converters) and Ethernet controller(s). Moreover, your application may include other middleware components like an OS kernel, networking (TCP/IP) stack or USB stack that may integrate with µC/FS.

A Windows™-based development platform is assumed. The directories and files make references to typical Windows-type directory structures. However, since µC/FS is available in source form then it can certainly be used on Unix, Linux or other development platforms. This, of course, assumes that you are a valid µC/FS licensee in order to obtain the source code.

The names of the files are shown in upper case to make them ‘stand out’. The file names, however, are actually lower case.

Figure - µC/FS Architecture

(1) The application code consist of project or product files. For convenience, we simply called these app.c and app.h but your application can contain any number of files and they do not have to be called app.*. The application code is typically where you would find main().

(2) Quite often, semiconductor manufacturers provide library functions in source form for accessing the peripherals on their CPU (Central Processing Unit) or MCU (Micro Controller Unit). These libraries are quite useful and often save valuable time. Since there is no naming convention for these files, *.c and *.h are assumed.

(3) The Board Support Package (BSP) is code that you would typically write to interface to peripherals on your target board. For example you can have code to turn on and off LEDs (light emitting diodes), functions to turn on and off relays, and code to read switches and temperature sensors.

(4) µC/CPU is an abstraction of basic CPU-specific functionality. These files define functions to disable and enable interrupts, data types (e.g., CPU_INT08UCPU_FP32) independent of the CPU and compiler and many more functions.

(5) µC/LIB consists of a group of source files to provide common functions for memory copy, string manipulation and character mapping. Some of the functions replace stdlib functions provided by the compiler. These are provided to ensure that they are fully portable from application to application and (most importantly) from compiler to compiler.

(6) µC/Clk is an independant clock/calendar management module, with source code for easily managing date and time in a product. µC/FS uses the date and time information from µC/Clk to update files and directories with the proper creation/modification/access time.

(7) µC/CRC is a stand-alone module for calculating checksums and error correction codes. This module is used by some of µC/FS device drivers.

(8) This is the µC/FS platform-independent code, free of dependencies on CPU and memory device. This code is written in highly-portable ANSI C code. This code is only available to µC/FS licensees.

(9) This is the µC/FS system driver for FAT file systems. This code is only available to µC/FS licensees.

(10) This is the collection of device drivers for µC/FS. Each driver supports a certain device type, such as SD/MMC cards, NAND flash or NOR flash. Drivers are only available to µC/FS licensees.

(11) This is the µC/FS code that is adapted to a specific platform. It consists of small code modules written for specific drivers called ports that must be adapted to the memory device controllers or peripherals integrated into or attached to the CPU. The requirements for these ports are described in Appendix C, Porting Manual.

(12) µC/FS does not require an RTOS. However, if µC/FS is used with an RTOS, a set of functions must be implemented to prevent simultaneous access of devices and core µC/FS structures by multiple tasks.

(13) This µC/FS configuration file defines which µC/FS features (fs_cfg.h) are included in the application.


Application Code

When Micriµm provides you with example projects, we typically place those in a directory structure as shown below. Of course, you can use whatever directory structure suits your project/product.

\Micrium
  \Software
    \EvalBoards
      \<manufacturer>
        \<board name>
          \<compiler>
            \<project name>
              \*.*
 
\Micrium

This is where we place all software components and projects provided by Micriµm. This directory generally starts from the root directory of your computer.

\Software

This sub-directory contains all the software components and projects.

\EvalBoards

This sub-directory contains all the projects related to the evaluation boards supported by Micriµm.

\<manufacturer>

Is the name of the manufacturer of the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\<board name>

This is the name of the evaluation board. A board from Micriµm will typically be called uC-Eval-xxxx where ‘xxxx’ will represent the CPU or MCU used on the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\<compiler>

This is the name of the compiler or compiler manufacturer used to build the code for the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\<project name>

This is the name of the project that will be demonstrated. For example a simple µC/FS project might have a project name of ‘FS-Ex1’. The ‘-Ex1’ represents a project containing only µC/FS. A project name of FS-Probe-Ex1 would represent a project containing µC/FS as well as µC/Probe. The ‘<’ and ‘>’ are not part of the actual name.

\*.*

These are the source files for the project/product. You are certainly welcomed to call the main files APP*.* for your own projects but you don’t have to. This directory also contains the configuration file FS_CFG.H and other files as needed by the project.

Board Support Package (BSP)

 

The BSP is generally found with the evaluation or target board because the BSP is specific to that board. In fact, if well written, the BSP should be used for multiple projects.

\Micrium
  \Software
    \EvalBoards
      \<manufacturer>
        \<board name>
          \<compiler>
            \BSP
              \*.*
 
\Micrium

This is where we place all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\EvalBoards

This sub-directory contains all the projects related to evaluation boards.

\<manufacturer>

Is the name of the manufacturer of the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\<board name>

This is the name of the evaluation board. A board from Micriµm will typically be called uC Eval xxxx where ‘xxxx’ will be the name of the CPU or MCU used on the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\<compiler>

This is the name of the compiler or compiler manufacturer used to build the code for the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

\BSP

This directory is always called BSP.

\*.*

These are the source files of the BSP. Typically all the file names start with BSP_ but they don’t have to. It’s thus typical to find bsp.c and bsp.h in this directory. Again, the BSP code should contain functions such as LED control functions, initialization of timers, interface to Ethernet controllers and more.

µC/CPU Specific Source Code

µC/CPU consists of files that encapsulate common CPU-specific functionality as well as CPU- and compiler-specific data types.

\Micrium
  \Software
    \uC-CPU
        \CPU_CORE.C  
        \CPU_CORE.H  
        \CPU_DEF.H  
      \Cfg\Template
          \CPU_CFG.H  
      \<architecture>
        \<compiler>
            \CPU.H  
            \CPU_A.ASM  
            \CPU_C.C  
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-CPU

This is the main µC/CPU directory.

cpu_core.c contains C code that is common to all CPU architectures. Specifically, this file contains functions to measure the interrupt disable time of the CPU_CRITICAL_ENTER() andCPU_CRITICAL_EXIT() macros, a function that emulates a count leading zeros instruction and a few other functions.

cpu_core.h contains the function prototypes of the functions provided in cpu_core.c as well as allocation of the variables used by this module to measure interrupt disable time.

cpu_def.h contains miscellaneous #define constants used by the µC/CPU module.

\Cfg\Template

This directory contains a configuration template file (cpu_cfg.h) that you will need to copy to your application directory in order to configure the µC/CPU module based on your application requirements.

cpu_cfg.h determines whether you will enable measurement of the interrupt disable time, whether your CPU implements a count leading zeros instruction in assembly language or whether it will need to be emulated in C and more.

\<architecture>

This is the name of the CPU architecture for which µC/CPU was ported to. The ‘<’ and ‘>’ are not part of the actual name.

\<compiler>

This is the name of the compiler or compiler manufacturer used to build the code for the µC/CPU port. The ‘<’ and ‘>’ are not part of the actual name.

The files in this directory contain the µC/CPU port.

cpu.h contains type definitions to make µC/FS and other modules independent of the CPU and compiler word sizes. Specifically, you will find the declaration of the CPU_INT16U,CPU_INT32UCPU_FP32 and many other data types. Also, this file specifies whether the CPU is a big- or little-endian machine and contains function prototypes for functions that are specific to the CPU architecture and more.

cpu_a.asm contains the assembly language functions to implement the code to disable and enable CPU interrupts, count leading zeros (if the CPU supports that instruction) and other CPU specific functions that can only be written in assembly language. This file could also contain code to enable caches, setup MPUs and MMU and more. The functions provided in this file are accessible from C.

cpu_c.c contains C code of functions that are specific to the specific CPU architecture but written in C for portability. As a general rule, if a function can be written in C then it should, unless there are significant performance benefits by writing it in assembly language.

µC/Lib Portable Library Functions

µC/LIB consists of library functions that are meant to be highly portable and not tied to any specific compiler. This was done to facilitate third party certification of Micriµm products.

\Micrium
  \Software
    \uC-LIB
      \lib_ascii.C
      \lib_ascii.H
      \lib_def.H
      \lib_math.C
      \lib_math.H
      \lib_mem.C
      \lib_mem.H
      \lib_str.C
      \lib_str.H
      \Cfg\Template
        \lib_cfg.H
      \Ports
        \<architecture>
          \<compiler>
            \lib_mem_a.asm
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-LIB

This is the main µC/LIB directory.

\Cfg\Template

This directory contains a configuration template file (lib_cfg.h) that must be copied to the application directory to configure the µC/LIB module based on application requirements.

lib_cfg.h determines whether to enable assembly-language optimization (assuming there is an assembly-language file for the processor, i.e. lib_mem_a.asm) and a few other #defines.

µC/Clk Time/Calendar Management

µC/Clk consists of functions that are meant to centralize time management in one independant module. This way, the same time info can be easily shared across all Micrium products.

\Micrium
  \Software
    \uC-Clk
      \Cfg
        \Template
          \clk_cfg.h
      \OS
        \<rtos_name>
          \clk_os.c
      \Source
        \clk.c
        \clk.h
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-Clk

This is the main µC/Clk directory.

\Cfg\Template

This directory contains a configuration template file (clk_cfg.h) that must be copied to the application directory to configure the µC/Clk module based on application requirements.

clk_cfg.h determines whether clock will be managed by the RTOS or in your application. A few other #defines are used to enable/disable some features of µC/Clk and to configure some parameteres, like the clock frequency.

\OS

This is the main OS directory.

\<rtos_name>

This is the directory that contains the file to perform RTOS abstraction. Note that the file for the selected RTOS abstraction layer must always be named clk_os.c.

µC/Clk has been tested with µC/OS-II, µC/OS-III and the RTOS layer files for these RTOS are found in the following directories:

\Micrium\Software\uC-Clk\OS\uCOS-II\clk_os.c

\Micrium\Software\uC-Clk\OS\uCOS-III\clk_os.c

\Source

This directory contains the CPU-independant source code for µC/Clk. All file in this directory should be included in the build (assuming the presence of the source code). Features that are not required will be compiled out based on the value of #define constants in clk_cfg.h.

µC/CRC Checksums and Error Correction Codes

µC/CRC consists of functions to compute different error detection and correction codes. The functions are speed-optimized to avoid the important impact on performances that these CPU-intensive calcutions may present.

\Micrium
  \Software
    \uC-CRC
      \Cfg
        \Template
          \crc_cfg.h
      \Ports
        \<architecture>
          \<compiler>
            \ecc_hamming_a.asm
            \edc_crc_a.asm
      \Source
        \edc_crc.h
        \edc_crc.c
        \ecc_hamming.h
        \ecc_hamming.c
        \ecc.h
        \crc_util.h
        \crc_util.c
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-CRC

This is the main µC/CRC directory.

\Cfg\Template

This directory contains a configuration template file (crc_cfg.h) that must be copied to the application directory to configure the µC/CRC module based on application requirements.

crc_cfg.h determines whether to enable assembly-language optimization (assuming there is an assembly-language file for the processor) and a few other #defines.

\<architecture>

The name of the CPU architecture that µC/CRC was ported to. The ‘<’ and ‘>’ are not part of the actual name.

\<compiler>

The name of the compiler or compiler manufacturer used to build code for the µC/CRC port. The ‘<’ and ‘>’ are not part of the actual name.

ecc_hamming_a.asm contains the assembly language functions to optimize the calculation speed of Hamming code.

edc_crc_a.asm contains the assembly language functions to optimize the calculation speed of CRC (cyclic redundancy checks).

\Source

This is the directory that contains all the CPU independent source code files. of µC/CRC.

µC/FS Platform-Independent Source Code

The files in these directories are available to µC/FS licensees (see Appendix H, Licensing Policy).

\Micrium
  \Software
    \uC-FS
      \APP\Template
        \fs_app.c
        \fs_app.h
      \Cfg\Template
        \fs_cfg.h
      \OS\Template
        \fs_os.c
        \fs_os.h
      \Source
        \fs_c
        \fs.h
        \fs_api.c
        \fs_api.h
        \fs_buf.c
        \fs_buf.h
        \fs_cache.c
        \fs_cache.h
        \fs_cfg_fs.h
        \fs_ctr.h
        \fs_def.h
        \fs_dev.c
        \fs_dev.h
        \fs_dir.c
        \fs_dir.h
        \fs_entry.c
        \fs_entry.h
        \fs_err.h
        \fs_file.c
        \fs_file.h
        \fs_inc.h
        \fs_partition.c
        \fs_partition.h
        \fs_sys.c
        \fs_sys.h
        \fs_type.h
        \fs_unicode.c
        \fs_unicode.h
        \fs_util.c
        \fs_util.h
        \fs_vol.c
        \fs_vol.h
 
\Micrium

This is where we place all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-FS

This is the main µC/FS directory.

\APP\Template

This directory contains a template of the code for initializing the file system.

\Cfg\Template

This directory contains a configuration template file (lib_cfg.h) that is required to be copied to the application directory to configure the µC/FS module based on application requirements.

fs_cfg.h specifies which features of µC/FS you want in your application. If µC/FS is provided in linkable object code format then this file will be provided to show you what features are available in the object file. See Appendix B, µC/FS Configuration Manual.

\Source

This directory contains the platform-independent source code for µC/FS. All the files in this directory should be included in your build (assuming you have the source code). Features that you don’t want will be compiled out based on the value of #define constants in fs_cfg.h.

fs.c/h contains core functionality for µC/FS including FS_Init() (called to initialize µC/FS) and FS_WorkingDirSet()/FS_WorkingDirGet() (used to get and set the working directory).

fs_api.c/h contains the code for the POSIX-compatible API. See Chapter x, API for details about the POSIX-compatible API.

fs_buf.c/h contains the code for the buffer management (used internally by µC/FS).

fs_dev.c/h contains code for device management. See Chapter x, Devices for details about devices.

fs_dir.c/h contains code for directory access. See Chapter x, Directories for details about directory access.

fs_entry.c/h contains code for entry access. See Chapter x, Entries for details about entry access.

fs_file.c/h contains code for file access. See Chapter x, Files for details about file access.

fs_inc.h is a master include file that includes all other include files.

fs_sys.c/h contains the code for system driver management (used internally by µC/FS).

fs_unicode.c/h contains the code for handling Unicode strings (used internally by µC/FS).

µC/FS FAT Filesystem Source Code

The files in these directories are available to µC/FS licensees (see Appendix H, Licensing Policy).

\Micrium
  \Software
    \uC-FS
      \FAT
        \fs_fat.c
        \fs_fat.h
        \fs_fat_dir.c
        \fs_fat_dir.h
        \fs_fat_entry.c
        \fs_fat_entry.h
        \fs_fat_fat12.c
        \fs_fat_fat12.h
        \fs_fat_fat16.c
        \fs_fat_fat16.h
        \fs_fat_fat32.c
        \fs_fat_fat32.h
        \fs_fat_file.c
        \fs_fat_file.h
        \fs_fat_journal.c
        \fs_fat_journal.h
        \fs_fat_lfn.c
        \fs_fat_lfn.h
        \fs_fat_sfn.c
        \fs_fat_sfn.h
        \fs_fat_type.h
 
\Micrium

This is where we place all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-FS

This is the main µC/FS directory.

\FAT

This directory contains the FAT system driver for µC/FS. All the files in this directory should be included in your build (assuming you have the source code).

µC/FS Memory Device Drivers

These files are generic drivers to use with differenty memory devices.

\Micrium
  \Software
    \uC-FS
      \Dev
        \MSC
          \fs_dev_msc.c
          \fs_dev_msc.h
        \NAND
          \fs_dev_nand.c
          \fs_dev_nand.h
          \Ctrlr
            \fs_dev_nand_ctrlr_gen.c
            \fs_dev_nand_ctrlr_gen.h
            \GenExt
              \fs_dev_nand_ctrlr_gen_soft_ecc.c
              \fs_dev_nand_ctrlr_gen_soft_ecc.h
              \fs_dev_nand_ctrlr_gen_micron_ecc.c
              \fs_dev_nand_ctrlr_gen_micron_ecc.h
          \Part
            \fs_dev_nand_part_static.c
            \fs_dev_nand_part_static.h
            \fs_dev_nand_part_onfi.c
            \fs_dev_nand_part_onfi.h
          \Cfg\Template
            \fs_dev_nand_cfg.h
          \BSP\Template
            \fs_dev_nand_ctrlr_gen_bsp.c
        \NOR
          \fs_dev_nor.c
          \fs_dev_nor.h
          \PHY
            \fs_dev_nor_amd_1x08.c
            \fs_dev_nor_amd_1x08.h
            \fs_dev_nor_amd_1x16.c
            \fs_dev_nor_amd_1x16.h
            \fs_dev_nor_intel.c
            \fs_dev_nor_intel.h
            \fs_dev_nor_sst25.c
            \fs_dev_nor_sst25.h
            \fs_dev_nor_sst39.c
            \fs_dev_nor_sst39.h
            \fs_dev_nor_stm25.c
            \fs_dev_nor_stm25.h
            \fs_dev_nor_stm29_1x08.c
            \fs_dev_nor_stm29_1x08.h
            \fs_dev_nor_stm29_1x16.c
            \fs_dev_nor_stm29_1x16.h
            \Template
              \fs_dev_nor_template.c
              \fs_dev_nor_template.h          
          \BSP\Template
            \fs_dev_nor_bsp.c
          \BSP\Template (SPI GPIO)
            \fs_dev_nor_bsp.c
          \BSP\Template (SPI)
            \fs_dev_nor_bsp.c
        \RAMDisk
          \fs_dev_ram.c
          \fs_dev_ram.h
        \SD
          \fs_dev_sd.c
          \fs_dev_sd.h
          \Card
            \fs_dev_sd_card.c
            \fs_dev_sd_card.h
            \BSP\Template
              \fs_dev_sd_card_bsp.c
          \SPI
            \fs_dev_sd_spi.c
            \fs_dev_sd_spi.h
            \BSP\Template
              \fs_dev_sd_spi.bsp.c
        \Template
          \fs_dev_template.c
          \fs_dev_template.h
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-FS

This is the main µC/FS directory.

\Dev

This is where you will find the device driver files for the storage devices you are planning on using.

\MSC

This directory contains the MSC (Mass Storage Class - USB drives) driver files.

fs_dev_msc.* are device driver for MSC devices. This driver is designed to work with µC/USB host stack.

For more details on this driver, please refer to MSC Driver.

\NAND

This directory contains the NAND driver files.

fs_dev_nand.* are the device driver for NAND devices. These files require a set of controller-layer functions (defined in a file named fs_dev_nand_ctrlr_<type>.*) as well as BSP functions specific to particular hardware and associated with chosen controller-layer (to be defined in a file named fs_dev_nand_ctrlr_<type>_bsp.c).

Note that in the case of the “generic” controller-layer implementation, some controller extensions files (defined in files named fs_dev_nand_ctrlr_<ext_name>.*) may also be required.

For more details on this driver, please refer to NAND Flash Driver.

\NOR

This directory contains the NOR driver files.

fs_dev_nor.* are the device driver for NOR devices. These files require a set of physical-layer functions (defined in a file name fs_dev_nor_<physical type>.*) as well as BSP functions (to be defined in a file named fs_dev_nor_bsp.c) to work with a particular hardware setup.

For more details on this driver, please refer to NOR Flash Driver.

\RAMDisk

This directory contains the RAM disk driver files.

fs_dev_ramdisk.* constitue the RAM disk driver.

For more details on this driver, please refer to RAM Disk Driver.

\SD

This directory contains the SD/MMC driver files.

fs_dev_sd.* are device driver for SD devices. Theses files require to be used with either the fs_dev_sd_spi.* (for SPI/one-wire mode) or fs_dev_sd_card.* (for Card/4-wires mode) files. These files require a set of BSP functions to be defined in a file named either fs_dev_sd_spi_bsp.c or fs_dev_sd_card_bsp.c to work with a particular hardware setup.

For more details on this driver, please refer to SD/MMC Drivers.

µC/FS Platform-Specific Source Code

These files are provided by the µC/FS device driver developer. See Chapter 17, Porting µC/FS. However, the µC/FS source code is delivered with port examples.

\Micrium
  \Software
    \uC-FS
      \Examples
        \BSP
          \Dev
            <memory type>
              <manufacturer>
                <board name>
                  \fs_dev_<memory type>_bsp.c
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-FS

This is the main µC/FS directory.

\Examples

This is where you will find the device driver BSP example files.

\Dev\<memory type>

This is where you will find the examples BSP for one memory type. The ‘<’ and ‘>’ are not part of the actual name. The memory types supported by µC/FS are the following: NAND, NOR, SD\CARD, SD\SPI.

\<manufacturer>

The name of the manufacturer of the evaluation board. The ‘<’ and ‘>’ are not part of the actual name.

µC/FS OS Abstraction Layer

This directory contains the RTOS abstraction layer which allows the use of µC/FS with nearly any commercial of in-house RTOS, or without any RTOS at all. The abstraction layer for the selected RTOS is placed in a sub-directory under OS as follows:

\Micrium
  \Software
    \uC-FS
      \OS
        \<rtos_name>
          \fs_os.c
          \fs_os.h
 
\Micrium

This directory contains all software components and projects provided by Micriµm.

\Software

This sub-directory contains all the software components and projects.

\uC-FS

This is the main µC/FS directory.

\OS

This is the main OS directory.

\<rtos_name>

This is the directory that contains the files to perform RTOS abstraction. Note that files for the selected RTOS abstraction layer must always be named fs_os.*.

µC/FS has been tested with µC/OS-II, µC/OS-III and without an RTOS. The RTOS layer files are found in the following directories:

\Micrium\Software\uC-Clk\OS\None\fs_os.*

 \Micrium\Software\uC-Clk\OS\Template\fs_os.*

 \Micrium\Software\uC-Clk\OS\uCOS-II\fs_os.*

 \Micrium\Software\uC-Clk\OS\uCOS-III\fs_os.*