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:
parent
04bf2e1bd1
commit
2d2e1614b5
3 changed files with 73 additions and 62 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue