common: fastboot: support fat boot partition
authorChanho Park <chanho61.park@samsung.com>
Wed, 5 Aug 2015 10:11:14 +0000 (19:11 +0900)
committerChanho Park <chanho61.park@samsung.com>
Wed, 5 Aug 2015 10:11:14 +0000 (19:11 +0900)
This patch supports a boot partition which is formatted to fat file
system. The boot partition contains a kernel, dtb and initrd image. The
file can be retrived from u-boot environment variables. To avoid
conflict android's boot partition, just disables the android boot
partition.

Change-Id: I5c275ce61b211aef8e39701daabaa79527ac865d
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
common/cmd_fastboot.c
include/fastboot.h

index d370c8e08fdb8b1a0898a37176fe4669e6275a8f..e9732ca42d6373e8e589324f4211802fed3270ee 100644 (file)
@@ -577,7 +577,7 @@ static int write_to_ptn_sdmmc(struct fastboot_ptentry *ptn, unsigned int addr,
 {
        int ret = 1;
        char cmd[32], device[32], part[32], part2[32];
-       char start[32], length[32], buffer[32], run_cmd[32];
+       char start[32], length[32], buffer[32], run_cmd[64];
        char dev_num[2];
        char *argv[6]  = { NULL, NULL, NULL, NULL, NULL, NULL, };
        int argc = 0;
@@ -605,6 +605,21 @@ static int write_to_ptn_sdmmc(struct fastboot_ptentry *ptn, unsigned int addr,
                                ptn->start / CFG_FASTBOOT_SDMMC_BLOCKSIZE,
                                size / CFG_FASTBOOT_SDMMC_BLOCKSIZE,
                                is_sparse);
+       } else if (ptn->flags & FASTBOOT_PTENTRY_FLAGS_USE_FAT_CMD) {
+               char *file_name;
+
+               if (!strcmp(ptn->name, "kernel"))
+                       file_name = getenv("kernel_file");
+               else if (!strcmp(ptn->name, "dtb"))
+                       file_name = getenv("fdtfile");
+               else if (!strcmp(ptn->name, "ramdisk"))
+                       file_name = getenv("initrd_file");
+               else
+                       return -1;
+
+               sprintf(run_cmd, "fatwrite mmc %d:1 0x%x %s 0x%x",
+                       DEV_NUM, addr, file_name, size);
+               ret = run_command(run_cmd, 0);
        } else if (ptn->flags & FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD) {
                argv[2] = part;
                argv[3] = dev_num;
@@ -1350,9 +1365,11 @@ static int process_cmd_flash(const char *cmdbuf, char *response)
        LCD_setprogress(100);
 #endif
 
+#ifdef CONFIG_ANDROID_PARTITIONS
        /* Special case: boot.img */
        if (!strcmp("boot", cmdbuf + 6))
                return process_cmd_flash_boot(cmdbuf, response);
+#endif
 
        ptn = fastboot_flash_find_ptn(cmdbuf + 6);
        if (ptn == 0)
@@ -1495,7 +1512,6 @@ static int rx_handler (const unsigned char *buffer, unsigned int buffer_size)
                LCD_setprogress(0);
 #endif
        } /* End of command */
-
 ret_free:
        free(response);
        return ret;
@@ -1828,14 +1844,21 @@ static int set_partition_table_sdmmc()
        strcpy(ptable[pcount].name, "kernel");
        ptable[pcount].start = 0;
        ptable[pcount].length = 0;
-       ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD;
+       ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_FAT_CMD;
        pcount++;
 
        /* Ramdisk */
        strcpy(ptable[pcount].name, "ramdisk");
        ptable[pcount].start = 0;
        ptable[pcount].length = PART_SIZE_ROOTFS;
-       ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD;
+       ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_FAT_CMD;
+       pcount++;
+
+       /* Devicetree */
+       strcpy(ptable[pcount].name, "dtb");
+       ptable[pcount].start = 0;
+       ptable[pcount].length = 0;
+       ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_FAT_CMD;
        pcount++;
 
 #ifdef CONFIG_CHARGER_LOGO
index b02173384af4597f216c2ec0125392ae842e7459..dd90b79652d40beb273ca9adc84fc4a7517396e3 100644 (file)
@@ -213,6 +213,9 @@ struct fastboot_ptentry
 /* Download and imediately flash this partition */
 #define FASTBOOT_PTENTRY_FLAGS_FLASH_CHUNK            0x00040000
 
+/* Use fat command to read/write this file */
+#define FASTBOOT_PTENTRY_FLAGS_USE_FAT_CMD            0x00080000
+
 /* Status values */
 #define FASTBOOT_OK                    0
 #define FASTBOOT_ERROR                 -1