提交 deee25d1 编写于 作者: A armink

1、【更新】说明文件及API文档。

Signed-off-by: Narmink <armink.ztl@gmail.com>
上级 31128657
......@@ -4,14 +4,19 @@
## 1、介绍
EasyFlash是一款开源的轻量级嵌入式Flash存储器库,主要为MCU(Micro Control Unit)提供便捷、通用的上层应用接口,使得开发者更加高效实现基于的Flash存储器常见应用开发。该库目前提供 **大实用功能**
EasyFlash是一款开源的轻量级嵌入式Flash存储器库,主要为MCU(Micro Control Unit)提供便捷、通用的上层应用接口,使得开发者更加高效实现基于的Flash存储器常见应用开发。该库目前提供 **大实用功能**
- **Env** 让变量轻松实现掉电保存,支持 **写平衡** 模式,无需担心变量长度、磨损平衡等问题
- **Env** 让变量轻松实现掉电保存,支持 **写平衡** 模式,无需担心变量长度、磨损平衡等问题
使用 **键值对(key-value)** 方式将变量存储到Flash中。在产品上,能够更加简捷的实现 **设定参数****运行日志** 等信息掉电保存的功能。
- **IAP** 在线升级再也不是难事儿
使用 **键值对(key-value)** 方式将变量存储到Flash中。在产品上,能够更加简捷的实现 **设定参数****运行日志** 等信息掉电保存的功能。
- **IAP** 在线升级再也不是难事儿
该库封装了IAP(In-Application Programming)功能常用的接口,支持CRC32校验,同时支持Bootloader及Application的升级。
该库封装了IAP(In-Application Programming)功能常用的接口,支持CRC32校验,同时支持Bootloader及Application的升级。
- **Log** 无需文件系统,日志可直接存储在Flash上
非常适合应用在小型的不带文件系统的产品中。同时配合[EasyLogger](https://github.com/armink/EasyLogger)(我开源的超轻量级、高性能C日志库,它提供与EasyFlash的无缝接口)一起使用,轻松实现日志的Flash存储功能。
### 1.1、文件结构
......@@ -20,6 +25,7 @@ EasyFlash是一款开源的轻量级嵌入式Flash存储器库,主要为MCU(Mi
|\easyflash\src\flash_env.c |Env(常规模式)相关操作接口及实现源码|
|\easyflash\src\flash_env_wl.c |Env(磨损平衡模式)相关操作接口及实现源码|
|\easyflash\src\flash_iap.c |IAP 相关操作接口及实现源码|
|\easyflash\src\flash_log.c |Log 相关操作接口及实现源码|
|\easyflash\src\flash_utils.c |EasyFlash常用小工具,例如:CRC32|
|\easyflash\src\flash.c |目前只包含EasyFlash初始化方法|
|\easyflash\port\flash_port.c |不同平台下的EasyFlash移植接口及配置参数|
......@@ -66,14 +72,19 @@ Demo平台:STM32F103RET6 + RT-Thread 1.2.2 + Env(2K bytes)
## 1 Introduction
EasyFlash is an open source lightweight embedded flash memory library. It provide convenient application interface for MCU (Micro Control Unit). The developers can achieve more efficient and common application development based on Flash memory. The library currently provides **two useful features** :
EasyFlash is an open source lightweight embedded flash memory library. It provide convenient application interface for MCU (Micro Control Unit). The developers can achieve more efficient and common application development based on Flash memory. The library currently provides **Three useful features** :
- **Env(environment variables)** : Let variable easily achieve power down to save. Support **write balance mode** . No need to worry about variable length, wear leveling and other problems.
- **Env(environment variables)** : Let variable easily achieve power down to save. Support **write balance mode** . No need to worry about variable length, wear leveling and other problems.
Use **key-value** model to stored variables to the Flash. You can be more simple to store **setting parameters** or **running logs** and other information which you want to power down to save.
- **IAP** : online upgrade is no longer a difficult thing.
Use **key-value** model to stored variables to the Flash. You can be more simple to store **setting parameters** or **running logs** and other information which you want to power down to save.
- **IAP** : online upgrade is no longer a difficult thing.
The library encapsulates the IAP (In-Application Programming) feature common interface. Support CRC32 checksum. While supporting the bootloader and application upgrade.
The library encapsulates the IAP (In-Application Programming) feature common interface. Support CRC32 checksum. While supporting the bootloader and application upgrade.
- **Log** : The logs can store to product's flash which has no file-system.
It's very suitable for small without a file system products. You can use [EasyLogger](https://github.com/armink/EasyLogger)( A super-lightweight, high-performance C log library which open source by me. It provides a seamless interface with EasyFlash) at the same time. So, it's so easy to store the logs to flash.
### 1.1 File structure
......@@ -82,6 +93,7 @@ EasyFlash is an open source lightweight embedded flash memory library. It provid
|\easyflash\src\flash_env.c |Env (normal mode) interface and implementation source code.|
|\easyflash\src\flash_env_wl.c |Env (wear leveling mode) interface and implementation source code.|
|\easyflash\src\flash_iap.c |IAP interface and implementation source code.|
|\easyflash\src\flash_log.c |Log interface and implementation source code.|
|\easyflash\src\flash_utils.c |EasyFlash utils. For example CRC32.|
|\easyflash\src\flash.c |Currently contains EasyFlash initialization function only. |
|\easyflash\port\flash_port.c |EasyFlash portable interface and configuration for different platforms.|
......
......@@ -181,6 +181,43 @@ FlashErrCode flash_copy_bl_from_bak(uint32_t bl_addr, size_t bl_size)
|bl_addr |Bootloader入口地址|
|bl_size |Bootloader大小|
### 1.4 日志存储
#### 1.4.1 从Flash中读取已存在的日志
```C
FlashErrCode flash_log_read(size_t pos, uint32_t *log, size_t size);
```
|参数 |描述|
|:----- |:----|
|pos |日志读取的起始地址|
|log |存储待读取日志的缓冲区|
|size |读取日志的大小|
#### 1.4.2 往Flash中保存日志
```C
FlashErrCode flash_log_write(const uint32_t *log, size_t size);
```
|参数 |描述|
|:----- |:----|
|log |存储待保存的日志|
|size |待保存日志的大小|
#### 1.4.3 清空存储在Flash中全部日志
```C
FlashErrCode flash_log_clean(void);
```
#### 1.4.4 获取已存储在Flash中的日志大小
```C
size_t flash_log_get_used_size(void);
```
## 2 移植接口
### 2.1 读取Flash
......@@ -287,17 +324,22 @@ void flash_print(const char *format, ...)
- 默认状态:开启
- 操作方法:开启、关闭`FLASH_USING_IAP`宏即可
### 3.3 ENV的CRC32校验
### 3.3 Log功能
- 默认状态:开启
- 操作方法:开启、关闭`FLASH_USING_LOG`宏即可
### 3.4 ENV的CRC32校验
- 默认状态:开启
- 操作方法:开启、关闭`FLASH_ENV_USING_CRC_CHECK`宏即可
### 3.4 环境变量的容量
### 3.5 环境变量的容量
- 默认容量:2K Bytes
- 操作方法:修改`FLASH_USER_SETTING_ENV_SIZE`宏定义即可
### 3.5 磨损平衡/常规 模式
### 3.6 磨损平衡/常规 模式
- 默认状态:常规模式
- 磨损平衡模式:打开`FLASH_ENV_USING_WEAR_LEVELING_MODE`,关闭`FLASH_ENV_USING_NORMAL_MODE`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册