提交 3b2b01c3 编写于 作者: G goprife@gmail.com

1. fix bug in uffs_nandif.c to work with mtd nand driver; 2)clean code in...

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
上级 e56e9a26
......@@ -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_ */
......@@ -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 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册