当前位置:网站首页>关于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);设置进去常存内容
边栏推荐
- Leetcode-304: two dimensional area and retrieval - matrix immutable
- mysql插入数据创建触发器填充uuid字段值
- openinstall与虎扑达成合作,挖掘体育文化产业数据价值
- Use of JSON extractor originals in JMeter
- P1031 [NOIP2002 提高组] 均分纸牌
- 1323:【例6.5】活动选择
- Elegant controller layer code
- 【acwing】789. 数的范围(二分基础)
- Postman interface test III
- Adb 实用命令(网络包、日志、调优相关)
猜你喜欢

Elegant controller layer code

字符串格式化

leetcode-304:二维区域和检索 - 矩阵不可变

Weekly recommended short videos: what are the functions of L2 that we often use in daily life?

MySQL insert data create trigger fill UUID field value

基于gis三维可视化技术的智慧城市建设
![[牛客网刷题 Day5] JZ77 按之字形顺序打印二叉树](/img/ba/b2dfbf121798757c7b9fba4811221b.png)
[牛客网刷题 Day5] JZ77 按之字形顺序打印二叉树

Inno setup packaging and signing Guide

Appx code signing Guide

Appx代码签名指南
随机推荐
Prototype object in ES6
IIC基本知识
Guid主键
STM32 ADC and DMA
Study summary of postgraduate entrance examination in November
When there are pointer variable members in the custom type, the return value and parameters of the assignment operator overload must be reference types
XML configuration file parsing and modeling
Study summary of postgraduate entrance examination in October
大整数类实现阶乘
Learning records - high precision addition and multiplication
01 use function to approximate cosine function (15 points)
Jump to the mobile terminal page or PC terminal page according to the device information
Study summary of postgraduate entrance examination in September
P1223 排队接水/1319:【例6.1】排队接水
2022.7.6DAY598
IPv4套接字地址结构
The story of Plato and his three disciples: how to find happiness? How to find the ideal partner?
The mobile terminal automatically adjusts the page content and font size by setting rem
Vs code specifies the extension installation location
Prototype and prototype chain