当前位置:网站首页>关于easyflash v3.3使用过程的记录
关于easyflash v3.3使用过程的记录
2022-07-07 08:23:00 【Sky_Lannister】
开源地址https://github.com/armink/EasyFlash
开源作者的一个帖子:https://www.amobbs.com/thread-5624863-1-1.html
已经更到V4了,但是使用的是ST的L4系列单片机,不能逆序写入,所以还是用的V3版本
使用的时候偶尔出现过空间已满,还特别不好复现,就把源代码过了一遍
关于磨损平衡
不是真正的磨损平衡,只是先一直向一个扇区不断的擦写读,等把这个扇区写坏了,再往下平移一个扇区,而且是只要这个扇区里面有一次写或者擦除失败都会平移到下一扇区,V4的实现和V3完全不一样关于env删除和复位:
/* remain ENV move forward */
memcpy(del_env, del_env + del_env_length, remain_env_length);
删除某个键值对后,缓存区数据统一向前平移 然后设置结尾地址;
将当前使用地址之后的缓存区域(env_cache)大小擦除,然后将移位好的数据从当前地址写入
save_cur_using_data_addr是写入前16字节的导头数据到系统区;
删除的时候会有一个空间保存一组每次复位都会保存的数据关于掉电保护:
掉电保护是通过软件实现的,不是通过检测单片机电压低于某个值后进行保存,而是调用ef_save_env_wt的时候,一次写入后几k备份,一次写入前几k真正保存,两次来回往复,始终有一个是另一个的保存,但是这样造成空间的浪费关于 get_env_user_used_size(void) 的理解:
static size_t get_env_user_used_size(void) {
if (get_env_detail_end_addr() > get_cur_using_data_addr()) {
return get_env_detail_end_addr() - get_cur_using_data_addr();
} else {
return 0;
}
}
为什么获取已经用过的大小,是通过末尾地址减去正在使用的地址,正序倒序都理解不了?
实际应该理解为get_env_detail_end_addr()是使用的末尾地址,是一直根据写入的大小改变的,而get_cur_using_data_addr();是固定的两个值,即要不是备份区,要不是真正存储区关于env空间分配:
掉电和磨损平衡模式,前后内存区分布一致:1系统区、2数据区
注意缓存区RAM大小、环境变量区、最小擦除扇区的大小及彼此的关系关于常存数据区大小:
default_env_set_size:一直保存的KEY-VALUE 复位的时候将其写入缓存的最后区域
使用set_env_detail_end_addr(get_env_detail_end_addr() + env_str_len);设置进去常存内容
边栏推荐
- IDA中常见快捷键
- MySQL insert data create trigger fill UUID field value
- P1223 排队接水/1319:【例6.1】排队接水
- 成为优秀的TS体操高手 之 TS 类型体操前置知识储备
- How embedded engineers improve work efficiency
- When there are pointer variable members in the custom type, the return value and parameters of the assignment operator overload must be reference types
- IPv4 socket address structure
- 原型与原型链
- Sword finger offer 38 Arrangement of strings [no description written]
- About hzero resource error (groovy.lang.missingpropertyexception: no such property: weight for class)
猜你喜欢
The Hal library is configured with a general timer Tim to trigger ADC sampling, and then DMA is moved to the memory space.
Appx code signing Guide
IIC基本知识
搭建物联网硬件通信技术几种方案
Leetcode-304: two dimensional area and retrieval - matrix immutable
Several schemes of building hardware communication technology of Internet of things
Pdf document signature Guide
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
Postman interface test III
Programming features of ISP, IAP, ICP, JTAG and SWD
随机推荐
大整数类实现阶乘
Sword finger offer 38 Arrangement of strings [no description written]
【剑指Offer】42. 栈的压入、弹出序列
【acwing】789. 数的范围(二分基础)
优雅的 Controller 层代码
根据设备信息进行页面跳转至移动端页面或者PC端页面
. Net configuration system
LLVM之父Chris Lattner:為什麼我們要重建AI基礎設施軟件
关于hzero-resource报错(groovy.lang.MissingPropertyException: No such property: weight for class)
[detailed explanation of Huawei machine test] tall and short people queue up
Study summary of postgraduate entrance examination in September
Multisim--软件相关使用技巧
STM32 ADC and DMA
SolidWorks工程图中添加中心线和中心符号线的办法
对word2vec的一些浅层理解
Appx code signing Guide
table宽度比tbody宽度大4px
1323:【例6.5】活动选择
Hdu-2196 tree DP learning notes
Embedded background - chip