diff --git a/easyflash/inc/ef_cfg.h b/easyflash/inc/ef_cfg.h index 717748b..a32ab22 100644 --- a/easyflash/inc/ef_cfg.h +++ b/easyflash/inc/ef_cfg.h @@ -59,6 +59,9 @@ * only support 1(nor flash)/ 8(stm32f4)/ 32(stm32f1) */ #define EF_WRITE_GRAN /* @note you must define it for a value */ + +/* The size of read_env and continue_ff_addr function used*/ +#define EF_READ_BUF_SIZE 32 /* @default 32, Larger numbers can improve first-time speed of alloc_env but require more stack space*/ /* * * This all Backup Area Flash storage index. All used flash area configure is under here. diff --git a/easyflash/src/ef_env.c b/easyflash/src/ef_env.c index a3a4c31..50d5d69 100644 --- a/easyflash/src/ef_env.c +++ b/easyflash/src/ef_env.c @@ -424,7 +424,7 @@ static bool get_env_from_cache(const char *name, size_t name_len, uint32_t *addr */ static uint32_t continue_ff_addr(uint32_t start, uint32_t end) { - uint8_t buf[32], last_data = 0x00; + uint8_t buf[EF_READ_BUF_SIZE], last_data = 0x00; size_t i, addr = start, read_size; for (; start < end; start += sizeof(buf)) { @@ -522,7 +522,7 @@ static uint32_t get_next_env_addr(sector_meta_data_t sector, env_node_obj_t pre_ static EfErrCode read_env(env_node_obj_t env) { struct env_hdr_data env_hdr; - uint8_t buf[32]; + uint8_t buf[EF_READ_BUF_SIZE]; uint32_t calc_crc32 = 0, crc_data_len, env_name_addr; EfErrCode result = EF_NO_ERR; size_t len, size;