From 3b2b01c37583727025ffdc39bf7d3a5920a1da50 Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Mon, 31 Dec 2012 06:07:04 +0000 Subject: [PATCH] 1. fix bug in uffs_nandif.c to work with mtd nand driver; 2)clean code in uffs_nandif.c and dfs_uffs.h git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2575 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/dfs/filesystems/uffs/dfs_uffs.h | 19 +++++-------- components/dfs/filesystems/uffs/uffs_nandif.c | 28 +++++++++---------- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/components/dfs/filesystems/uffs/dfs_uffs.h b/components/dfs/filesystems/uffs/dfs_uffs.h index a15cc58754..83b4735f3f 100644 --- a/components/dfs/filesystems/uffs/dfs_uffs.h +++ b/components/dfs/filesystems/uffs/dfs_uffs.h @@ -11,32 +11,26 @@ #include "uffs_config.h" #include "uffs/uffs_public.h" -//#define UFFS_BLOCK_MARK_SPARE_OFFSET 4 /* indicate block bad or good, offset in spare */ - -//#define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT -//#define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE +/* the UFFS ECC mode opitons */ +/* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO */ +/* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT */ +/* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE */ /* enable this ,you need provide a mark_badblock/check_block funciton */ -//#define RT_UFFS_USE_CHECK_MARK_FUNCITON +/* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */ #if RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT /* let uffs do soft ecc */ - #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */ -#define RT_CONFIG_UFFS_ECC_SIZE 0 /* if 0, then uffs will caculate a proper ecc size */ #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO /* nand driver make ecc and do ecc correct */ - #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_FLASH -#define RT_CONFIG_UFFS_ECC_SIZE 4 /* if 0, then uffs will caculate a proper ecc size */ #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE - #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */ -#define RT_CONFIG_UFFS_ECC_SIZE 0 /* if 0, then uffs will caculate a proper ecc size */ #else #error "uffs under rt-thread do not support this ECC mode" -#endif +#endif /* RT_CONFIG_UFFS_ECC_MODE */ #if (!CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR) #define RT_UFFS_MEMORY_ALLOCATOR 1 /* use system memory allocator */ @@ -67,4 +61,5 @@ extern void uffs_setup_storage( struct uffs_StorageAttrSt *attr, struct rt_mtd_nand_device * nand); +extern int dfs_uffs_init(void); #endif /* DFS_UFFS_H_ */ diff --git a/components/dfs/filesystems/uffs/uffs_nandif.c b/components/dfs/filesystems/uffs/uffs_nandif.c index 98131e4039..3db174c7c9 100644 --- a/components/dfs/filesystems/uffs/uffs_nandif.c +++ b/components/dfs/filesystems/uffs/uffs_nandif.c @@ -143,13 +143,13 @@ void uffs_setup_storage( rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt)); // attr->total_blocks = nand->end_block - nand->start_block + 1;/* no use */ - attr->page_data_size = nand->page_size; /* page data size */ - attr->pages_per_block = nand->pages_per_block; /* pages per block */ - attr->spare_size = nand->oob_size; /* page spare size */ - attr->block_status_offs = UFFS_BLOCK_MARK_SPARE_OFFSET; /* block status offset is 5th byte in spare */ - attr->ecc_opt = RT_CONFIG_UFFS_ECC_MODE; /* ecc option */ - attr->ecc_size = RT_CONFIG_UFFS_ECC_SIZE; /* ecc size */ - attr->layout_opt = RT_CONFIG_UFFS_LAYOUT; /* let UFFS do the spare layout */ + attr->page_data_size = nand->page_size; /* page data size */ + attr->pages_per_block = nand->pages_per_block; /* pages per block */ + attr->spare_size = nand->oob_size; /* page spare size */ + attr->ecc_opt = RT_CONFIG_UFFS_ECC_MODE; /* ecc option */ + attr->ecc_size = 0; /* ecc size is 0 , the uffs will calculate the ecc size*/ + attr->block_status_offs = attr->ecc_size; /* indicate block bad or good, offset in spare */ + attr->layout_opt = RT_CONFIG_UFFS_LAYOUT; /* let UFFS do the spare layout */ } #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO @@ -316,13 +316,13 @@ void uffs_setup_storage( rt_memset(attr, 0, sizeof(struct uffs_StorageAttrSt)); // attr->total_blocks = nand->end_block - nand->start_block + 1;/* no use */ - attr->page_data_size = nand->page_size; /* page data size */ - attr->pages_per_block = nand->pages_per_block; /* pages per block */ - attr->spare_size = nand->oob_size; /* page spare size */ - attr->ecc_opt = RT_CONFIG_UFFS_ECC_MODE; /* ecc option */ - attr->ecc_size = nand->oob_size-nand->oob_free;//RT_CONFIG_UFFS_ECC_SIZE; /* ecc size */ - attr->block_status_offs = attr->ecc_size;//UFFS_BLOCK_MARK_SPARE_OFFSET; /* block status offset is 5th byte in spare */ - attr->layout_opt = RT_CONFIG_UFFS_LAYOUT; /* let UFFS do the spare layout */ + attr->page_data_size = nand->page_size; /* page data size */ + attr->pages_per_block = nand->pages_per_block; /* pages per block */ + attr->spare_size = nand->oob_size; /* page spare size */ + attr->ecc_opt = RT_CONFIG_UFFS_ECC_MODE; /* ecc option */ + attr->ecc_size = nand->oob_size-nand->oob_free; /* ecc size */ + attr->block_status_offs = attr->ecc_size; /* indicate block bad or good, offset in spare */ + attr->layout_opt = RT_CONFIG_UFFS_LAYOUT; /* let UFFS do the spare layout */ /* calculate the ecc layout array */ hw_flash_data_layout[0] = attr->ecc_size + 1; /* ecc size + 1byte block status */ -- GitLab