資源簡介
強大的工具 -- Flashimg
flashimg是一個由網(wǎng)友 Fabrice Jouhaud 開發(fā)的軟件,可以很快捷地生成NAND或NOR鏡像文

代碼片段和文件信息
/*
?*?flashimg
?*?Copyright?(C)?2011-2012??Yargil?
?*
?*?This?program?is?free?software;?you?can?redistribute?it?and/or?modify
?*?it?under?the?terms?of?the?GNU?General?Public?License?as?published?by
?*?the?Free?Software?Foundation;?either?version?2?of?the?License?or
?*?(at?your?option)?any?later?version.
?*
?*?This?program?is?distributed?in?the?hope?that?it?will?be?useful
?*?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
?*?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
?*?GNU?General?Public?License?for?more?details.
?*
?*?You?should?have?received?a?copy?of?the?GNU?General?Public?License
?*?along?with?this?program;?if?not?write?to?the?Free?Software
?*?Foundation?Inc.?59?Temple?Place?Suite?330?Boston?MA??02111-1307??USA
?*/
#include?
#include?
#include?
#include?
#include?
#include?
#include?
#include?“config.h“
#define?FLASH_TYPE_NAND 0
#define?FLASH_TYPE_NOR 1
struct?image?{
char?*mem;
size_t?size;
};
struct?action?{
char?*part;
char?*file;
char?action;
};
struct?ecc_info?{
int?page_size;
int?oob_size;
int?ecc_nb;
int?ecc_pos[24];
};
struct?ecc_info?const?ecc_tab[]?=?{
{
.page_size?=?256
.oob_size?=?8
.ecc_nb?=?3
.ecc_pos?=?{?0?1?2?}
}
{
.page_size?=?512
.oob_size?=?16
.ecc_nb?=?6
.ecc_pos?=?{?0?1?2?3?6?7?}
}
{
.page_size?=?2048
.oob_size?=?64
.ecc_nb?=?24
.ecc_pos?=?{
40?41?42?43?44?45?46?47
48?49?50?51?52?53?54?55
56?57?58?59?60?61?62?63?}
}
};
struct?partition?{
char?*name;
long?off;
long?len;
};
static?struct?ecc_info?const?*ecc?=?NULL;
static?int?page_size;
static?struct?partition?part_tab[32];
static?int?nb_part;
static?int?flash_type;
void?__nand_calculate_ecc(const?unsigned?char?*buf?unsigned?int?eccsize
???????unsigned?char?*code);
static?void?oob(const?unsigned?char?*buf?size_t?len?unsigned?char?*check)
{
int?i;
unsigned?char?code[32]?*_code;
memset(check?0xff?16);
_code?=?code;
for?(i=0;i __nand_calculate_ecc(buf+i*256?256?_code);
check[0]?=?_code[0];
check[1]?=?_code[1];
check[2]?=?_code[2];
_code?+=?3;
}
for?(i=0;iecc_nb;i++)
check[ecc->ecc_pos[i]]?=?code[i];
}
/*
?*?Parse?the?partition?file
?*/
static?int?partition_file(const?char?*filename)
{
int?idx?=?0;
char?name[64];
long?off?len;
FILE?*fp;
int?retval?=?0;
/*?
?*?File?format:
?*???
?*/
printf(“Partition?list:\n“);
fp?=?fopen(filename?“r“);
if?(fp?==?NULL)?{
fprintf(stderr?“Can‘t?open?partition?file?%s\n“?filename);
return?-1;
}
printf(“name\toffset\t\tsize\n“);
do?{
int?ret?=?fscanf(fp?“%s?%li?%li“?name?&len?&off);
if?(ret?==?-1)?break;
if?(ret?!=?3)?{
retval?=?-1;
fprintf(stderr?“Error?in?partition?file\n“);
break;
}
part_tab[idx].name?=?strdup(name);
part_tab[idx].off?=?off;
part_tab[idx].len?=?len;
printf(“%s\t0x%08l
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-11-25?02:42??flashimg-master\
?????文件?????????166??2013-11-25?02:42??flashimg-master\.gitignore
?????文件??????????16??2013-11-25?02:42??flashimg-master\AUTHORS
?????文件???????18011??2013-11-25?02:42??flashimg-master\COPYING
?????文件???????????0??2013-11-25?02:42??flashimg-master\ChangeLog
?????文件???????18045??2013-11-25?02:42??flashimg-master\LICENSE
?????文件?????????306??2013-11-25?02:42??flashimg-master\Makefile.am
?????文件???????????0??2013-11-25?02:42??flashimg-master\NEWS
?????文件????????1650??2013-11-25?02:42??flashimg-master\README
?????文件?????????188??2013-11-25?02:42??flashimg-master\README.md
?????文件?????????307??2013-11-25?02:42??flashimg-master\autocp.sh
?????文件?????????153??2013-11-25?02:42??flashimg-master\autogen.sh
?????文件?????????641??2013-11-25?02:42??flashimg-master\configure.ac
?????文件????????9874??2013-11-25?02:42??flashimg-master\main.c
?????文件???????12378??2013-11-25?02:42??flashimg-master\nand_ecc.c
?????文件?????????109??2013-11-25?02:42??flashimg-master\uboot.part
- 上一篇:微信小程序 記事本
- 下一篇:軟件工程課程設(shè)計-物流平臺的信息發(fā)布
評論
共有 條評論