1 /* 2 * Copyright (c) 2015, Armink, <armink.ztl@gmail.com> 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * 'Software'), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject to 10 * the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 * 23 * Function: It is the configure head file for this library. 24 * Created on: 2015-07-14 25 */ 26 #ifndef _EF_CFG_H_ 27 #define _EF_CFG_H_ 28 29 /* using ENV function */ 30 #define EF_USING_ENV 31 32 /* using wear leveling mode for ENV */ 33 /* #define EF_ENV_USING_WL_MODE */ 34 35 /* using power fail safeguard mode for ENV */ 36 #define EF_ENV_USING_PFS_MODE 37 38 /* using IAP function */ 39 //#define EF_USING_IAP 40 41 /* using save log function */ 42 //#define EF_USING_LOG 43 44 /* the minimum size of flash erasure */ 45 #define EF_ERASE_MIN_SIZE 4096 46 47 /** 48 * 49 * This all Backup Area Flash storage index. All used flash area configure is under here. 50 * |----------------------------| Storage Size 51 * | Environment variables area | ENV area size @see ENV_AREA_SIZE 52 * | 1.system section | ENV_SYSTEM_SIZE 53 * | 2:data section | ENV_AREA_SIZE - ENV_SYSTEM_SIZE 54 * |----------------------------| 55 * | Saved log area | Log area size @see LOG_AREA_SIZE 56 * |----------------------------| 57 * |(IAP)Downloaded application | IAP already downloaded application, unfixed size 58 * |----------------------------| 59 * 60 * @note all area size must be aligned with EF_ERASE_MIN_SIZE 61 * @note EasyFlash will use ram to buffered the ENV. At some time flash's EF_ERASE_MIN_SIZE is so big, 62 * and you want use ENV size is less than it. So you must defined ENV_USER_SETTING_SIZE for ENV. 63 * @note ENV area size has some limitations in different modes. 64 * 1.Normal mode: no more limitations 65 * 2.Wear leveling mode: system section will used an flash section and the data section will used at least 2 flash sections 66 * 3.Power fail safeguard mode: ENV area will has an backup. It is twice as normal mode. 67 * 4.wear leveling and power fail safeguard mode: The required capacity will be 2 times the total capacity in wear leveling mode. 68 * For example: 69 * The EF_ERASE_MIN_SIZE is 128K and the ENV_USER_SETTING_SIZE: 2K. The ENV_AREA_SIZE in different mode you can define 70 * 1.Normal mode: 1*EF_ERASE_MIN_SIZE 71 * 2.Wear leveling mode: 3*EF_ERASE_MIN_SIZE (It has 2 data section to store ENV. So ENV can erase at least 200,000 times) 72 * 3.Power fail safeguard mode: 2*EF_ERASE_MIN_SIZE 73 * 4.Wear leveling and power fail safeguard mode: 6*EF_ERASE_MIN_SIZE 74 * @note the log area size must be more than twice of EF_ERASE_MIN_SIZE 75 */ 76 /* backup area start address */ /* start address of param partition */ 77 #define EF_START_ADDR 0x3FA000 //(0x400000 - 12*2*1024) //(0x1FC000) 78 79 /* the user setting size of ENV, must be word alignment */ 80 #define ENV_USER_SETTING_SIZE (12 * 1024 - 20)//(8 * 1024 - 20) 81 82 #ifndef EF_ENV_USING_PFS_MODE 83 #ifndef EF_ENV_USING_WL_MODE 84 /* ENV area total bytes size in normal mode. */ 85 #define ENV_AREA_SIZE (1 * EF_ERASE_MIN_SIZE) /* 4K */ 86 #else 87 /* ENV area total bytes size in wear leveling mode. */ 88 #define ENV_AREA_SIZE (4 * EF_ERASE_MIN_SIZE) /* 16K */ 89 #endif 90 #else 91 #ifndef EF_ENV_USING_WL_MODE 92 /* ENV area total bytes size in power fail safeguard mode. */ 93 #define ENV_AREA_SIZE ((12*2/4) * EF_ERASE_MIN_SIZE) /* 16K */ 94 #else 95 /* ENV area total bytes size in wear leveling and power fail safeguard mode. */ 96 #define ENV_AREA_SIZE (6 * EF_ERASE_MIN_SIZE) /* 24K */ 97 #endif 98 #endif 99 /* saved log area size */ 100 #define LOG_AREA_SIZE (254 * EF_ERASE_MIN_SIZE) /* 1016K */ 101 102 /* print debug information of flash */ 103 //#define PRINT_DEBUG 104 105 #endif /* EF_CFG_H_ */ 106