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/).|
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.
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.