提交 19a307cb 编写于 作者: A armink

1、【更新】说明文档。

Signed-off-by: Narmink <armink.ztl@gmail.com>
上级 f2faf532
# EasyFlash 使用说明
# EasyFlash
---
......@@ -59,7 +59,69 @@ Demo平台:STM32F103RET6 + RT-Thread 1.2.2 + Env(2K bytes)
## 3、文档
具体内容参考`\docs\`下的文件。
## 4、版权
## 4、许可
采用 GPL v3.0 开源协议,细节请阅读项目中的 LICENSE 文件内容。
---
## 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** :
- **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.
The library encapsulates the IAP (In-Application Programming) feature common interface. Support CRC32 checksum. While supporting the bootloader and application upgrade.
### 1.1 File structure
|Source file |Description |
|:------------------------------ |:----- |
|\flash\src\flash_env.c |Env (normal mode) interface and implementation source code.|
|\flash\src\flash_env_wl.c |Env (wear leveling mode) interface and implementation source code.|
|\flash\src\flash_iap.c |IAP interface and implementation source code.|
|\flash\src\flash_utils.c |EasyFlash utils. For example CRC32.|
|\flash\src\flash.c |Currently contains EasyFlash initialization function only. |
|\flash\port\flash_port.c |EasyFlash portable interface and configuration for different platforms.|
|\demo\stm32f10x\non_os |stm32f10x non-os demo.|
|\demo\stm32f10x\rtt |stm32f10x demo base on [RT-Thread](http://www.rt-thread.org/).|
|\demo\stm32f4xx |stm32f4xx demo base on [RT-Thread](http://www.rt-thread.org/).|
### 1.2 Resource consumption
```
Minimum : ROM: 6K bytes RAM: 0.5K bytes + (Env size)
Demo :STM32F103RET6 + RT-Thread 1.2.2 + Env(2K bytes)
Actual : ROM: 6K bytes RAM: 2.6K bytes
```
### 1.3 Supported platforms
Hardware platform has been ported `stm32f10x` and `stm32f4xx` series of on-chip Flash. This is my product platform. Remaining platform porting difficulty is little. The porting just modify `\flash\port\flash_port.c` file. Implement erase, write, read, print feature.
Welcome everyone to **fork and pull request**([Github](https://github.com/armink/EasyFlash)|[OSChina](http://git.oschina.net/armink/EasyFlash)|[Coding](https://coding.net/u/armink/p/EasyFlash/git)). The open source software success is inseparable from everyone efforts. I hope this project will help everyone reduce product development cycle and make product to success earlier.
## 2 Flow
### 2.1 Env
The figure below shows an ENV's common interface be called by the console(terminal). The ENV `"temp"` from creation to save, and then modify the final delete process. These interfaces are supported by the application layer called.
![easy_flash_env](https://cloud.githubusercontent.com/assets/1734686/5886463/46ad7efa-a3db-11e4-8401-75c00a4c35ba.gif)
### 2.2 IAP
The figure below shows the process of upgrade software through the console by IAP. It use this library comes with IAP function interface. Uses a serial port + Ymodem protocol mode. You can also be achieved through CAN, 485, Ethernet bus to online upgrade.
![easy_flash_iap](https://cloud.githubusercontent.com/assets/1734686/5886462/40f7d62c-a3db-11e4-866a-ba827c809370.gif)
## 3 Documents
All documents is in the `\docs\` folder.
## 4 License
Using GPL v3.0 open source license, please read the project LICENSE file.
\ No newline at end of file
......@@ -222,27 +222,7 @@ FlashErrCode flash_write(uint32_t addr, const uint32_t *buf, size_t size)
|buf |源数据的缓冲区|
|size |写入数据的大小(字节)|
### 2.4 分配动态内存
```C
void *flash_malloc(size_t size)
```
|参数 |描述|
|:----- |:----|
|size |需分配的内存大小|
### 2.5 释放动态内存
```C
void flash_free(void *p)
```
|参数 |描述|
|:----- |:----|
|p |需释放的动态内存地址|
### 2.6 打印调试日志信息
### 2.4 打印调试日志信息
在定义 `FLASH_PRINT_DEBUG` 宏后,打印调试日志信息
......@@ -257,7 +237,7 @@ void flash_log_debug(const char *file, const long line, const char *format, ...)
|format |打印格式|
|... |不定参|
### 2.7 打印普通日志信息
### 2.5 打印普通日志信息
```C
void flash_log_info(const char *format, ...)
......@@ -268,7 +248,7 @@ void flash_log_info(const char *format, ...)
|format |打印格式|
|... |不定参|
### 2.8 无格式打印信息
### 2.6 无格式打印信息
该方法输出无固定格式的打印信息,为 `flash_print_env` 方法所用。而 `flash_log_debug``flash_log_info` 可以输出带指定前缀及格式的打印日志信息。
......@@ -283,19 +263,25 @@ void flash_print(const char *format, ...)
## 3、配置
配置该库需要打开`\flash\flash.h`文件,开启、关闭对应的宏即可。
配置该库需要打开`\flash\flash.h`文件,开启、关闭、修改对应的宏即可。
### 3.1 CRC32校验
- 默认状态:开启
- 操作方法:开启、关闭`FLASH_ENV_USING_CRC_CHECK`宏即可
### 3.2 磨损平衡/常规 模式
### 3.2 环境变量的容量
- 默认容量:2K Bytes
- 操作方法:修改 `FLASH_USER_SETTING_ENV_SIZE`宏定义即可
### 3.3 磨损平衡/常规 模式
- 默认状态:常规模式
- 磨损平衡模式:打开`FLASH_ENV_USING_WEAR_LEVELING_MODE`,关闭`FLASH_ENV_USING_NORMAL_MODE`
- 常规模式:打开`FLASH_ENV_USING_NORMAL_MODE`,关闭`FLASH_ENV_USING_WEAR_LEVELING_MODE`
- 注意:只能选择其中一种模式,两种模式不能同时使用
- 常规模式:打开`FLASH_ENV_USING_NORMAL_MODE`,关闭`FLASH_ENV_USING_WEAR_LEVELING_MODE
> 注意:只能选择其中一种模式,两种模式不能同时使用
## 4、注意
......@@ -303,5 +289,3 @@ void flash_print(const char *format, ...)
- 环境变量设置完后,只有调用 `flash_save_env`才会保存在Flash中,否则开机会丢失修改的内容
- 不要在应用程序及Bootloader中执行擦除及拷贝自身的动作
- Flash读取和写入方法的最小单位为4个字节,擦除的最小单位则需根据用户的平台来确定
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册