|
@@ -22,14 +22,16 @@ int main()
|
|
|
{
|
|
|
int i;
|
|
|
uint8_t *buf;//[64*1024+1] = {0}; //4KB, one sector
|
|
|
- uint8_t *chkBuf;//[4*1024] = {0};
|
|
|
+// uint8_t *chkBuf;//[4*1024] = {0};
|
|
|
FILE *fp;
|
|
|
size_t len, totalSize = 1, writeSize = 0;
|
|
|
FILE *fprogress;
|
|
|
+ FILE *fpErase;
|
|
|
+ FILE *fpVerify;
|
|
|
uint8_t progressStr[10] = {0};
|
|
|
uint8_t rate = 0;
|
|
|
|
|
|
- buf = malloc(64*1024);
|
|
|
+ buf = malloc(32*1024 + 50);
|
|
|
// chkBuf = malloc(64*1024);
|
|
|
|
|
|
fp = fopen("/var/www/goahead/tmp/tmp.uImage", "rb");
|
|
@@ -46,25 +48,27 @@ int main()
|
|
|
printf("Image size: %d\n", totalSize);
|
|
|
|
|
|
//开始擦除
|
|
|
- fprogress = fopen("/var/www/goahead/tmp/Erase.log", "w");
|
|
|
- if(NULL == fprogress)
|
|
|
+ fpErase = fopen("/var/www/goahead/tmp/Erase.log", "w");
|
|
|
+ if(NULL == fpErase)
|
|
|
{
|
|
|
printf("Create Erase.log file fail!\n");
|
|
|
}
|
|
|
- fputs(progressStr, "Erasing");
|
|
|
- fclose(fprogress);
|
|
|
+ fputs("Erasing", fpErase);
|
|
|
+ fclose(fpErase);
|
|
|
|
|
|
printf("Chip erase ...\n");
|
|
|
sf_chip_erase(5);
|
|
|
printf("Chip erase finished!\n");
|
|
|
|
|
|
- fprogress = fopen("/var/www/goahead/tmp/Erase.log", "w");
|
|
|
- if(NULL == fprogress)
|
|
|
+ fpErase = fopen("/var/www/goahead/tmp/Erase.log", "w");
|
|
|
+ if(NULL == fpErase)
|
|
|
{
|
|
|
printf("Create Erase.log file fail!\n");
|
|
|
}
|
|
|
- fputs(progressStr, "Erase OK");
|
|
|
- fclose(fprogress);
|
|
|
+ fputs("Erase OK", fpErase);
|
|
|
+ fclose(fpErase);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//用来保存更新的进度
|
|
|
fprogress = fopen("/var/www/goahead/tmp/UpdateProgress.log", "w");
|
|
@@ -73,11 +77,11 @@ int main()
|
|
|
printf("Create UpdateProgress.log file fail!\n");
|
|
|
//return -1;
|
|
|
}
|
|
|
- fputs(progressStr, "0");
|
|
|
+ fputs("0", fprogress);
|
|
|
fclose(fprogress);
|
|
|
|
|
|
do{
|
|
|
- len = fread(buf, 1, 64*1024, fp);
|
|
|
+ len = fread(buf, 1, 32*1024, fp);
|
|
|
if(len <= 0)
|
|
|
{
|
|
|
close(fp);
|
|
@@ -119,13 +123,13 @@ int main()
|
|
|
//Verify
|
|
|
printf("Verigy successful.\n");
|
|
|
//用来保存校验结果
|
|
|
- fprogress = fopen("/var/www/goahead/tmp/Verify.log", "w");
|
|
|
- if(NULL == fprogress)
|
|
|
+ fpVerify = fopen("/var/www/goahead/tmp/Verify.log", "w");
|
|
|
+ if(NULL == fpVerify)
|
|
|
{
|
|
|
printf("Create UpdateProgress.log file fail!\n");
|
|
|
}
|
|
|
- fputs(progressStr, "Verify OK");
|
|
|
- fclose(fprogress);
|
|
|
+ fputs("Verify OK", fpVerify);
|
|
|
+ fclose(fpVerify);
|
|
|
|
|
|
fclose(fp);
|
|
|
|