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);
|
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
|
* The android things defines permanent attributes to
|
||||||
* store PSK_public, product id. We can use this function
|
* 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;
|
AvbIOResult io_ret = AVB_IO_RESULT_OK;
|
||||||
AvbABData ab_data;
|
AvbABData ab_data;
|
||||||
size_t slot_index_to_boot;
|
size_t slot_index_to_boot;
|
||||||
|
static int last_slot_index = -1;
|
||||||
|
|
||||||
io_ret = ab_ops->read_ab_metadata(ab_ops, &ab_data);
|
io_ret = ab_ops->read_ab_metadata(ab_ops, &ab_data);
|
||||||
if (io_ret != AVB_IO_RESULT_OK) {
|
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) {
|
} else if(slot_index_to_boot == 1) {
|
||||||
strcpy(select_slot, "_b");
|
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:
|
out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -172,6 +181,26 @@ int rk_avb_get_current_slot(char *select_slot)
|
||||||
return ret;
|
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)
|
int rk_avb_read_permanent_attributes(uint8_t *attributes, uint32_t size)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_OPTEE_CLIENT
|
#ifdef CONFIG_OPTEE_CLIENT
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue