- int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-
- {
-
- if (set_partition_table())
-
-
-
- ---------------------------------------->
-
-
-
-
- strcpy(ptable[pcount].name, "bootloader");
-
- ptable[pcount].start = 0;
-
- ptable[pcount].length = 0;
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD;
-
- pcount++;
-
-
-
-
-
- strcpy(ptable[pcount].name, "kernel");
-
- ptable[pcount].start = 0;
-
- ptable[pcount].length = 0;
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD;
-
- pcount++;
-
-
-
-
-
- strcpy(ptable[pcount].name, "ramdisk");
-
- ptable[pcount].start = 0;
-
- ptable[pcount].length = 0x300000;
-
-
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MOVI_CMD;
-
- pcount++;
-
- -----------------------
-
-
-
- get_mmc_part_info("0", 2, &start, &count, &pid);
-
- -------------------------
-
- if (pid != 0x83)
-
- goto part_type_error;
-
- strcpy(ptable[pcount].name, "system");
-
-
-
-
-
-
-
-
-
-
-
-
-
- ptable[pcount].start = start * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
-
-
- ptable[pcount].length = count * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
-
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
-
- pcount++;
-
-
-
-
-
- get_mmc_part_info("0", 3, &start, &count, &pid);
-
- if (pid != 0x83)
-
- goto part_type_error;
-
- strcpy(ptable[pcount].name, "userdata");
-
- ptable[pcount].start = start * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].length = count * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
-
- pcount++;
-
-
-
-
-
- get_mmc_part_info("0", 4, &start, &count, &pid);
-
- if (pid != 0x83)
-
- goto part_type_error;
-
- strcpy(ptable[pcount].name, "cache");
-
- ptable[pcount].start = start * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].length = count * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
-
- pcount++;
-
-
-
-
-
- get_mmc_part_info("0", 1, &start, &count, &pid);
-
- if (pid != 0xc)
-
- goto part_type_error;
-
- strcpy(ptable[pcount].name, "fat");
-
- ptable[pcount].start = start * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].length = count * CFG_FASTBOOT_SDMMC_BLOCKSIZE;
-
- ptable[pcount].flags = FASTBOOT_PTENTRY_FLAGS_USE_MMC_CMD;
-
- pcount++;
-
-
-
- -------------->
- <PRE class=cpp name="code">---------------------------->
-
- int get_mmc_part_info(char *device_name, int part_num, int *block_start, int *block_count, unsigned char *part_Id)
- {
- int rv;
- PartitionInfo partInfo;
- unsigned char mbr[512];
-
- rv = get_mmc_mbr(device_name, mbr);
-
- if(rv !=0)
- return -1;
-
- switch(part_num)
- {
-
- case 1:
- decode_partitionInfo(&mbr[0x1BE], &partInfo);
- *block_start = partInfo.block_start;
- *block_count = partInfo.block_count;
- *part_Id = partInfo.partitionId;
- break;
-
- case 2:
- decode_partitionInfo(&mbr[0x1CE], &partInfo);
- *block_start = partInfo.block_start;
- *block_count = partInfo.block_count;
- *part_Id = partInfo.partitionId;
- break;
-
- case 3:
- decode_partitionInfo(&mbr[0x1DE], &partInfo);
- *block_start = partInfo.block_start;
- *block_count = partInfo.block_count;
- *part_Id = partInfo.partitionId;
- break;
-
- case 4:
- decode_partitionInfo(&mbr[0x1EE], &partInfo);
- *block_start = partInfo.block_start;
- *block_count = partInfo.block_count;
- *part_Id = partInfo.partitionId;
- break;
- default:
- return -1;
- }
-
- return 0;
- }
-
- if (memcmp(cmdbuf, "erase:", 6) == 0)
- {
- struct fastboot_ptentry *ptn;
-
- ptn = fastboot_flash_find_ptn(cmdbuf + 6);
- if (ptn == 0)
-
- ------------------------------------------------------------
-
- fastboot_ptentry *fastboot_flash_find_ptn(const char *name)
- {
- unsigned int n;
-
- for (n = 0; n < pcount; n++)
- {
-
- if (strlen(name) == strlen(ptable[n].name))
- {
- if (0 == strcmp(ptable[n].name, name))
- return ptable + n;
- }
- }
- return 0;
- }
- -------------------------------------------------------
-
-
-
- char run_cmd[80];
- status = 1;
-
- if (!strcmp(ptn->name, "sytem"))
- {
- sprintf(run_cmd, "ext3format mmc 0:2");
- status = run_command(run_cmd, 0);
- }
- Else if (!strcmp(ptn->name, "userdata"))
- {
- sprintf(run_cmd, "ext3format mmc 0:3");
- status = run_command(run_cmd, 0);
- }
- else if (!strcmp(ptn->name, "cache"))
- {
- sprintf(run_cmd, "ext3format mmc 0:4");
- status = run_command(run_cmd, 0);
- }
- else if (!strcmp(ptn->name, "fat"))
- {
- sprintf(run_cmd, "fatformat mmc 0:1");
- status = run_command(run_cmd, 0);
- }
- =======================================================
- </PRE>
- <P><BR>
- </P>
- <PRE class=cpp name="code">Flash what was downloaded */
- if (memcmp(cmdbuf, "flash:", 6) == 0)
- {
- if (download_bytes == 0)
- {
- sprintf(response, "FAILno image downloaded");
- ret = 0;
- goto send_tx_status;
- }
-
- ptn = fastboot_flash_find_ptn(cmdbuf + 6);
- ----------------------
- if ((download_bytes > ptn->length) && (ptn->length != 0) &&
- !(ptn->flags & FASTBOOT_PTENTRY_FLAGS_WRITE_ENV))
- {
-
- sprintf(response, "FAILimage too large for partition");
-
- }
- else
- {
-
- if (write_to_ptn(ptn, (unsigned int)interface.transfer_buffer, download_bytes))
- {
- printf("flashing '%s' failed\n", ptn->name);
- sprintf(response, "FAILfailed to flash partition");
- }
- else
- {
- printf("partition '%s' flashed\n", ptn->name);
- sprintf(response, "OKAY");
- }
- }
- -------------------------------------------
http://blog.csdn.net/yunfly163/article/details/7496869