1
0
mirror of git://projects.qi-hardware.com/xburst-tools.git synced 2024-11-23 04:42:27 +02:00

Implemented padding of NAND images

This commit is contained in:
Sergey Gridassov 2010-12-10 16:54:35 +03:00
parent 9773d34f38
commit 36cd4414a1

View File

@ -628,6 +628,14 @@ int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *fi
int file_size = ftell(in); int file_size = ftell(in);
fseek(in, 0, SEEK_SET); fseek(in, 0, SEEK_SET);
int tail = file_size % page_size;
if(tail) {
tail = page_size - tail;
file_size += page_size - tail;
}
int pages = file_size / page_size; int pages = file_size / page_size;
int ret = 0; int ret = 0;
@ -643,10 +651,14 @@ int ingenic_program_nand(void *hndl, int cs, int start, int type, const char *fi
int chunk = pages < chunk_pages ? pages : chunk_pages; int chunk = pages < chunk_pages ? pages : chunk_pages;
int bytes = chunk * page_size; int bytes = chunk * page_size;
debug(LEVEL_DEBUG, "Writing %d pages from %d\n", chunk, start);
ret = fread(iobuf, 1, bytes, in); ret = fread(iobuf, 1, bytes, in);
if(pages < chunk_pages && tail) {
memset(iobuf + ret, 0xFF, tail);
ret += tail;
}
if(ret != bytes) { if(ret != bytes) {
debug(LEVEL_ERROR, "fread: %d\n", ret); debug(LEVEL_ERROR, "fread: %d\n", ret);