mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-22 23:21:53 +02:00
Implemented padding of NAND images
This commit is contained in:
parent
9773d34f38
commit
36cd4414a1
16
ingenic.c
16
ingenic.c
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user