lib: avb: add partition slot append interface
Dump current slot information is helpful. Change-Id: I872c29b9a67860703951a4e88e9549be17b94eed Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
This commit is contained in:
parent
0ed06f16e2
commit
eb89f0a81d
|
|
@ -76,6 +76,17 @@ int rk_avb_set_slot_active(unsigned int *slot_number);
|
|||
*/
|
||||
int rk_avb_get_current_slot(char *select_slot);
|
||||
|
||||
/**
|
||||
* Append current slot to given partition name
|
||||
*
|
||||
* @param part_name partition name
|
||||
* @param slot given slot suffix, auto append current slot if NULL
|
||||
* @param new_name partition name with slot suffix appended
|
||||
*
|
||||
* @return 0 if the command succeeded, -1 if it failed
|
||||
*/
|
||||
int rk_avb_append_part_slot(const char *part_name, char *new_name);
|
||||
|
||||
/**
|
||||
* The android things defines permanent attributes to
|
||||
* store PSK_public, product id. We can use this function
|
||||
|
|
|
|||
|
|
@ -112,6 +112,7 @@ AvbABFlowResult rk_avb_ab_slot_select(AvbABOps* ab_ops,char* select_slot)
|
|||
AvbIOResult io_ret = AVB_IO_RESULT_OK;
|
||||
AvbABData ab_data;
|
||||
size_t slot_index_to_boot;
|
||||
static int last_slot_index = -1;
|
||||
|
||||
io_ret = ab_ops->read_ab_metadata(ab_ops, &ab_data);
|
||||
if (io_ret != AVB_IO_RESULT_OK) {
|
||||
|
|
@ -140,6 +141,14 @@ AvbABFlowResult rk_avb_ab_slot_select(AvbABOps* ab_ops,char* select_slot)
|
|||
} else if(slot_index_to_boot == 1) {
|
||||
strcpy(select_slot, "_b");
|
||||
}
|
||||
|
||||
if (last_slot_index != slot_index_to_boot) {
|
||||
last_slot_index = slot_index_to_boot;
|
||||
printf("A/B-slot: %s, successful: %d, tries-remain: %d\n",
|
||||
select_slot,
|
||||
ab_data.slots[slot_index_to_boot].successful_boot,
|
||||
ab_data.slots[slot_index_to_boot].tries_remaining);
|
||||
}
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -172,6 +181,26 @@ int rk_avb_get_current_slot(char *select_slot)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int rk_avb_append_part_slot(const char *part_name, char *new_name)
|
||||
{
|
||||
char slot_suffix[3] = {0};
|
||||
|
||||
if (!strcmp(part_name, "misc")) {
|
||||
strcat(new_name, part_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (rk_avb_get_current_slot(slot_suffix)) {
|
||||
printf("%s: failed to get slot suffix !\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
strcpy(new_name, part_name);
|
||||
strcat(new_name, slot_suffix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rk_avb_read_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||
{
|
||||
#ifdef CONFIG_OPTEE_CLIENT
|
||||
|
|
|
|||
Loading…
Reference in New Issue