資源簡介
Tiny6410 mlc2 支持K9GAG08U0E nand flash啟動,沒有實現ECC校驗,有待繼續完善
代碼片段和文件信息
#include?
#include?
#include?
int?main?(int?argc?char?*argv[])
{
FILE *fp;????/*?定義一個文件指針?*/
unsigned?char *Buf?*a;
int BufLen;
int nbytes?fileLen?curPosition;
unsigned?int checksum?count;
int i;
if?(argc?!=?3)?/*?如果參數個數錯誤,打印幫助信息?*/
{
/*?應用工具時格式必須是?./mlc_boot_tool.exe?old.bin?new.bin?*/
printf(“Usage:?mkbl1??\n“);
return?-1;
}
fp?=?fopen(argv[1]?“rb“);?/*?以讀二進制的方式打開沒有頭部信號的old.bin文件?*/
if(?fp?==?NULL)
{
printf(“source?file?open?error\n“);
return?-1;
}
fseek(fp?0L?SEEK_END);?/*?讓文件位置指針指向文件末尾,便于下行的統計大小的操作?*/
fileLen?=?ftell(fp);?/*?用于得到文件位置指針當前位置相對于文件首的偏移字節數即文件大小*/
BufLen?=?16*1024;
Buf?=?(char?*)malloc(BufLen);?/*?動態分配一段24k的內存空間?*/
if?(!Buf)?/*?分配失敗,將返回0?*/
{
printf(“Alloc?buffer?failed!\n“);
return?-1;
}
memset(Buf?0x00?BufLen);?/*?將上面分配的空間清零?*/
if(fileLen?2048)
{
printf(“source?file?too?small?!!?do?not?need?the?tool?!!\n“);
free(Buf);?/*?釋放內存?*/
return?-1;
}
fseek(fp?0L?SEEK_SET);?/*?讓文件位置指針指向文件開始?*/
nbytes?=?fread(Buf?1?2048?fp);?/*?將編譯生成的old.bin文件拷貝前2K數據到到buf中?*/
if?(?nbytes?!=?2048?)?/*?返回值等于拷貝的元素的個數?*/
{
printf(“0?page.?source?file?read?error\n“);?/*?如果個數和實際的不想等,則失敗?*/
free(Buf);?/*?釋放內存?*/
fclose(fp);?/*?關閉文件?*/
return?-1;
}
curPosition?=?ftell(fp);??/*?獲得當前文件指針的位置?*/
nbytes?=?fread(Buf?+?8192?1?2048?fp);
if?(?nbytes?!=?2048?)?/*?返回值等于拷貝的元素的個數?*/
{
printf(“1?page.?source?file?read?error\n“);?/*?如果個數和實際的不想等,則失敗?*/
free(Buf);?/*?釋放內存?*/
fclose(fp);?/*?關閉文件?*/
return?-1;
}
fclose(fp);?/*?關閉文件?*/
/*?到這里為止,把新的bin的數據已經構造完成,現在要把這些數據寫入到新的bin文件中?*/
fp?=?fopen(argv[2]?“wb“);?/*?以二進制寫的方式創建一個新的二進制文件?*/
if?(fp?==?NULL)
{
printf(“destination?file?open?error\n“);
free(Buf);?/*?釋放內存?*/
return?-1;
}
a?=?Buf;?/*?指向內存的首地址?*/
nbytes?=?fwrite(?a?1?BufLen?fp);?/*?把buf中的數據寫入新創建的bin文件?*/
if?(?nbytes?!=?BufLen?)?/*?返回值等于寫入的元素的個數?*/
{
printf(“destination?file?write?error\n“);
free(Buf);?/*?釋放內存?*/
fclose(fp);/*?關閉文件?*/
return?-1;
}
free(Buf);?/*?釋放內存?*/
fclose(fp);/*?關閉文件?*/
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????823818??2013-04-16?09:11??u-boot-2010.09-tiny6410\u-boot
?????文件????????615??2013-04-15?13:48??u-boot-2010.09-tiny6410\u-boot.lds
?????文件?????682342??2013-04-16?09:11??u-boot-2010.09-tiny6410\u-boot.srec
?????文件????????732??2010-09-28?21:20??u-boot-2010.09-tiny6410\.gitignore
?????文件?????227432??2013-04-16?09:11??u-boot-2010.09-tiny6410\u-boot.bin
?????文件??????22744??2013-04-16?06:14??u-boot-2010.09-tiny6410\bl1.dis
?????文件????1781499??2013-04-16?06:48??u-boot-2010.09-tiny6410\bl2.dis
?????文件??????15951??2010-09-28?21:20??u-boot-2010.09-tiny6410\COPYING
?????文件??????12701??2010-09-28?21:20??u-boot-2010.09-tiny6410\CREDITS
?????文件??????19807??2010-09-28?21:20??u-boot-2010.09-tiny6410\MAINTAINERS
?????文件??????17659??2013-03-23?05:41??u-boot-2010.09-tiny6410\MAKEALL
?????文件??????88616??2013-03-23?11:12??u-boot-2010.09-tiny6410\Makefile
?????文件?????149798??2010-09-28?21:20??u-boot-2010.09-tiny6410\README
?????文件??????12442??2010-09-28?21:20??u-boot-2010.09-tiny6410\boards.cfg
?????文件???????8012??2010-09-28?21:20??u-boot-2010.09-tiny6410\config.mk
?????文件???????2919??2010-09-28?21:20??u-boot-2010.09-tiny6410\mkconfig
?????文件???????1631??2010-09-28?21:20??u-boot-2010.09-tiny6410\rules.mk
?????文件?????????74??2010-09-28?21:20??u-boot-2010.09-tiny6410\snapshot.commit
?????文件?????198118??2013-04-16?09:11??u-boot-2010.09-tiny6410\u-boot.map
?????文件??????29443??2013-04-16?09:11??u-boot-2010.09-tiny6410\System.map
?????文件?????231528??2013-04-16?09:11??u-boot-2010.09-tiny6410\u-boot-nand.bin
?????文件??????16384??2013-04-16?06:35??u-boot-2010.09-tiny6410\16k.bin
?????文件???????1632??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\Makefile
?????文件???????8014??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\atum8548.c
?????文件????????945??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\config.mk
?????文件???????1766??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\ddr.c
?????文件???????2317??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\law.c
?????文件???????3147??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\atum8548\tlb.c
?????文件???????1445??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\espt\Makefile
?????文件????????168??2010-09-28?21:20??u-boot-2010.09-tiny6410\board\espt\config.mk
............此處省略7621個文件信息
- 上一篇:指針儀表角度檢測
- 下一篇:STDP8028源代碼
評論
共有 條評論