1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2012-03-30 prife the first version 9 */ 10 11 #ifndef DFS_UFFS_H_ 12 #define DFS_UFFS_H_ 13 14 #include "uffs_config.h" 15 #include "uffs/uffs_public.h" 16 17 /* the UFFS ECC mode opitons */ 18 #ifndef RT_UFFS_ECC_MODE 19 #define RT_UFFS_ECC_MODE 1 20 #endif 21 22 /* 23 * RT_UFFS_ECC_MODE: 24 * 0, Do not use ECC 25 * 1, UFFS calculate the ECC 26 * 2, Flash driver(or by hardware) calculate the ECC 27 * 3, Hardware calculate the ECC and automatically write to spare. 28 */ 29 #if RT_UFFS_ECC_MODE == 0 30 #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE 31 #elif RT_UFFS_ECC_MODE == 1 32 #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT 33 #elif RT_UFFS_ECC_MODE == 2 34 #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW 35 #elif RT_UFFS_ECC_MODE == 3 36 #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO 37 #endif 38 39 /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_HW_AUTO */ 40 /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_SOFT */ 41 /* #define RT_CONFIG_UFFS_ECC_MODE UFFS_ECC_NONE */ 42 43 /* enable this ,you need provide a mark_badblock/check_block funciton */ 44 /* #define RT_UFFS_USE_CHECK_MARK_FUNCITON */ 45 46 #if RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT /* let uffs do soft ecc */ 47 #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */ 48 49 #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO /* nand driver make ecc and do ecc correct */ 50 #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_FLASH 51 52 #elif RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_NONE 53 #define RT_CONFIG_UFFS_LAYOUT UFFS_LAYOUT_UFFS /* UFFS_LAYOUT_FLASH */ 54 55 #else 56 #error "uffs under rt-thread do not support this ECC mode" 57 #endif /* RT_CONFIG_UFFS_ECC_MODE */ 58 59 #if (!CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR) 60 #define RT_UFFS_MEMORY_ALLOCATOR 1 /* use system memory allocator */ 61 #elif (CONFIG_USE_STATIC_MEMORY_ALLOCATOR) && (!CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR) 62 #define RT_UFFS_MEMORY_ALLOCATOR 0 /* use static memory allocator */ 63 #else 64 #error "UFFS: CONFIG_USE_STATIC_MEMORY_ALLOCATOR ,CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR are invalid!" 65 #endif 66 67 #if CONFIG_USE_STATIC_MEMORY_ALLOCATOR > 0 68 #error "dfs_uffs only support CONFIG_USE_SYSTEM_MEMORY_ALLOCATOR" 69 #endif 70 71 #if defined(CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME) 72 #error "dfs_uffs not support CONFIG_UFFS_AUTO_LAYOUT_USE_MTD_SCHEME" 73 #endif 74 75 #if (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_HW_AUTO) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_FLASH) 76 #error "when use UFFS_ECC_HW_AUTO, you must use UFFS_LAYOUT_FLASH" 77 78 #elif (RT_CONFIG_UFFS_ECC_MODE == UFFS_ECC_SOFT) && (RT_CONFIG_UFFS_LAYOUT != UFFS_LAYOUT_UFFS) 79 #warning "when use UFFS_ECC_SOFT, it is recommended to use UFFS_LAYOUT_UFFS" 80 #endif 81 82 extern const uffs_FlashOps nand_ops; 83 84 extern void uffs_setup_storage( 85 struct uffs_StorageAttrSt *attr, 86 struct rt_mtd_nand_device * nand); 87 88 extern int dfs_uffs_init(void); 89 #endif /* DFS_UFFS_H_ */ 90