dfu/flash_img: use flash_map instead of flash API

Patch introduces flash_map subsystem to operate on flash
image instead of direct operation using flash_driver API.
Changes allows to support operation on the image in any flash
device.

flash_map was not available when this subsystem was introduced.

Signed-off-by: Findlay Feng <i@fengch.me>
This commit is contained in:
Findlay Feng 2018-08-02 09:44:13 +08:00 committed by Kumar Gala
commit 2d2e1614b5
3 changed files with 73 additions and 62 deletions

View file

@ -12,9 +12,11 @@
extern "C" {
#endif
#include <flash_map.h>
struct flash_img_context {
u8_t buf[CONFIG_IMG_BLOCK_BUF_SIZE];
struct device *dev;
const struct flash_area *flash_area;
size_t bytes_written;
u16_t buf_bytes;
};
@ -23,9 +25,10 @@ struct flash_img_context {
* @brief Initialize context needed for writing the image to the flash.
*
* @param ctx context to be initialized
* @param dev flash driver to used while writing the image
*
* @return 0 on success, negative errno code on fail
*/
void flash_img_init(struct flash_img_context *ctx, struct device *dev);
int flash_img_init(struct flash_img_context *ctx);
/**
* @brief Read number of bytes of the image written to the flash.