TargetBFS Configuration
Overview
TargetBFS is configured using a set of #defines in the external include file “bsp.h”. To use TargetBFS on multiple target boards, the board support package for each board should have its own “bsp.h” file. The configuration definitions are listed and explained below.
BFS_NAND_FLASH and BFS_NOR_FLASH
Define either BFS_NAND_FLASH or BFS_NOR_FLASH to include support for either NAND or NOR flash memory, respectively. Only one can be defined.
BFS_BLK_SIZE
The number of bytes in the smallest erasable ‘chunk’ of flash memory. Its value depends on both the flash device and the system architecture. If two 16-bit wide NOR devices, each with a block size of 64KB, are used in parallel to present a 32-bit bus interface, then the block size is 128KB.
BFS_PAGE_SIZE
The number of bytes accessed by the driver read_page() and write_page() routines. For parallel NOR flash, it is usually set to 512 bytes. For SPI NOR and NAND flash, the page size is defined by the device. The page size should divide evenly into the block size, discussed above.
BFS_NUM_BLKS
The total number of erasable blocks assigned to the volume. Unless some of the flash is used for another purpose, this field is normally set to the entire number of erasable blocks in the device.
BFS_NUM_FILES
The compile-time limit on the number of files that can be created. For boot loader applications, it is usually a small number. This impacts the RAM footprint, as the file name and extents for each file are stored in RAM.
BFS_BOOT_FNAME
The name of an optional “boot file” whose data is written to consecutive reserved blocks at the beginning of flash memory. This is intended for storing a boot image. Except for the last page on the last block, no metadata is written on the boot blocks, so all other blocks and pages can be used to store bootable code.
The reserved boot blocks will be used when a file whose name matches BFS_BOOT_FNAME is opened and written to. To not reserve any blocks for a boot file, undefine BFS_BOOT_FNAME.
BFS_BOOT_BLKS
If BFS_BOOT_FNAME is defined, this is the number of erasable blocks reserved for the boot file and the number of blocks available for all other files is BFS_NUM_BLKS - BFS_BOOT_BLKS. Otherwise no boot blocks are reserved.
BFS_MAX_BAD (NAND only)
The maximum number of bad blocks specified to exist in the device over the course of its guaranteed lifetime. Bad blocks can exist in new devices and also appear randomly during device operation. This value should be determined from the device’s data sheet.
CACHE_LINE_SIZE
Used to align the buffer used in calls to the page read and page write routines. It can be 0 if your CPU doesn’t have a data cache. Otherwise, it ensures DMA transfers will have an aligned buffer address.