Giter VIP home page Giter VIP logo

easyflash's People

Contributors

armink avatar lianghongquan avatar yangjie11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easyflash's Issues

增加ef_iterator_env函数让外部调用,增加ef_env.h文件把定义单独放进来

void ef_iterator_env(void *arg1, void *arg2, bool (*callback)(env_meta_data_t env, void *arg1, void *arg2))
{
struct env_meta_data env;

if (!init_ok) {
    EF_INFO("ENV isn't initialize OK.\n");
    return;
}

/* lock the ENV cache */
ef_port_env_lock();

env_iterator(&env, arg1, arg2, callback);

/* unlock the ENV cache */
ef_port_env_unlock();

}

/**

  • Print ENV.
    */
    void ef_print_env(void)
    {
    size_t using_size = 0;

    ef_iterator_env(&using_size, NULL, print_env_cb);

    ef_print("\nmode: next generation\n");
    ef_print("size: %lu/%lu bytes.\n", using_size + (SECTOR_NUM - EF_GC_EMPTY_SEC_THRESHOLD) * SECTOR_HDR_DATA_SIZE,
    ENV_AREA_SIZE - SECTOR_SIZE * EF_GC_EMPTY_SEC_THRESHOLD);
    }

log_index2addr 函数存在隐藏风险,建议优化

ef_log.c 文件内的 log_index2addr 函数使用存在隐藏风险,建议可以优化

当给 log_index2addr 传入的参数index 的值 大于 2倍LOG_AREA_SIZE时,回导致计算出来的flash物理地址错误

建议将返回值计算
return log_start_addr + index + header_total_offset - LOG_AREA_SIZE;
修改为
return (log_start_addr + index + header_total_offse)t % LOG_AREA_SIZE;

尽管此函数仅由ef_log_read调用,且ef_log_read函数内做了EF_ASSERT(index < cur_using_size);判断,目前整体是安全的,但是此函数是不安全的,为防止后续其他函数调用是引入风险,建议修改

一些意见和建议

1

ENV_AREA_SIZE没有办法设置,现在我直接改了ef_cfg.h,但这样太不稳定了。(包是用pkgs下载的)

2

还有配置方面的一些问题,比如现在很多配置的检查是用这样的方式实现的:

#if EF_ENV_CACHE_TABLE_SIZE > 0xFFFF
#error "The ENV cache table size must less than 0xFFFF"
#endif

而另一些是assert,实际上都可以用assert,这样有机会把它们定义成某种在应用早期计算的全局变量,可以更灵活。

3

ef_env_init()中的EF_ASSERT(ENV_AREA_SIZE % EF_ERASE_MIN_SIZE == 0);没有什么必要,我需要专门算ENV_AREA_SIZE ,但其实并不会导致什么问题,只是最后有一些空间浪费了而已。

ef_fal_port.c有BUG

ef_port_read/write/erase调用fal_partition相关函数时,地址变量传递不正确。
以ef_port_read为例:
该函数的声明如下:
EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size);
其参数addr是一个绝对地址变量。

fal_partition_read函数的声明如下:
int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
其参数addr是一个相对地址变量。

所以调用fal_partition_read的方式应改为这样:
fal_partition_read(part, addr - stm32f2_onchip_flash.addr - part->offset, (uint8_t *)buf, size);

Make EasyFlash support multiple partation operations with FAL

Although FAL support multiple partitions for multiple physical flash devices, only one partation could be used when porting FAL to EasyFlash.

EasyFlash uses one static global partation descriptor in ef_port.c or ef_fal_port.c, and the api doesn't support passing different partation names or partation descriptors. This is not flexible enough when we got several flash chips (in-chip and off-chip). Only one partation in one chip could be managed by EF.

One way to solve this with least changes is to modify the ef_port_xxx apis, passing partation descriptor or partation name or something else into it, and each function block (env, iap, log...) passes different partation params to port apis. But this makes EF and FAL couples tighter. A more abstract descriptor might be added in EF implementation.

STM32L4系列芯片,Easyflash初始化问题

芯片:STM32L496RGT,使用fal组件和easyflash。flash驱动用的是rtt的drv_flash_l4.c
fal层分区是(0-1000KB)APP、(1000-1024KB)PARAMS。fal层初始化成功,因为曾经移植过littlefs,这部分比较熟悉。

easyflash格式化head不知道是不是成功了,如下:
Read data success. Start from 0x00000000, size is 200. The data is:
Offset (h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
[00000000] 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000010] FF FF FF FF FF FF FF FF 00 FF FF FF FF FF FF FF ................
[00000020] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000030] 45 46 34 30 FF FF FF FF FF FF FF FF 00 00 00 00 EF40............
[00000040] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000050] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000060] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000070] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000080] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[00000090] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[000000A0] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[000000B0] FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ................
[000000C0] FF FF FF FF FF FF FF FF ........

easyflash的menuconfig配置大致如下:
use ENV
Erase MIN:2048;Write MIN:64bits;Start addr:0
Version:V4.1.0

问题是:初始化默认环境变量时,会从offset=8开始写入flash,而这里已经被head写过了,因此HAL_FLASH_Program函数失败了。

大致看了下代码,了解到写环境变量时将申请flash块地址,而这个申请是easyflash管理的,在不清楚原理的情况下不敢贸然改动。

想请教的是,easyflash移植到L4系列中是否有问题的地方?

如果能做成像表查询一样的功能就更好了

类似数据库主键作为Key,JSON或者struct作Value,提供查询接口,字段值的过滤比较排序等函数由用户编写,当作参数传入,实现自定义的过滤排序等,那就完全是一个NoSQL数据库了

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.