Merge branch 'next-dev' into thunder-boot

This commit is contained in:
Joseph Chen 2020-05-06 18:29:50 +08:00
commit ab6f8011c4
4 changed files with 31 additions and 61 deletions

View File

@ -242,26 +242,24 @@ out:
return 0; return 0;
} }
int spl_get_partitions_sector(struct blk_desc *dev_desc, char *partition, int spl_ab_append_part_slot(struct blk_desc *dev_desc,
u32 *sectors) const char *part_name,
char *new_name)
{ {
disk_partition_t part_info; char slot_suffix[3] = {0};
char part[10] = {0};
char slot[3] = {0};
if (!partition || !sectors) if (!strcmp(part_name, "misc")) {
return -EFAULT; strcat(new_name, part_name);
return 0;
}
spl_get_current_slot(dev_desc, "misc", slot); if (spl_get_current_slot(dev_desc, "misc", slot_suffix)) {
if (strlen(partition) > 8) printf("%s: failed to get slot suffix !\n", __func__);
return -ENOMEM; return -1;
}
strcat(part, partition); strcpy(new_name, part_name);
strcat(part, slot); strcat(new_name, slot_suffix);
if (part_get_info_by_name(dev_desc, part, &part_info) < 0)
return -ENODEV;
*sectors = part_info.start;
return 0; return 0;
} }

View File

@ -9,7 +9,6 @@
#include <common.h> #include <common.h>
#include <dm.h> #include <dm.h>
#include <spl.h> #include <spl.h>
#include <spl_ab.h>
#include <spl_rkfw.h> #include <spl_rkfw.h>
#include <linux/compiler.h> #include <linux/compiler.h>
#include <errno.h> #include <errno.h>
@ -74,15 +73,6 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image,
load.bl_len = mmc->read_bl_len; load.bl_len = mmc->read_bl_len;
load.read = h_spl_load_read; load.read = h_spl_load_read;
#ifdef CONFIG_SPL_AB
char trust_partition[] = "trust";
char uboot_partition[] = "uboot";
spl_get_partitions_sector(mmc_get_blk_desc(mmc), trust_partition,
&trust_sectors);
spl_get_partitions_sector(mmc_get_blk_desc(mmc), uboot_partition,
&uboot_sectors);
#endif
ret = spl_load_rkfw_image(spl_image, &load, ret = spl_load_rkfw_image(spl_image, &load,
trust_sectors, trust_sectors,
uboot_sectors, uboot_sectors,

View File

@ -11,6 +11,9 @@
#include <ide.h> #include <ide.h>
#include <malloc.h> #include <malloc.h>
#include <part.h> #include <part.h>
#ifdef CONFIG_SPL_AB
#include <spl_ab.h>
#endif
#include <ubifs_uboot.h> #include <ubifs_uboot.h>
#ifdef CONFIG_ANDROID_AB #ifdef CONFIG_ANDROID_AB
#include <android_avb/avb_ops_user.h> #include <android_avb/avb_ops_user.h>
@ -671,7 +674,6 @@ cleanup:
return ret; return ret;
} }
#ifdef CONFIG_ANDROID_AB
/* /*
* For android A/B system, we append the current slot suffix quietly, * For android A/B system, we append the current slot suffix quietly,
* this takes over the responsibility of slot suffix appending from * this takes over the responsibility of slot suffix appending from
@ -688,14 +690,18 @@ int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
part_drv = part_driver_lookup_type(dev_desc); part_drv = part_driver_lookup_type(dev_desc);
if (!part_drv) if (!part_drv)
return -1; return -1;
#ifndef CONFIG_SPL_BUILD #if defined(CONFIG_ANDROID_AB) && !defined(CONFIG_SPL_BUILD)
/* 1. Query partition with A/B slot suffix */ /* 1. Query partition with A/B slot suffix */
if (rk_avb_append_part_slot(name, name_slot)) if (rk_avb_append_part_slot(name, name_slot))
return -1; return -1;
#elif defined(CONFIG_SPL_AB) && defined(CONFIG_SPL_BUILD)
if (spl_ab_append_part_slot(dev_desc, name, name_slot))
return -1;
#else
strcpy(name_slot, name);
#endif #endif
retry: retry:
debug("## Query partition(%d): %s\n", none_slot_try, name_slot); debug("## Query partition(%d): %s\n", none_slot_try, name_slot);
for (i = 1; i < part_drv->max_entries; i++) { for (i = 1; i < part_drv->max_entries; i++) {
ret = part_drv->get_info(dev_desc, i, info); ret = part_drv->get_info(dev_desc, i, info);
if (ret != 0) { if (ret != 0) {
@ -718,33 +724,6 @@ retry:
return -1; return -1;
} }
#else
int part_get_info_by_name(struct blk_desc *dev_desc, const char *name,
disk_partition_t *info)
{
struct part_driver *part_drv;
int ret;
int i;
part_drv = part_driver_lookup_type(dev_desc);
if (!part_drv)
return -1;
for (i = 1; i < part_drv->max_entries; i++) {
ret = part_drv->get_info(dev_desc, i, info);
if (ret != 0) {
/* no more entries in table */
break;
}
if (strcmp(name, (const char *)info->name) == 0) {
/* matched */
return i;
}
}
return -1;
}
#endif
void part_set_generic_name(const struct blk_desc *dev_desc, void part_set_generic_name(const struct blk_desc *dev_desc,
int part_num, char *name) int part_num, char *name)
{ {

View File

@ -24,13 +24,16 @@ int spl_get_current_slot(struct blk_desc *dev_desc, char *partition,
char *slot); char *slot);
/* /*
* spl_get_partitions_sector * spl_ab_append_part_slot
* *
* @dev_desc: block description * @dev_desc: block description
* @partition: partition name * @part_name: partition name
* @sectors: firmware load address * @new_name: append the slot suffix
*
* return: 0 success, others fail.
*/ */
int spl_get_partitions_sector(struct blk_desc *dev_desc, char *partition, int spl_ab_append_part_slot(struct blk_desc *dev_desc,
u32 *sectors); const char *part_name,
char *new_name);
#endif #endif