当前位置:网站首页>关于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);设置进去常存内容
边栏推荐
- Remote meter reading, switching on and off operation command
- Sword finger offer 38 Arrangement of strings [no description written]
- When there are pointer variable members in the custom type, the return value and parameters of the assignment operator overload must be reference types
- HAL库配置通用定时器TIM触发ADC采样,然后DMA搬运到内存空间。
- 1321:【例6.3】删数问题(Noip1994)
- [STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
- 反射效率为什么低?
- Multisim--软件相关使用技巧
- Leetcode-560: subarray with sum K
- 根据设备信息进行页面跳转至移动端页面或者PC端页面
猜你喜欢

Some superficial understanding of word2vec

1323:【例6.5】活动选择

STM32 ADC和DMA

Leetcode exercise - 113 Path sum II

Vs code specifies the extension installation location

The variables or functions declared in the header file cannot be recognized after importing other people's projects and adding the header file

浅谈日志中的返回格式封装格式处理,异常处理

Yarn的基础介绍以及job的提交流程

MySQL insert data create trigger fill UUID field value

SolidWorks工程图中添加中心线和中心符号线的办法
随机推荐
STM32 ADC and DMA
[牛客网刷题 Day5] JZ77 按之字形顺序打印二叉树
Socket通信原理和实践
Appx代碼簽名指南
成为优秀的TS体操高手 之 TS 类型体操前置知识储备
施努卡:机器视觉定位技术 机器视觉定位原理
555电路详解
AHB bus in stm32_ Apb2 bus_ Apb1 bus what are these
[detailed explanation of Huawei machine test] tall and short people queue up
Five simple and practical daily development functions of chrome are explained in detail. Unlock quickly to improve your efficiency!
2022.7.6DAY598
Leetcode-304: two dimensional area and retrieval - matrix immutable
Chris Lattner, père de llvm: Pourquoi reconstruire le logiciel d'infrastructure ai
[STM32] solution to the problem that SWD cannot recognize devices after STM32 burning program
Appx代码签名指南
字符串格式化
A small problem of bit field and symbol expansion
Review of the losers in the postgraduate entrance examination
移动端通过设置rem使页面内容及字体大小自动调整
P1223 排队接水/1319:【例6.1】排队接水