Migrated repository
Go to file
2015-07-29 16:55:21 +08:00
demo 1、【更新】log功能Demo。 2015-07-25 16:36:50 +08:00
docs 1、【增加】设置环境变量后立刻保存的方法,简化用户操作。 2015-07-29 16:55:21 +08:00
easyflash 1、【增加】设置环境变量后立刻保存的方法,简化用户操作。 2015-07-29 16:55:21 +08:00
.gitattributes 1、【增加】git版本控制; 2015-01-24 16:13:52 +08:00
LICENSE 1、【修改】开源许可协议为MIT协议。 2015-06-17 12:15:52 +08:00
README.md 1、【增加】移植说明文档。 2015-07-22 11:42:33 +08:00

EasyFlash


1、介绍

EasyFlash是一款开源的轻量级嵌入式Flash存储器库主要为MCU(Micro Control Unit)提供便捷、通用的上层应用接口使得开发者更加高效实现基于的Flash存储器常见应用开发。该库目前提供 三大实用功能

  • Env 小型KV数据库支持 写平衡(磨损平衡)掉电保护 模式

让Flash变为NoSQL非关系型数据库模型的小型键值Key-Value存储数据库。在产品上能够更加简捷的实现 设定参数运行日志 等信息掉电保存功能。

  • IAP 在线升级再也不是难事儿

该库封装了IAP(In-Application Programming)功能常用的接口支持CRC32校验同时支持Bootloader及Application的升级。

  • Log 无需文件系统日志可直接存储在Flash上

非常适合应用在小型的不带文件系统的产品中,方便开发人员快速定位、查找系统发生崩溃或死机的原因。同时配合EasyLogger(我开源的超轻量级、高性能C日志库它提供与EasyFlash的无缝接口)一起使用轻松实现C日志的Flash存储功能。

1.1、资源占用

最低要求: ROM: 6K bytes     RAM: 0.5K bytes + (Env大小)

Demo平台STM32F103RET6 + RT-Thread 1.2.2 + Env(2K bytes)
实际占用: ROM: 6K bytes     RAM: 2.6K bytes

1.2、支持平台

目前已移植硬件平台有 stm32f10xstm32f4xx 系列的片内Flash这个也是笔者产品使用的平台。其余平台的移植难度不大在项目的设计之初就有考虑针对所有平台的适配性问题64位除外所以对所有移植接口都有做预留。移植只需修改 \easyflash\port\ef_port.c 一个文件,实现里面的擦、写、读及打印功能即可。

欢迎大家 star and pull request(Github|OSChina|Coding) 。开源软件的成功离不开所有人的努力,也希望该项目能够帮助大家降低开发周期,让产品更早的获得成功。

2、流程

2.1、Env环境变量KV数据库

下图为通过控制台(终端)来调用环境变量的常用接口,演示了以下过程,这些接口都支持被应用层直接调用。

  • 1、创建“温度”的环境变量名为 temp,并且赋值为 123
  • 2、保存“温度”到Flash中并重启
  • 3、检查“温度”是否被成功保存
  • 4、修改“温度”值为 456 并保存、重启;
  • 5、检查“温度”是否被成功修改
  • 6、删除“温度”的环境变量。

easy_flash_env

2.2、IAP在线升级

下图演示了通过控制台来进行IAP升级软件的过程使用的是库中自带的IAP功能接口演示采用的是串口+Ymodem协议的方式。你还也可以实现通过CAN、485、以太网等总线来实现远程网络更新。

easy_flash_iap

2.3、Log日志存储

下图过程为通过控制台输出日志并将输出的日志存储到Flash中。重启再读取上次保存的日志最后清空Flash日志。

easy_flash_log

3、文档

具体内容参考\docs\下的文件。务必保证在 阅读文档 后再移植使用。

4、许可

采用 MIT 开源协议,细节请阅读项目中的 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 Three useful features

  • Env(environment variables) : A small KV database. Support write balance mode(wear leveling) and power fail safeguard.

Let Flash becomes a small NoSQL (non-relational databases) model and Key-Value stores database. 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.

  • 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. The developer can easy to locate and query problem when system crashes or freezes. You can use 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 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.2 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 \easyflash\port\ef_port.c file. Implement erase, write, read, print feature.

Welcome everyone to star and pull request(Github|OSChina|Coding). 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(KV database)

The figure below shows an ENV's common interface be called by the console(terminal). These interfaces are supported by the application layer called.

  • 1.Create temperature environment variable. It's name is temp and value is 123;
  • 2.Save temperature to flash and reboot;
  • 3.Check the temperature has saved successfully;
  • 4.Change the temperature value to 456 and save, reboot;
  • 5.Check the temperature has changed successfully;
  • 6.Delete temperature environment variable.

easy_flash_env

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

2.3 Log

The following figure is the output log process through the console. The logs will save to flash at the same time. Then reboot the and read the logs from flash. At last will clean all logs which on flash.

easy_flash_log

3 Documents

All documents is in the \docs\ folder. Please read the documents before port and use it.

4 License

Using MIT open source license, please read the project LICENSE file.