Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
flash_img.h File Reference

Go to the source code of this file.

Data Structures

struct  flash_img_context
 
struct  flash_img_check
 Structure for verify flash region integrity. More...
 

Functions

int flash_img_init_id (struct flash_img_context *ctx, uint8_t area_id)
 Initialize context needed for writing the image to the flash. More...
 
int flash_img_init (struct flash_img_context *ctx)
 Initialize context needed for writing the image to the flash. More...
 
size_t flash_img_bytes_written (struct flash_img_context *ctx)
 Read number of bytes of the image written to the flash. More...
 
int flash_img_buffered_write (struct flash_img_context *ctx, const uint8_t *data, size_t len, bool flush)
 Process input buffers to be written to the image slot 1. flash memory in single blocks. Will store remainder between calls. More...
 
int flash_img_check (struct flash_img_context *ctx, const struct flash_img_check *fic, uint8_t area_id)
 Verify flash memory length bytes integrity from a flash area. The start point is indicated by an offset value. More...
 

Function Documentation

◆ flash_img_buffered_write()

int flash_img_buffered_write ( struct flash_img_context ctx,
const uint8_t data,
size_t  len,
bool  flush 
)

Process input buffers to be written to the image slot 1. flash memory in single blocks. Will store remainder between calls.

A final call to this function with flush set to true will write out the remaining block buffer to flash. Since flash is written to in blocks, the contents of flash from the last byte written up to the next multiple of CONFIG_IMG_BLOCK_BUF_SIZE is padded with 0xff.

Parameters
ctxcontext
datadata to write
lenNumber of bytes to write
flushwhen true this forces any buffered data to be written to flash
Returns
0 on success, negative errno code on fail

◆ flash_img_bytes_written()

size_t flash_img_bytes_written ( struct flash_img_context ctx)

Read number of bytes of the image written to the flash.

Parameters
ctxcontext
Returns
Number of bytes written to the image flash.

◆ flash_img_check()

int flash_img_check ( struct flash_img_context ctx,
const struct flash_img_check fic,
uint8_t  area_id 
)

Verify flash memory length bytes integrity from a flash area. The start point is indicated by an offset value.

The function is enabled via CONFIG_IMG_ENABLE_IMAGE_CHECK Kconfig options.

Parameters
[in]ctxcontext.
[in]ficflash img check data.
[in]area_idflash area id of partition where the image should be verified.
Returns
0 on success, negative errno code on fail

◆ flash_img_init()

int flash_img_init ( struct flash_img_context ctx)

Initialize context needed for writing the image to the flash.

Parameters
ctxcontext to be initialized
Returns
0 on success, negative errno code on fail

◆ flash_img_init_id()

int flash_img_init_id ( struct flash_img_context ctx,
uint8_t  area_id 
)

Initialize context needed for writing the image to the flash.

Parameters
ctxcontext to be initialized
area_idflash area id of partition where the image should be written
Returns
0 on success, negative errno code on fail