author | Xindong Xu <xindong.xu@amlogic.com> | 2019-06-25 07:54:59 (GMT) |
---|---|---|
committer | Xindong Xu <xindong.xu@amlogic.com> | 2019-07-03 02:51:29 (GMT) |
commit | 848957626a4badfdef92fe144ca7d2aef879a49f (patch) | |
tree | b1f5c2958241b2086575eedeba86bb93dfd21bbe | |
parent | 1061f1f47c61b2783764bcb64f80c49d647cff54 (diff) | |
download | uboot-848957626a4badfdef92fe144ca7d2aef879a49f.zip uboot-848957626a4badfdef92fe144ca7d2aef879a49f.tar.gz uboot-848957626a4badfdef92fe144ca7d2aef879a49f.tar.bz2 |
fastboot: support dynamic partition [2/9]
PD#SWPL-6548
Problem:
android Q need to support dynamic partition
Solution:
we can only burn physics partition in bootloader
such as: boot/recovery/dts/dtbo/logo
others must burned by fastbootd
verify:
franklin
Change-Id: Ic916a1ca62f6f601ac7f57ae54ffcac9d1568590
-rw-r--r-- | common/partitions.c | 7 | ||||
-rw-r--r-- | drivers/usb/gadget/f_fastboot.c | 97 | ||||
-rw-r--r-- | include/partition_table.h | 1 |
3 files changed, 89 insertions, 16 deletions
diff --git a/common/partitions.c b/common/partitions.c index c3078dc..e14bb4c 100644 --- a/common/partitions.c +++ b/common/partitions.c @@ -21,6 +21,7 @@ struct partitions *part_table = NULL; static int parts_total_num; int has_boot_slot = 0; int has_system_slot = 0; +bool dynamic_partition = false; int get_partitions_table(struct partitions **table) @@ -100,6 +101,7 @@ int get_partition_from_dts(unsigned char *buffer) memset(part_table, 0, sizeof(struct partitions)*(be32_to_cpup((u32*)parts_num))); parts_total_num = be32_to_cpup((u32*)parts_num); } + dynamic_partition = false; for (index = 0; index < be32_to_cpup((u32*)parts_num); index++) { sprintf(propname,"part-%d", index); @@ -142,6 +144,11 @@ int get_partition_from_dts(unsigned char *buffer) has_system_slot = 1; else if (strcmp(uname, "system") == 0) has_system_slot = 0; + + if (strcmp(uname, "super") == 0) { + dynamic_partition = true; + printf("enable dynamic_partition\n"); + } } return 0; diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c index 0e30bf1..b476545 100644 --- a/drivers/usb/gadget/f_fastboot.c +++ b/drivers/usb/gadget/f_fastboot.c @@ -567,6 +567,36 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) strncat(response, "yes", chars_left); } else if (!strcmp_l1("battery-voltage", cmd)) { strncat(response, "4.2V", chars_left); + } else if (!strcmp_l1("is-userspace", cmd)) { + strncat(response, "no", chars_left); + } else if (!strcmp_l1("is-logical", cmd)) { + strsep(&cmd, ":"); + printf("partition is %s\n", cmd); + if (!dynamic_partition) { + strncat(response, "no", chars_left); + } else { + if ((strcmp(cmd, "system") == 0) || (strcmp(cmd, "vendor") == 0) + || (strcmp(cmd, "odm") == 0) || (strcmp(cmd, "product") == 0)) { + strncat(response, "yes", chars_left); + } else { + strncat(response, "no", chars_left); + } + } + } else if (!strcmp_l1("super-partition-name", cmd)) { + char *slot_name; + slot_name = getenv("slot-suffixes"); + if (has_boot_slot == 0) { + strncat(response, "super", chars_left); + } else { + printf("slot-suffixes: %s\n", slot_name); + if (strcmp(slot_name, "0") == 0) { + printf("active_slot is %s\n", "a"); + strncat(response, "super_a", chars_left); + } else if (strcmp(slot_name, "1") == 0) { + printf("active_slot is %s\n", "b"); + strncat(response, "super_b", chars_left); + } + } } else if (!strcmp_l1("downloadsize", cmd) || !strcmp_l1("max-download-size", cmd)) { char str_num[12]; @@ -618,29 +648,55 @@ static void cb_getvar(struct usb_ep *ep, struct usb_request *req) } else strncat(response, "no", chars_left); } else if (!strcmp_l1("has-slot:system", cmd)) { - if (has_system_slot == 1) { - printf("has system slot\n"); - strncat(response, "yes", chars_left); - } else + if (dynamic_partition) { strncat(response, "no", chars_left); + } else { + if (has_system_slot == 1) { + printf("has system slot\n"); + strncat(response, "yes", chars_left); + } else + strncat(response, "no", chars_left); + } } else if (!strcmp_l1("has-slot:vendor", cmd)) { - if (has_boot_slot == 1) { - printf("has vendor slot\n"); - strncat(response, "yes", chars_left); - } else + if (dynamic_partition) { strncat(response, "no", chars_left); + } else { + if (has_boot_slot == 1) { + printf("has vendor slot\n"); + strncat(response, "yes", chars_left); + } else + strncat(response, "no", chars_left); + } } else if (!strcmp_l1("has-slot:vbmeta", cmd)) { - if (has_boot_slot == 1) { - printf("has vbmeta slot\n"); - strncat(response, "yes", chars_left); - } else + if (dynamic_partition) { strncat(response, "no", chars_left); + } else { + if (has_boot_slot == 1) { + printf("has vbmeta slot\n"); + strncat(response, "yes", chars_left); + } else + strncat(response, "no", chars_left); + } } else if (!strcmp_l1("has-slot:product", cmd)) { - if (has_boot_slot == 1) { - printf("has product slot\n"); - strncat(response, "yes", chars_left); - } else + if (dynamic_partition) { strncat(response, "no", chars_left); + } else { + if (has_boot_slot == 1) { + printf("has product slot\n"); + strncat(response, "yes", chars_left); + } else + strncat(response, "no", chars_left); + } + } else if (!strcmp_l1("has-slot:super", cmd)) { + if (!dynamic_partition) { + strncat(response, "no", chars_left); + } else { + if (has_boot_slot == 1) { + printf("has product slot\n"); + strncat(response, "yes", chars_left); + } else + strncat(response, "no", chars_left); + } } else if (!strcmp_l1("has-slot:metadata", cmd)) { if (has_boot_slot == 1) { printf("has metadata slot\n"); @@ -1120,6 +1176,15 @@ static void cb_flash(struct usb_ep *ep, struct usb_request *req) return; } + if (dynamic_partition) { + if ((strcmp(cmd, "system") == 0) || (strcmp(cmd, "vendor") == 0) + || (strcmp(cmd, "odm") == 0) || (strcmp(cmd, "product") == 0)) { + error("system/vendor/odm/product is logic partition, can not write here\n"); + fastboot_tx_write_str("FAILlogic partition"); + return; + } + } + printf("partition is %s\n", cmd); if (strcmp(cmd, "userdata") == 0) { strcpy(cmd, "data"); diff --git a/include/partition_table.h b/include/partition_table.h index f4c89a5..9a6744d 100644 --- a/include/partition_table.h +++ b/include/partition_table.h @@ -54,6 +54,7 @@ extern int info_disprotect; extern int has_boot_slot; extern int has_system_slot; +extern bool dynamic_partition; #define DISPROTECT_KEY 1 #define DISPROTECT_SECURE 1<<1 |