#define BCB_PART_NAME "misc"
#define BOOT_PART_NAME "boot"
#define VENDOR_BOOT_PART_NAME "vendor_boot"
+#define SLOT_LEN 2
/**
* struct android_priv - Private data
*/
struct android_priv {
enum android_boot_mode boot_mode;
- char slot[2];
+ char *slot;
u32 header_version;
};
char *buf;
int ret;
- sprintf(partname, BOOT_PART_NAME "_%s", priv->slot);
+ if (priv->slot)
+ sprintf(partname, BOOT_PART_NAME "_%s", priv->slot);
+ else
+ sprintf(partname, BOOT_PART_NAME);
+
ret = part_get_info_by_name(desc, partname, &partition);
if (ret < 0)
return log_msg_ret("part info", ret);
char *buf;
int ret;
- sprintf(partname, VENDOR_BOOT_PART_NAME "_%s", priv->slot);
+ if (priv->slot)
+ sprintf(partname, VENDOR_BOOT_PART_NAME "_%s", priv->slot);
+ else
+ sprintf(partname, VENDOR_BOOT_PART_NAME);
+
ret = part_get_info_by_name(desc, partname, &partition);
if (ret < 0)
return log_msg_ret("part info", ret);
char slot_suffix[3];
int ret;
+ if (!CONFIG_IS_ENABLED(ANDROID_AB)) {
+ priv->slot = NULL;
+ return 0;
+ }
+
ret = part_get_info_by_name(desc, BCB_PART_NAME, &misc);
if (ret < 0)
return log_msg_ret("part", ret);
if (ret < 0)
return log_msg_ret("slot", ret);
+ priv->slot = malloc(SLOT_LEN);
priv->slot[0] = BOOT_SLOT_NAME(ret);
priv->slot[1] = '\0';
configure_serialno(bflow);
configure_bootloader_version(bflow);
- if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL) {
+ if (priv->boot_mode == ANDROID_BOOT_MODE_NORMAL && priv->slot) {
ret = bootflow_cmdline_set_arg(bflow, "androidboot.force_normal_boot",
"1", false);
if (ret < 0) {
{
struct disk_partition partition;
char partname[PART_NAME_LEN];
+ size_t partname_len;
int ret;
u32 n;
- /* Ensure name fits in partname it should be: <name>_<slot>\0 */
- if (strlen(name) > (PART_NAME_LEN - 2 - 1))
+ /*
+ * Ensure name fits in partname.
+ * For A/B, it should be <name>_<slot>\0
+ * For non A/B, it should be <name>\0
+ */
+ if (CONFIG_IS_ENABLED(ANDROID_AB))
+ partname_len = PART_NAME_LEN - 2 - 1;
+ else
+ partname_len = PART_NAME_LEN - 1;
+
+ if (strlen(name) > partname_len)
return log_msg_ret("name too long", -EINVAL);
- sprintf(partname, "%s_%s", name, slot);
+ if (slot)
+ sprintf(partname, "%s_%s", name, slot);
+ else
+ sprintf(partname, "%s", name);
+
ret = part_get_info_by_name(desc, partname, &partition);
if (ret < 0)
return log_msg_ret("part", ret);
AvbSlotVerifyData *out_data;
enum avb_boot_state boot_state;
char *extra_args;
- char slot_suffix[3];
+ char slot_suffix[3] = "";
bool unlocked = false;
int ret;
if (!avb_ops)
return log_msg_ret("avb ops", -ENOMEM);
- sprintf(slot_suffix, "_%s", priv->slot);
+ if (priv->slot)
+ sprintf(slot_suffix, "_%s", priv->slot);
ret = avb_ops->read_is_device_unlocked(avb_ops, &unlocked);
if (ret != AVB_IO_RESULT_OK)
}
set_abootimg_addr(loadaddr);
+ if (priv->slot)
+ free(priv->slot);
+
ret = bootm_boot_start(loadaddr, bflow->cmdline);
return log_msg_ret("boot", ret);