#define TOTAL_SIZE (BLOCK_SIZE * TOTAL_BLOCKS) #define MAX_MOUNT_TABLES 10 #define MAX_MOUNT_POINT_NAME 32 static uffs_Device demo_device = {0}; static struct uffs_MountTableEntrySt demo_mount = { &demo_device, 0, /* start from block 0 */ -1, /* use whole chip */ "/", /* mount point */ NULL }; /* static alloc the memory */ static int static_buffer_pool[UFFS_STATIC_BUFF_SIZE(PAGES_PER_BLOCK, PAGE_SIZE, TOTAL_BLOCKS) / sizeof(int)]; static void setup_storage(struct uffs_StorageAttrSt *attr) { attr->total_blocks = TOTAL_BLOCKS; /* total blocks */ attr->page_data_size = PAGE_DATA_SIZE; /* page data size */ attr->spare_size = PAGE_SPARE_SIZE; /* page spare size */ attr->pages_per_block = PAGES_PER_BLOCK; /* pages per block */ attr->block_status_offs = 4; /* block status offset is 5th byte in spare */ attr->ecc_opt = UFFS_ECC_SOFT; /* use UFFS software ecc */ attr->layout_opt = UFFS_LAYOUT_UFFS; /* let UFFS do the spare layout */ } static void setup_device(uffs_Device *dev) {
struct my_nand_chip g_nand_chip = {0}; static struct uffs_StorageAttrSt g_my_flash_storage = {0}; /* define mount table */ static uffs_Device demo_device_1 = {0}; static uffs_Device demo_device_2 = {0}; static uffs_MountTable demo_mount_table[] = { { &demo_device_1, 0, PAR_1_BLOCKS - 1, "/data/" }, { &demo_device_2, PAR_1_BLOCKS, PAR_1_BLOCKS + PAR_2_BLOCKS - 1, "/" }, { NULL, 0, 0, NULL } }; /* static alloc the memory for each partition */ static int static_buffer_par1[UFFS_STATIC_BUFF_SIZE(PAGES_PER_BLOCK, PAGE_SIZE, PAR_1_BLOCKS) / sizeof(int)]; static int static_buffer_par2[UFFS_STATIC_BUFF_SIZE(PAGES_PER_BLOCK, PAGE_SIZE, PAR_2_BLOCKS) / sizeof(int)];; static void init_nand_chip(struct my_nand_chip *chip) { // init chip IO address, etc. } static void setup_flash_storage(struct uffs_StorageAttrSt *attr) { memset(attr, 0, sizeof(struct uffs_StorageAttrSt)); attr->total_blocks = TOTAL_BLOCKS; /* total blocks */ attr->page_data_size = PAGE_DATA_SIZE; /* page data size */ attr->pages_per_block = PAGES_PER_BLOCK; /* pages per block */ attr->spare_size = PAGE_SPARE_SIZE; /* page spare size */
} #endif // defined(_OBC_ROM_) #endif // WITH_STORAGE #if ENABLE_FLASH_FS /* UFFS includes */ #include <uffs/uffs_utils.h> #include <uffs/uffs_mtb.h> #include <uffs/uffs_fd.h> #include <uffs/uffs_config.h> /** Static memory buffer for UFFS */ #ifdef ENABLE_FLASH_FS #include <uffs/at49bv320dt.h> int flash_static_buffer[UFFS_STATIC_BUFF_SIZE(FLASH_PAGES_PER_BLOCK, FLASH_PAGE_SIZE, FLASH_PAR_BLOCKS) / sizeof(int)]; extern struct uffs_StorageAttrSt flash_storage; uffs_Device flash_device = {.Init = flash_init_device, .Release = flash_release_device, .attr = &flash_storage}; uffs_MountTable flash_table = {.dev = &flash_device, .start_block = FLASH_FS_FIRST_BLOCK, .end_block = FLASH_FS_LAST_BLOCK, .mount = "/boot/"}; #endif #if ENABLE_DF #include <uffs/at45db642d.h> int df_static_buffer[UFFS_STATIC_BUFF_SIZE(DF_PAGES_PER_BLOCK, DF_PAGE_SIZE, DF_PAR_BLOCKS) / sizeof(int)]; extern struct uffs_StorageAttrSt df_storage; uffs_Device df_device = {.Init = df_init_device, .Release = df_release_device, .attr = &df_storage}; uffs_MountTable df_table = {.dev = &df_device, .start_block = DF_FS_FIRST_BLOCK, .end_block = DF_FS_LAST_BLOCK, .mount = "/data/"}; #endif #endif void vTaskInit(void * pvParameters __attribute__((unused))) {