fota lib for mdot

Dependents:   UQ_LoraWAN

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers spiffs_config.h Source File

spiffs_config.h

00001 /*
00002  * spiffs_config.h
00003  *
00004  *  Created on: Jul 3, 2013
00005  *      Author: petera
00006  */
00007 
00008 #ifndef SPIFFS_CONFIG_H_
00009 #define SPIFFS_CONFIG_H_
00010 
00011 // ----------- 8< ------------
00012 // Following includes are for the linux test build of spiffs
00013 // These may/should/must be removed/altered/replaced in your target
00014 #include <stdio.h>
00015 #include <stdlib.h>
00016 #include <string.h>
00017 #include <stddef.h>
00018 // ----------- >8 ------------
00019 
00020 typedef signed int          s32_t;
00021 typedef unsigned int        u32_t;
00022 typedef signed short        s16_t;
00023 typedef unsigned short      u16_t;
00024 typedef signed char         s8_t;;
00025 typedef unsigned char       u8_t;
00026 
00027 // compile time switches
00028 
00029 // Set generic spiffs debug output call.
00030 #ifndef SPIFFS_DGB
00031 #define SPIFFS_DBG(...)
00032 #endif
00033 // Set spiffs debug output call for garbage collecting.
00034 #ifndef SPIFFS_GC_DGB
00035 #define SPIFFS_GC_DBG(...)
00036 #endif
00037 // Set spiffs debug output call for caching.
00038 #ifndef SPIFFS_CACHE_DGB
00039 #define SPIFFS_CACHE_DBG(...)
00040 #endif
00041 // Set spiffs debug output call for system consistency checks.
00042 #ifndef SPIFFS_CHECK_DGB
00043 #define SPIFFS_CHECK_DBG(...)
00044 #endif
00045 
00046 // Enable/disable API functions to determine exact number of bytes
00047 // for filedescriptor and cache buffers. Once decided for a configuration,
00048 // this can be disabled to reduce flash.
00049 #ifndef SPIFFS_BUFFER_HELP
00050 #define SPIFFS_BUFFER_HELP              0
00051 #endif
00052 
00053 // Enables/disable memory read caching of nucleus file system operations.
00054 // If enabled, memory area must be provided for cache in SPIFFS_mount.
00055 #ifndef  SPIFFS_CACHE
00056 #define SPIFFS_CACHE                    1
00057 #endif
00058 #if SPIFFS_CACHE
00059 // Enables memory write caching for file descriptors in hydrogen
00060 #ifndef  SPIFFS_CACHE_WR
00061 #define SPIFFS_CACHE_WR                 1
00062 #endif
00063 
00064 // Enable/disable statistics on caching. Debug/test purpose only.
00065 #ifndef  SPIFFS_CACHE_STATS
00066 #define SPIFFS_CACHE_STATS              0
00067 #endif
00068 #endif
00069 
00070 // Always check header of each accessed page to ensure consistent state.
00071 // If enabled it will increase number of reads, will increase flash.
00072 #ifndef SPIFFS_PAGE_CHECK
00073 #define SPIFFS_PAGE_CHECK               1
00074 #endif
00075 
00076 // Define maximum number of gc runs to perform to reach desired free pages.
00077 #ifndef SPIFFS_GC_MAX_RUNS
00078 #define SPIFFS_GC_MAX_RUNS              3
00079 #endif
00080 
00081 // Enable/disable statistics on gc. Debug/test purpose only.
00082 #ifndef SPIFFS_GC_STATS
00083 #define SPIFFS_GC_STATS                 0
00084 #endif
00085 
00086 // Garbage collecting examines all pages in a block which and sums up
00087 // to a block score. Deleted pages normally gives positive score and
00088 // used pages normally gives a negative score (as these must be moved).
00089 // To have a fair wear-leveling, the erase age is also included in score,
00090 // whose factor normally is the most positive.
00091 // The larger the score, the more likely it is that the block will
00092 // picked for garbage collection.
00093 
00094 // Garbage collecting heuristics - weight used for deleted pages.
00095 #ifndef SPIFFS_GC_HEUR_W_DELET
00096 #define SPIFFS_GC_HEUR_W_DELET          (5)
00097 #endif
00098 // Garbage collecting heuristics - weight used for used pages.
00099 #ifndef SPIFFS_GC_HEUR_W_USED
00100 #define SPIFFS_GC_HEUR_W_USED           (-1)
00101 #endif
00102 // Garbage collecting heuristics - weight used for time between
00103 // last erased and erase of this block.
00104 #ifndef SPIFFS_GC_HEUR_W_ERASE_AGE
00105 #define SPIFFS_GC_HEUR_W_ERASE_AGE      (50)
00106 #endif
00107 
00108 // Object name maximum length.
00109 #ifndef SPIFFS_OBJ_NAME_LEN
00110 #define SPIFFS_OBJ_NAME_LEN             (32)
00111 #endif
00112 
00113 // Size of buffer allocated on stack used when copying data.
00114 // Lower value generates more read/writes. No meaning having it bigger
00115 // than logical page size.
00116 #ifndef SPIFFS_COPY_BUFFER_STACK
00117 #define SPIFFS_COPY_BUFFER_STACK        (64)
00118 #endif
00119 
00120 // SPIFFS_LOCK and SPIFFS_UNLOCK protects spiffs from reentrancy on api level
00121 // These should be defined on a multithreaded system
00122 
00123 // define this to entering a mutex if you're running on a multithreaded system
00124 #ifndef SPIFFS_LOCK
00125 #define SPIFFS_LOCK(fs)
00126 #endif
00127 // define this to exiting a mutex if you're running on a multithreaded system
00128 #ifndef SPIFFS_UNLOCK
00129 #define SPIFFS_UNLOCK(fs)
00130 #endif
00131 
00132 
00133 // Enable if only one spiffs instance with constant configuration will exist
00134 // on the target. This will reduce calculations, flash and memory accesses.
00135 // Parts of configuration must be defined below instead of at time of mount.
00136 #ifndef SPIFFS_SINGLETON
00137 #define SPIFFS_SINGLETON 0
00138 #endif
00139 
00140 #if SPIFFS_SINGLETON
00141 // Instead of giving parameters in config struct, singleton build must
00142 // give parameters in defines below.
00143 #ifndef SPIFFS_CFG_PHYS_SZ
00144 #define SPIFFS_CFG_PHYS_SZ(ignore)        (1024*1024*2)
00145 #endif
00146 #ifndef SPIFFS_CFG_PHYS_ERASE_SZ
00147 #define SPIFFS_CFG_PHYS_ERASE_SZ(ignore)  (65536)
00148 #endif
00149 #ifndef SPIFFS_CFG_PHYS_ADDR
00150 #define SPIFFS_CFG_PHYS_ADDR(ignore)      (0)
00151 #endif
00152 #ifndef SPIFFS_CFG_LOG_PAGE_SZ
00153 #define SPIFFS_CFG_LOG_PAGE_SZ(ignore)    (256)
00154 #endif
00155 #ifndef SPIFFS_CFG_LOG_BLOCK_SZ
00156 #define SPIFFS_CFG_LOG_BLOCK_SZ(ignore)   (65536)
00157 #endif
00158 #endif
00159 
00160 // Set SPFIFS_TEST_VISUALISATION to non-zero to enable SPIFFS_vis function
00161 // in the api. This function will visualize all filesystem using given printf
00162 // function.
00163 #ifndef SPIFFS_TEST_VISUALISATION
00164 #define SPIFFS_TEST_VISUALISATION         1
00165 #endif
00166 #if SPIFFS_TEST_VISUALISATION
00167 #ifndef spiffs_printf
00168 #define spiffs_printf(...)                printf(__VA_ARGS__)
00169 #endif
00170 // spiffs_printf argument for a free page
00171 #ifndef SPIFFS_TEST_VIS_FREE_STR
00172 #define SPIFFS_TEST_VIS_FREE_STR          "_"
00173 #endif
00174 // spiffs_printf argument for a deleted page
00175 #ifndef SPIFFS_TEST_VIS_DELE_STR
00176 #define SPIFFS_TEST_VIS_DELE_STR          "/"
00177 #endif
00178 // spiffs_printf argument for an index page for given object id
00179 #ifndef SPIFFS_TEST_VIS_INDX_STR
00180 #define SPIFFS_TEST_VIS_INDX_STR(id)      "i"
00181 #endif
00182 // spiffs_printf argument for a data page for given object id
00183 #ifndef SPIFFS_TEST_VIS_DATA_STR
00184 #define SPIFFS_TEST_VIS_DATA_STR(id)      "d"
00185 #endif
00186 #endif
00187 
00188 // Types depending on configuration such as the amount of flash bytes
00189 // given to spiffs file system in total (spiffs_file_system_size),
00190 // the logical block size (log_block_size), and the logical page size
00191 // (log_page_size)
00192 
00193 // Block index type. Make sure the size of this type can hold
00194 // the highest number of all blocks - i.e. spiffs_file_system_size / log_block_size
00195 typedef u8_t spiffs_block_ix;
00196 // Page index type. Make sure the size of this type can hold
00197 // the highest page number of all pages - i.e. spiffs_file_system_size / log_page_size
00198 typedef u16_t spiffs_page_ix;
00199 // Object id type - most significant bit is reserved for index flag. Make sure the
00200 // size of this type can hold the highest object id on a full system,
00201 // i.e. 2 + (spiffs_file_system_size / (2*log_page_size))*2
00202 typedef u16_t spiffs_obj_id;
00203 // Object span index type. Make sure the size of this type can
00204 // hold the largest possible span index on the system -
00205 // i.e. (spiffs_file_system_size / log_page_size) - 1
00206 typedef u16_t spiffs_span_ix;
00207 
00208 #endif /* SPIFFS_CONFIG_H_ */