MA-16954 set partition type to efi after flash gpt partition
authorfaqiang.zhu <faqiang.zhu@nxp.com>
Tue, 14 Apr 2020 07:44:58 +0000 (15:44 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
If the target device have DOS partition, uboot will save the partition
type as dos partition at early stage when the driver bind the device.
After the gpt partition is flashed, uboot will try to reload the DOS
partition, instead of the the EFI partition.

In this commit, if the GPT partition is successfully flashed, set the
partition type to be PART_TYPE_EFI if necessary, so the EFI partitions
will be reloaded.

Change-Id: I6095cb56c73aecee24f76d169db89daba3783e29
Signed-off-by: faqiang.zhu <faqiang.zhu@nxp.com>
(cherry picked from commit 62becd667e5f3ebbefef796818eda78f4d0e167b)
(cherry picked from commit 358efa24b714738ce145fa60f0b4d194b68c4c49)

drivers/fastboot/fb_fsl/fb_fsl_command.c

index 2cce088..d208672 100644 (file)
@@ -831,6 +831,18 @@ static void flash(char *cmd, char *response)
 #if defined(CONFIG_FASTBOOT_LOCK)
        if (strncmp(cmd, "gpt", 3) == 0) {
                int gpt_valid = 0;
+               int mmc_no;
+               struct blk_desc *dev_desc;
+               mmc_no = fastboot_devinfo.dev_id;
+               dev_desc = blk_get_dev("mmc", mmc_no);
+               if (dev_desc) {
+                       if (dev_desc->part_type != PART_TYPE_EFI)
+                               dev_desc->part_type = PART_TYPE_EFI;
+               }
+               else {
+                       fastboot_fail("", response);
+                       return;
+               }
                gpt_valid = partition_table_valid();
                /* If gpt is valid, load partitons table into memory.
                   So if the next command is "fastboot reboot bootloader",