diff options
| author | [email protected] <[email protected]> | 2012-12-30 03:26:34 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-12-30 03:26:34 +0000 |
| commit | 799ecf48c627b1879353bd789ce1212640daac5f (patch) | |
| tree | b4072ef71f781e931a58fa316ea8803d62022c2c | |
| parent | a3b5fa587080ef442563b37da412336897ff53dd (diff) | |
update uffs so it can work with mtd interface.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2558 bbd45198-f89e-11dd-88c7-29a3b14d5316
| -rw-r--r-- | components/dfs/filesystems/uffs/dfs_uffs.h | 2 | ||||
| -rw-r--r-- | components/dfs/filesystems/uffs/uffs_nandif.c | 25 |
2 files changed, 19 insertions, 8 deletions
diff --git a/components/dfs/filesystems/uffs/dfs_uffs.h b/components/dfs/filesystems/uffs/dfs_uffs.h index 650ea2cfbb..a15cc58754 100644 --- a/components/dfs/filesystems/uffs/dfs_uffs.h +++ b/components/dfs/filesystems/uffs/dfs_uffs.h @@ -11,7 +11,7 @@ #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 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
diff --git a/components/dfs/filesystems/uffs/uffs_nandif.c b/components/dfs/filesystems/uffs/uffs_nandif.c index 1c9f5c88f2..98131e4039 100644 --- a/components/dfs/filesystems/uffs/uffs_nandif.c +++ b/components/dfs/filesystems/uffs/uffs_nandif.c @@ -303,10 +303,10 @@ const uffs_FlashOps nand_ops = nand_erase_block, /* EraseBlock() */
};
-const rt_uint8_t k9fxg08_data_layout[UFFS_SPARE_LAYOUT_SIZE] =
+static rt_uint8_t hw_flash_data_layout[UFFS_SPARE_LAYOUT_SIZE] =
{0x05, 0x08, 0xFF, 0x00};
-const rt_uint8_t k9fxg08_ecc_layout[UFFS_SPARE_LAYOUT_SIZE] =
+static rt_uint8_t hw_flash_ecc_layout[UFFS_SPARE_LAYOUT_SIZE] =
{0x00, 0x04, 0xFF, 0x00};
void uffs_setup_storage(
@@ -317,16 +317,27 @@ void uffs_setup_storage( // 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->block_size / nand->page_size ; /* pages per block */
+ 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->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 */
+ /* calculate the ecc layout array */
+ hw_flash_data_layout[0] = attr->ecc_size + 1; /* ecc size + 1byte block status */
+ hw_flash_data_layout[1] = 0x08;
+ hw_flash_data_layout[2] = 0xFF;
+ hw_flash_data_layout[3] = 0x00;
+
+ hw_flash_ecc_layout[0] = 0;
+ hw_flash_ecc_layout[1] = attr->ecc_size;
+ hw_flash_ecc_layout[2] = 0xFF;
+ hw_flash_ecc_layout[3] = 0x00;
+
/* initialize _uffs_data_layout and _uffs_ecc_layout */
- rt_memcpy(attr->_uffs_data_layout, k9fxg08_data_layout, UFFS_SPARE_LAYOUT_SIZE);
- rt_memcpy(attr->_uffs_ecc_layout, k9fxg08_ecc_layout, UFFS_SPARE_LAYOUT_SIZE);
+ rt_memcpy(attr->_uffs_data_layout, hw_flash_data_layout, UFFS_SPARE_LAYOUT_SIZE);
+ rt_memcpy(attr->_uffs_ecc_layout, hw_flash_ecc_layout, UFFS_SPARE_LAYOUT_SIZE);
attr->data_layout = attr->_uffs_data_layout;
attr->ecc_layout = attr->_uffs_ecc_layout;
|
