先把薄码开关拨到MMC2启动,即OM[5:1] 为b'00010,把启动TF卡插入MMC2,上电启动,进入uboot命令行模式后执行命令:
mmc erase boot 0 0 10240
即可擦除uboot分区最前面的引导部分。注意,不要此时烧写uboot,此时烧写会把uboot烧写到TF卡上而不是INAND上。接着断电,薄码开关调回INAND启动,即OM[5:1] B'10100,上电就会检查iNand,但是iNand 没有uboot启动代码,所以就会自动切换到TF卡启动,这时就可以烧写uboot到inand上了
——这个里面有笔误,上面应该改成如下就可以了。
先把薄码开关拨到MMC2启动,即OM[5:1] 为b'00010,把启动TF卡插入MMC2,上电启动,进入uboot命令行模式后执行命令:
mmc erase boot 1 0 1024 (当从mmc2 TF卡启动时i,TF卡设备索引号是0,而nand 设备索引号应该是1)
即可擦除iNand uboot分区最前面的引导部分。注意,不要此时烧写uboot,此时烧写会把uboot烧写到TF卡上而不是INAND上。接着断电,薄码开关调回INAND启动,即OM[5:1] B'10100,上电就会检查iNand,但是iNand 没有uboot启动代码,所以就会自动切换到TF卡启动,但是此时的OM值是iNand 模式的,所以iNand 设备索引值是0,而mmc2 TF卡是1,所以能够正常用fdisk -c 0 ,ext3format mmc 0:1 等分区命令进行烧写。这时就可以烧写uboot到inand上了。整个过程终于明白了,今天主要看了Sate4412 的uboot代码,并且举一反三,终于明白4412 烧写是怎么回事。终于清静了......
intdo_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { int rc = 0; int part = 0;
switch (argc) { case 3: if (strcmp(argv[1],"rescan") == 0) { int dev =simple_strtoul(argv[2], NULL, 10); struct mmc *mmc =find_mmc_device(dev);
if (!mmc) return 1;
mmc_init(mmc);
return 0; }
case 0: case 1: case 4: printf("Usage:\n%s\n",cmdtp->usage); return 1;
case 2: if (!strcmp(argv[1],"list")) { print_mmc_devices('\n'); return 0; } return 1; case 6: if (strcmp(argv[1],"erase") == 0) { /* Read inputvariable */ int dev =simple_strtoul(argv[3], NULL, 10); u32 start =simple_strtoul(argv[4], NULL, 10); u32 block =simple_strtoul(argv[5], NULL, 10);
struct mmc *mmc =find_mmc_device(dev);
if (!mmc) return 1;
u32 count = 0;
/* Select erasepartition */ if (strcmp(argv[2],"boot") == 0) { part = 0; /* ReadBoot partition size. */ count =((mmc->ext_csd.boot_size_multi)*256); } else if(strcmp(argv[2], "user") == 0) { part = 1; /* ReadUser partition size. */ count =mmc->capacity; } else { part = 1; count =mmc->capacity; printf("Defaulterase user partition\n"); }
/* If input counteris larger than max counter */ if ((start + block)> count) { block =(count - start) - 1; printf("Blockcount is Too BIG!!\n"); }
/* If input counteris 0 */ if (!block ) { block =(count - start) - 1; printf("Eraseall from %d block\n", start); }
rc = mmc_erase(mmc,part, start, block);
if (rc == 0) { printf("MMCerase Success.!!\n"); } else { printf("MMCerase Failed.!!\n"); return -1; } return 0; } else if (strcmp(argv[1],"read") == 0) { int dev =simple_strtoul(argv[2], NULL, 10); void *addr = (void*)simple_strtoul(argv[3], NULL, 16); u32 cnt =simple_strtoul(argv[5], NULL, 10); u32 n; u32 blk =simple_strtoul(argv[4], NULL, 10); u32 read_cnt; u32 cnt_to_read; void *addr_to_read =addr; struct mmc *mmc =find_mmc_device(dev);
if (!mmc) return 1;
printf("\nMMCread: dev # %d, block # %d, count %d ... ", dev, blk,cnt);
n = 0; addr_to_read = addr; do { if (cnt - n> MAXIMUM_BLOCK_COUNT) cnt_to_read= MAXIMUM_BLOCK_COUNT; else cnt_to_read= cnt - n;
read_cnt =mmc->block_dev.block_read(dev, blk, cnt_to_read, addr_to_read); n +=read_cnt; blk +=read_cnt; addr_to_read+= read_cnt * 512; if(cnt_to_read!= read_cnt) { printf("%dblocks read: %s\n", n,"ERROR"); return-1; } } while(cnt > n);
/* flush cache afterread */ flush_cache((ulong)addr,cnt * 512); /* FIXME */
printf("%dblocks read: %s\n", n, (n==cnt)? "OK" : "ERROR"); return (n == cnt) ?0 : 1; } else if (strcmp(argv[1],"write") == 0) { int dev =simple_strtoul(argv[2], NULL, 10); void *addr = (void*)simple_strtoul(argv[3], NULL, 16); u32 cnt =simple_strtoul(argv[5], NULL, 10); int blk =simple_strtoul(argv[4], NULL, 10); u32 n; u32 written_cnt; u32 cnt_to_write; void *addr_to_write= addr; struct mmc *mmc =find_mmc_device(dev);
if (!mmc) return 1;
printf("\nMMCwrite: dev # %d, block # %d, count %d ... ", dev, blk,cnt);
n = 0; addr_to_write =addr; do { if (cnt - n> MAXIMUM_BLOCK_COUNT) cnt_to_write= MAXIMUM_BLOCK_COUNT; else cnt_to_write= cnt - n;
written_cnt= mmc->block_dev.block_write(dev, blk, cnt_to_write, addr_to_write); n +=written_cnt; blk +=written_cnt; addr_to_write+= written_cnt * 512; if(cnt_to_write!= written_cnt) { printf("%dblocks written: %s\n", n,"ERROR"); return-1; } } while(cnt > n);
printf("%dblocks written: %s\n", n, (n ==cnt) ? "OK" : "ERROR"); return (n == cnt) ?0 : 1; } else { printf("Usage:\n%s\n",cmdtp->usage); rc = 1; }
return rc; default: /* at least 5 args */ printf("Usage:\n%s\n",cmdtp->usage); return 1; } }
[ 本帖最后由 gooogleman 于 2013-11-27 23:22 编辑 ] |