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
This commit is contained in:
goprife@gmail.com 2012-12-30 03:26:34 +00:00
parent a3b5fa5870
commit 799ecf48c6
2 changed files with 19 additions and 8 deletions

View File

@ -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

View File

@ -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;