Device firmware update
-
voidset_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.
-
intdfu_alt_init(intnum, structdfu_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
-
intdfu_alt_add(structdfu_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
-
intdfu_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
-
voiddfu_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()
-
voiddfu_show_entities(void)
print DFU alt settings list
Parameters
void
no arguments
-
intdfu_get_alt_number(void)
get number of alternates
Parameters
void
no arguments
Return
number of alternates in the dfu entities list
-
constchar*dfu_get_dev_type(enumdfu_device_typetype)
get string representation for dfu device type
Parameters
enum dfu_device_type type
device type
Return
string representation for device type
-
constchar*dfu_get_layout(enumdfu_layoutlayout)
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".
-
structdfu_entity*dfu_get_entity(intalt)
get dfu entity for an alternate id
Parameters
int alt
alternate id
Return
dfu entity
-
intdfu_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)
-
intdfu_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
-
intdfu_read(structdfu_entity*de, void*buf, intsize, intblk_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
-
intdfu_write(structdfu_entity*de, void*buf, intsize, intblk_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
-
intdfu_flush(structdfu_entity*de, void*buf, intsize, intblk_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
-
voiddfu_initiated_callback(structdfu_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.
-
voiddfu_flush_callback(structdfu_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
-
voiddfu_error_callback(structdfu_entity*dfu, constchar*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
-
structdfu_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
-
voiddfu_set_defer_flush(structdfu_entity*dfu)
set the dfu_defer_flush pointer
Parameters
struct dfu_entity *dfu
pointer to the dfu_entity, which should be written
-
intdfu_write_from_mem_addr(structdfu_entity*dfu, void*buf, intsize)
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
-
intdfu_write_by_name(char*dfu_entity_name, void*addr, unsignedintlen, 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
-
intdfu_write_by_alt(intdfu_alt_num, void*addr, unsignedintlen, 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