Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

The following section shows an example on how to get started in a typical case comprising the following:

  • The generic controller layer implementation (included with the NAND driver)
  • The 1-bit software ECC implementation (included with the NAND driver)
  • The static part layer implementation (included with the NAND driver)
  • Your BSP layer implementation to adapt the driver to your specific platform
  • In case you need additional information and details regarding the different layers, please refer to the section 15-2 “Architecture Overview”.

    To use the NAND driver, you must include the following ten files in the build, in addition to the generic file system files:

  • fs_dev_nand.c (\Micrium\Software\uC-FS\Dev\NAND.)
  • fs_dev_nand.h (\Micrium\Software\uC-FS\Dev\NAND.)
  • fs_dev_nand_ctrlr_gen.c (\Micrium\Software\uC-FS\Dev\NAND\Ctrlr)
  • fs_dev_nand_ctrlr_gen.h (\Micrium\Software\uC-FS\Dev\NAND\Ctrlr)
  • fs_dev_nand_part_static.c (\Micrium\Software\uC-FS\Dev\NAND\Part)
  • fs_dev_nand_part_static.h (\Micrium\Software\uC-FS\Dev\NAND\Part)
  • ecc_hamming.c (\Micrium\Software\uC-CRC\Source)
  • ecc_hamming.h (\Micrium\Software\uC-CRC\Source)
  • ecc.h (\Micrium\Software\uC-CRC\Source)
  • Your BSP layer implementation (derived from fs_dev_nand_ctrlr_gen_bsp.c in \Micrium\Software\uC-FS\Dev\NAND\BSP\Template).
  • The example in Listing 15-1 shows how to open a single NAND volume. The file system initialization function (FS_Init()) must have previously been called.

    Listing 15-1 Opening a NAND device volume

    L15-1(1) Declare and initialize configuration structures. Structures should be initialized to allow for forward compatibility in case some new fields in those structures are added in future µC/FS versions.

    L15-1(2) Register the NAND device driver FS_NAND.

    L15-1(3) The NAND part layer configuration structure should be initialized. For more information about these parameters, see section “Statically configured part layer”.

    L15-1(4) The NAND controller layer configuration structure should be initialized. For more information about these parameters, see section 15-4-1 “Generic Controller Layer Implementation”. Please note that you might need to use a different controller layer. If this is the case, the configuration might be different (see section 15-4 “Controller Layer”).

    L15-1(5) The NAND generic controller software ECC extension should be initialized. For more information about these parameters, see section “Generic Controller Extension Layer”. Please note that if you are using a different controller layer implementation, there probably won’t be a controller extension layer. Also, if using the generic controller, you might need to use a different extension. Refer to section “Generic Controller Extension Layer” for a list of available controller extensions.

    L15-1(6) The NAND translation layer structure should be initialized. For more information about these parameters, see section 15-3-1 “Translation Layer Configuration”.

    L15-1(7) FSDev_Open() opens/initializes a file system device. The parameters are the device name (a) and a pointer to a device driver-specific configuration structure (b). The device name (a) is composed of a device driver name (“nand”), a single colon, an ASCII-formatted integer (the unit number) and another colon.

    L15-1(8) FS_NAND_LowFmt() low-level formats a NAND. If the NAND has never been used with µC/FS, it must be low-level formatted before being used. Low-level formatting will create and initialize the low-level driver metadata on the device.

    L15-1(9) FSVol_Open() opens/mounts a volume. The parameters are the volume name (a), the device name (b) and the index of the partition that will be opened (c). There is no restriction on the volume name (a); however, it is typical to give the volume the same name as the underlying device. If the default partition is to be opened, or if the device is not partition, then the partition number (c) should be 0.

    L15-1(10) FSVol_Fmt() formats a file system device. If the NAND has just been low-level formatted, there will be no file system on the corresponding volume after it is opened (it will be unformatted). The volume must be formatted before files can be created or accessed.

    If the NAND initialization succeeds, the file system traces (if a sufficiently high trace level is configured) will produce an output similar to Listing 15-1. See section E-9 “Trace Configuration” about configuring the trace level.

    Listing 15-2 NAND detection trace output

    Handling different use-cases

    If the above example does not apply to your situation, we strongly recommend you read the sections about the different layers. This will help you determine if other existing implementations are suitable for you, or if you need to develop your own implementation of some of those layers.

    • No labels