前阵和人家合作开发下载工具。我这边负责修改uboot,人家负责windows下载工具的开发。这里需要使用sdfuse flashall命令。
先看看sdfuse命令。
U_BOOT_CMD(
sdfuse, 4, 1, do_sdfuse,
"sdfuse - read images from FAT partition of SD card and write them to booting device.\n",
"info - print primitive infomation.\n"
"sdfuse flashall - flash boot.img, system.img,\n"
" erase userdata, cache, and reboot.\n"
"sdfuse flash <partition> [ <filename> ] - write a file to a partition.\n"
"sdfuse erase <partition> - erase (format) a partition.\n"
);
这个结构体是uboot下加命令时必须的。它会将所加的命令放在某一地址段里。执行时候回去查询。
接着追看 sdfuse flashall
......
else if ((argc == 2) && !strcmp(argv[1], "flashall"))
{
LCD_turnon();
//if (update_from_sd("boot", "boot.img"))
if (s5pc210_cpu_id == SMDK4212_AP10_ID) {
if (update_from_sd("bootloader", CONFIG_4212_AP10_BOOTLOADER))
printf("*****[bootloader] image updating failed...");
}
。。。
if (update_from_sd("kernel", "zImage"))
printf("*****[kernel] image updating failed...");
if (update_from_sd("ramdisk", "ramdisk-uboot.img"))
printf("*****[ramdisk] image updating failed...");
#ifdef CONFIG_RECOVERY
if (update_from_sd("Recovery", "ramdisk-recovery-uboot.img"))
printf("*****[Recovery] image updating failed...");
#endif
//在这里可以加入logo
//add by envi
#ifdef CONFIG_LOGO_DISPLAY
if(update_from_sd("logo", "logo.img"))
printf("*****[logo] image updating failed...");
#endif
// ++>>
if (update_from_sd("system", "system.img"))
printf("*****[system] image updating failed...");
if (update_from_sd("userdata", NULL))
goto err_sdfuse;
if (update_from_sd("cache", NULL))
goto err_sdfuse;
if (update_from_sd("fat", NULL))
goto err_sdfuse;
......
从代码可以看出,依次执行bootloader,kernel,ramdisk,recovery,logo,system的刷写。
update_from_sd函数是什么东东呢?
#define CFG_FASTBOOT_SDFUSE_DIR "/sdupdate/"
。。。
dev_desc = get_dev("mmc", CFG_UPDATE_FILE_SRC_DEV);
if (dev_desc == NULL) {
printf ("** Invalid boot device **\n");
return 1;
}
if (fat_register_device(dev_desc, CFG_FASTBOOT_SDFUSE_MMCPART) != 0) {
printf ("** Invalid partition **\n");
return 1;
}
sprintf(filename, "%s%s", CFG_FASTBOOT_SDFUSE_DIR, file);
offset = CFG_FASTBOOT_TRANSFER_BUFFER;
count = 0;
size = file_fat_read (filename, (unsigned char *) offset, count);
if (size == -1) {
printf("Failed to read %s\n", filename);
return 1;
}
download_size = 0; // should be 0
download_bytes = size;
。。。
if (download_bytes == 0)
sprintf(command, "%s:%s", "erase", part);
else
sprintf(command, "%s:%s", "flash", part);
ret = rx_handler(command, sizeof(command));
需要在SD卡建一个fat32分区,在里面建立一个sdupdate文件夹。放入uboot,kernel,ramdisk,system.logo等镜像文件。
rx_handler(){
....
else if (OmPin == BOOT_MMCSD) {
ret = write_to_ptn_sdmmc(ptn,
(unsigned int)interface.transfer_buffer + CFG_FASTBOOT_MKBOOTIMAGE_PAGE_SIZE,
fb_hdr->kernel_size);
} else if (OmPin == BOOT_EMMC441 || OmPin == BOOT_EMMC43) {
ret = write_to_ptn_sdmmc(ptn,
(unsigned int)interface.transfer_buffer + CFG_FASTBOOT_MKBOOTIMAGE_PAGE_SIZE,
fb_hdr->kernel_size);
}
......
}
在write_to_ptn_sdmmc函数调用movi命令去刷写
write_to_ptn_sdmmc(){
....
ret = do_movi(NULL, 0, argc, argv);
.....
}
第二步是需要向PC端通过串口传送烧录信息。我们做了简单的协议,你收到特定的字符串后,做相关的处理,显示烧录到那一块了,烧录的进度。同时我屏蔽了大量的原来烧录信息,否则会给那边的判断增加工作量。