Device firmware update

void set_dfu_alt_info(char *interface, char *devstr)

set dfu_alt_info environment variable

Parameters

char *interface
dfu interface, e.g. “mmc” or “nand”
char *devstr
device number as string

Description

If CONFIG_SET_DFU_ALT_INFO=y, this board specific function is called to set environment variable dfu_alt_info.

int dfu_alt_init(int num, struct dfu_entity **dfu)

initialize buffer for dfu entities

Parameters

int num
number of entities
struct dfu_entity **dfu
on return allocated buffer

Return

0 on success

int dfu_alt_add(struct dfu_entity *dfu, char *interface, char *devstr, char *s)

add alternate to dfu entity buffer

Parameters

struct dfu_entity *dfu
dfu entity
char *interface
dfu interface, e.g. “mmc” or “nand”
char *devstr
device number as string
char *s
string description of alternate

Return

0 on success

int dfu_config_entities(char *s, char *interface, char *devstr)

initialize dfu entitities from envirionment

Parameters

char *s
string with alternates
char *interface
interface, e.g. “mmc” or “nand”
char *devstr
device number as string

Description

Initialize the list of dfu entities from environment variable dfu_alt_info. The list must be freed by calling dfu_free_entities(). This function bypasses set_dfu_alt_info(). So typically you should use dfu_init_env_entities() instead.

See function dfu_free_entities() See function dfu_init_env_entities()

Return

0 on success, a negative error code otherwise

void dfu_free_entities(void)

free the list of dfu entities

Parameters

void
no arguments

Description

Free the internal list of dfu entities.

See function dfu_init_env_entities()

void dfu_show_entities(void)

print DFU alt settings list

Parameters

void
no arguments
int dfu_get_alt_number(void)

get number of alternates

Parameters

void
no arguments

Return

number of alternates in the dfu entities list

const char * dfu_get_dev_type(enum dfu_device_type type)

get string representation for dfu device type

Parameters

enum dfu_device_type type
device type

Return

string representation for device type

const char * dfu_get_layout(enum dfu_layout layout)

get string describing layout

Parameters

enum dfu_layout layout
layout Result: string representation for the layout

Description

Internally layouts are represented by enum dfu_device_type values. This function translates an enum value to a human readable string, e.g. DFU_FS_FAT is translated to “FAT”.

struct dfu_entity * dfu_get_entity(int alt)

get dfu entity for an alternate id

Parameters

int alt
alternate id

Return

dfu entity

int dfu_get_alt(char *name)

get alternate id for filename

Parameters

char *name
filename

Description

Environment variable dfu_alt_info defines the write destinations (alternates) for different filenames. This function get the index of the alternate for a filename. If an absolute filename is provided (starting with ‘/’), the directory path is ignored.

Return

id of the alternate or negative error number (-ENODEV)

int dfu_init_env_entities(char *interface, char *devstr)

initialize dfu entitities from envirionment

Parameters

char *interface
interface, e.g. “mmc” or “nand”
char *devstr
device number as string

Description

Initialize the list of dfu entities from environment variable dfu_alt_info. The list must be freed by calling dfu_free_entities(). interface and devstr are used to select the relevant set of alternates from environment variable dfu_alt_info.

If environment variable dfu_alt_info specifies the interface and the device, use NULL for interface and devstr.

See function dfu_free_entities()

Return

0 on success, a negative error code otherwise

int dfu_read(struct dfu_entity *de, void *buf, int size, int blk_seq_num)

read from dfu entity

Parameters

struct dfu_entity *de
dfu entity
void *buf
buffer
int size
size of buffer
int blk_seq_num
block sequence number

Description

The block sequence number blk_seq_num is a 16 bit counter that must be incremented with each call for the same dfu entity de.

Return

0 for success, -1 for error

int dfu_write(struct dfu_entity *de, void *buf, int size, int blk_seq_num)

write to dfu entity

Parameters

struct dfu_entity *de
dfu entity
void *buf
buffer
int size
size of buffer
int blk_seq_num
block sequence number

Description

Write the contents of a buffer buf to the dfu entity de. After writing the last block call dfu_flush(). If a file is already loaded completely into memory it is preferable to use dfu_write_from_mem_addr() which takes care of blockwise transfer and flushing.

The block sequence number blk_seq_num is a 16 bit counter that must be incremented with each call for the same dfu entity de.

See function dfu_flush() See function dfu_write_from_mem_addr()

Return

0 for success, -1 for error

int dfu_flush(struct dfu_entity *de, void *buf, int size, int blk_seq_num)

flush to dfu entity

Parameters

struct dfu_entity *de
dfu entity
void *buf
ignored
int size
ignored
int blk_seq_num
block sequence number of last write - ignored

Description

This function has to be called after writing the last block to the dfu entity de.

The block sequence number blk_seq_num is a 16 bit counter that must be incremented with each call for the same dfu entity de.

See function dfu_write()

Return

0 for success, -1 for error

void dfu_initiated_callback(struct dfu_entity *dfu)

weak callback called on DFU transaction start

Parameters

struct dfu_entity *dfu
pointer to the dfu_entity, which should be initialized

Description

It is a callback function called by DFU stack when a DFU transaction is initiated. This function allows to manage some board specific behavior on DFU targets.

void dfu_flush_callback(struct dfu_entity *dfu)

weak callback called at the end of the DFU write

Parameters

struct dfu_entity *dfu
pointer to the dfu_entity, which should be flushed

Description

It is a callback function called by DFU stack after DFU manifestation. This function allows to manage some board specific behavior on DFU targets

void dfu_error_callback(struct dfu_entity *dfu, const char *msg)

weak callback called at the DFU write error

Parameters

struct dfu_entity *dfu
pointer to the dfu_entity which cause the error
const char *msg
the message of the error

Description

It is a callback function called by DFU stack after DFU write error. This function allows to manage some board specific behavior on DFU targets

struct dfu_entity * dfu_get_defer_flush(void)

get current value of dfu_defer_flush pointer

Parameters

void
no arguments

Return

value of the dfu_defer_flush pointer

void dfu_set_defer_flush(struct dfu_entity *dfu)

set the dfu_defer_flush pointer

Parameters

struct dfu_entity *dfu
pointer to the dfu_entity, which should be written
int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size)

write data from memory to DFU managed medium

Parameters

struct dfu_entity *dfu
dfu entity to which we want to store data
void *buf
fixed memory address from where data starts
int size
number of bytes to write

Description

This function adds support for writing data starting from fixed memory address (like $loadaddr) to dfu managed medium (e.g. NAND, MMC, file system)

Return

0 on success, other value on failure

int dfu_write_by_name(char *dfu_entity_name, void *addr, unsigned int len, char *interface, char *devstring)

write data to DFU medium

Parameters

char *dfu_entity_name
Name of DFU entity to write
void *addr
Address of data buffer to write
unsigned int len
Number of bytes
char *interface
Destination DFU medium (e.g. “mmc”)
char *devstring
Instance number of destination DFU medium (e.g. “1”)

Description

This function is storing data received on DFU supported medium which is specified by dfu_entity_name.

Return

0 - on success, error code - otherwise

int dfu_write_by_alt(int dfu_alt_num, void *addr, unsigned int len, char *interface, char *devstring)

write data to DFU medium

Parameters

int dfu_alt_num
DFU alt setting number
void *addr
Address of data buffer to write
unsigned int len
Number of bytes
char *interface
Destination DFU medium (e.g. “mmc”)
char *devstring
Instance number of destination DFU medium (e.g. “1”)

Description

This function is storing data received on DFU supported medium which is specified by dfu_alt_name.

Return

0 - on success, error code - otherwise