Revert "fastboot: clean hibernate image when update uboot/kernel/rootfs partition"
authorHan Gao <gaohan@iscas.ac.cn>
Thu, 16 May 2024 05:28:15 +0000 (13:28 +0800)
committerHan Gao <rabenda.cn@gmail.com>
Wed, 29 May 2024 08:21:44 +0000 (16:21 +0800)
This reverts commit 3a7b5088eef6eed95537e5a5732f9c08095a559e.

drivers/fastboot/fb_command.c

index cd27679f778e6d97cb87a970380fd658153d177b..92b33b893c7c5e258432c6c5921455fc83e6a217 100644 (file)
@@ -294,56 +294,6 @@ int check_image_board_id(uint8_t *image_data)
        return 0;
 }
 
-int hibernate_image_cleaned_flag = 0;
-static void clean_hibernate_image_header(char *response)
-{
-       struct blk_desc *dev_desc;
-       disk_partition_t info;
-       if(0x03 == hibernate_image_cleaned_flag) //already erased all
-       {
-               return;
-       }
-       dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
-       if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
-               fastboot_fail("invalid mmc device", response);
-               return;
-       }
-       char * buf = memalign(CONFIG_SYS_CACHELINE_SIZE,4096);
-       if(!buf) {
-               printf(" mem alloc for hibernate partition header failed!\n");
-               return;
-       }
-       /* if fastresume partition exists, earse the old image header */
-       if(part_get_info_by_name(dev_desc, "fastresume", &info)) {
-               printf(" find fastresume partition , erase the header:\n");
-               memset(buf,0xff,4096);
-               if(blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf) != 4096/info.blksz)
-               {
-                       printf(" fastresume header write failed!\n");
-                       hibernate_image_cleaned_flag = 0;
-               }
-               else
-               {
-                       hibernate_image_cleaned_flag |= 0x1;
-               }
-       }
-       /* if swap partition exists, earse the old image header */
-       if(part_get_info_by_name(dev_desc, "swap", &info)) {
-               printf(" find swap partition , erase the header:\n");
-               memset(buf,0xff,4096);
-               if(blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf) != 4096/info.blksz)
-               {
-                       printf(" swap header write failed!\n");
-                       hibernate_image_cleaned_flag = 0;
-               }
-               else
-               {
-                       hibernate_image_cleaned_flag |= 0x2;
-               }
-       }
-       free(buf);
-}
-
 #if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
 /**
  * flash() - write the downloaded image to the indicated partition.
@@ -402,16 +352,25 @@ static void flash(char *cmd_parameter, char *response)
                memcpy((void *)LIGHT_TF_FW_ADDR, fastboot_buf_addr, image_size);
        } else if ((strcmp(cmd_parameter, TEE_PART_NAME) == 0)) {
                memcpy((void *)LIGHT_TEE_FW_ADDR, fastboot_buf_addr, image_size);
+       } else if ((strcmp(cmd_parameter, "boot") == 0)) {
+               dev_desc = blk_get_dev("mmc", CONFIG_FASTBOOT_FLASH_MMC_DEV);
+               if (!dev_desc || dev_desc->type == DEV_TYPE_UNKNOWN) {
+                       fastboot_fail("invalid mmc device", response);
+                       return;
+        }
+               /* if fastresume partition exists, earse the old image header */
+               if(part_get_info_by_name(dev_desc, "fastresume", &info)) {
+                       printf(" find fastresume partition , erase the header:\n");
+                       char * buf = memalign(CONFIG_SYS_CACHELINE_SIZE,4096);
+                       if(!buf) {
+                               printf(" fastresume partition header mem alloc failed\n");
+                               return;
+                       }
+                       memset(buf,0xff,4096);
+                       blk_dwrite(dev_desc, info.start, 4096/info.blksz, buf);
+                       free(buf);
+               }
        }
-
-       //If version is updated, hibernate image may not compatible with current,erase it.
-       if ((strcmp(cmd_parameter, "boot") == 0)
-               || (strcmp(cmd_parameter, "uboot") == 0)
-               || (strcmp(cmd_parameter, "root") == 0)) {
-
-               clean_hibernate_image_header(response);
-       }
-
        if(strcmp(cmd_parameter, "uboot") == 0 || (strcmp(cmd_parameter, "fw") == 0) ||
           (strcmp(cmd_parameter, "uImage") == 0) || (strcmp(cmd_parameter, "dtb") == 0) ||
           (strcmp(cmd_parameter, "rootfs") == 0) || (strcmp(cmd_parameter, "aon") == 0)) {