From c5b48a47362c5868e40f0bab008cf7c0808e36eb Mon Sep 17 00:00:00 2001 From: "teng.wu" <1045718093@qq.com> Date: Fri, 21 Oct 2022 20:54:36 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BC=98=E5=8C=96]=E4=BC=98=E5=8C=96=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E6=97=B6=E8=AF=BB=E5=86=99=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- easyflash/inc/ef_cfg.h | 3 +++ easyflash/src/ef_env.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) 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;