Skip to content

Commit

Permalink
1、【优化】Log 分区识别功能,大大提升 Log 分区初始化效率;
Browse files Browse the repository at this point in the history
2、【删除】部分冗余断言;
3、【修复】几处单词拼写错误。

Signed-off-by: armink <[email protected]>
  • Loading branch information
armink committed May 11, 2017
1 parent 5927f69 commit 6e0d2cd
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 178 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2016 Armink ([email protected])
Copyright (c) 2014-2017 Armink ([email protected])

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
6 changes: 2 additions & 4 deletions easyflash/inc/easyflash.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the EasyFlash Library.
*
* Copyright (c) 2014-2016, Armink, <[email protected]>
* Copyright (c) 2014-2017, Armink, <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -67,7 +67,7 @@ if (!(EXPR)) \
while (1); \
}
/* EasyFlash software version number */
#define EF_SW_VERSION "2.12.08"
#define EF_SW_VERSION "3.0.0"

typedef struct _ef_env{
char *key;
Expand Down Expand Up @@ -128,8 +128,6 @@ size_t ef_log_get_used_size(void);

/* ef_utils.c */
uint32_t ef_calc_crc32(uint32_t crc, const void *buf, size_t size);
EfSecrorStatus ef_get_sector_status(uint32_t addr, size_t sec_size);
uint32_t ef_find_sec_using_end_addr(uint32_t addr, size_t sec_size);

/* ef_port.c */
EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size);
Expand Down
10 changes: 5 additions & 5 deletions easyflash/src/ef_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,11 @@ size_t ef_get_env_write_bytes(void) {
*/
static EfErrCode write_env(const char *key, const char *value) {
EfErrCode result = EF_NO_ERR;
size_t ker_len = strlen(key), value_len = strlen(value), env_str_len;
size_t key_len = strlen(key), value_len = strlen(value), env_str_len;
char *env_cache_bak = (char *)env_cache;

/* calculate ENV storage length, contain '=' and '\0'. */
env_str_len = ker_len + value_len + 2;
env_str_len = key_len + value_len + 2;
if (env_str_len % 4 != 0) {
env_str_len = (env_str_len / 4 + 1) * 4;
}
Expand All @@ -298,8 +298,8 @@ static EfErrCode write_env(const char *key, const char *value) {
env_cache_bak += get_env_user_used_size();

/* copy key name */
memcpy(env_cache_bak, key, ker_len);
env_cache_bak += ker_len;
memcpy(env_cache_bak, key, key_len);
env_cache_bak += key_len;
/* copy equal sign */
*env_cache_bak = '=';
env_cache_bak++;
Expand All @@ -310,7 +310,7 @@ static EfErrCode write_env(const char *key, const char *value) {
*env_cache_bak = '\0';
env_cache_bak ++;
/* fill '\0' for word alignment */
memset(env_cache_bak, 0, env_str_len - (ker_len + value_len + 2));
memset(env_cache_bak, 0, env_str_len - (key_len + value_len + 2));
set_env_end_addr(get_env_end_addr() + env_str_len);
/* ENV ram cache has changed */
env_cache_changed = true;
Expand Down
6 changes: 1 addition & 5 deletions easyflash/src/ef_env_wl.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the EasyFlash Library.
*
* Copyright (c) 2015-2016, Armink, <[email protected]>
* Copyright (c) 2015-2017, Armink, <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -214,7 +214,6 @@ static uint32_t get_env_start_addr(void) {
* @return current using data section address
*/
static uint32_t get_cur_using_data_addr(void) {
EF_ASSERT(cur_using_data_addr);
return cur_using_data_addr;
}

Expand All @@ -233,7 +232,6 @@ static void set_cur_using_data_addr(uint32_t using_data_addr) {
* @return detail part start address
*/
static uint32_t get_env_detail_addr(void) {
EF_ASSERT(cur_using_data_addr);
return get_cur_using_data_addr() + ENV_PARAM_PART_BYTE_SIZE;
}

Expand Down Expand Up @@ -348,8 +346,6 @@ static char *find_env(const char *key) {
char *env_start, *env_end, *env, *found_env = NULL;
size_t key_len = strlen(key), env_len;

EF_ASSERT(cur_using_data_addr);

if (*key == NULL) {
EF_INFO("Flash ENV name must be not empty!\n");
return NULL;
Expand Down
3 changes: 1 addition & 2 deletions easyflash/src/ef_iap.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* This file is part of the EasyFlash Library.
*
* Copyright (c) 2015-2016, Armink, <[email protected]>
* Copyright (c) 2015-2017, Armink, <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
Expand Down Expand Up @@ -258,7 +258,6 @@ EfErrCode ef_copy_bl_from_bak(uint32_t bl_addr, size_t bl_size) {
* @return size
*/
static uint32_t get_bak_app_start_addr(void) {
EF_ASSERT(bak_app_start_addr);
return bak_app_start_addr;
}

Expand Down
Loading

0 comments on commit 6e0d2cd

Please sign in to comment.