From a8214921bdc7d78b75d133a37ff9f8d4ec919650 Mon Sep 17 00:00:00 2001 From: "Stanley.Miao" Date: Tue, 18 May 2010 20:23:10 +0800 Subject: nandwrite: check if the start address is page-aligned Only page-aligned address is permitted in NAND subsystem. Signed-off-by: Stanley.Miao Signed-off-by: Artem Bityutskiy --- nandwrite.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'nandwrite.c') diff --git a/nandwrite.c b/nandwrite.c index 1e30ad1..e691ebd 100644 --- a/nandwrite.c +++ b/nandwrite.c @@ -307,6 +307,14 @@ int main(int argc, char * const argv[]) exit (EXIT_FAILURE); } + if (mtdoffset & (meminfo.writesize - 1)) { + fprintf(stderr, "The start address is not page-aligned !\n" + "The pagesize of this NAND Flash is 0x%x.\n", + meminfo.writesize); + close(fd); + exit(EXIT_FAILURE); + } + if (autoplace) { /* Read the current oob info */ if (ioctl (fd, MEMGETOOBSEL, &old_oobinfo) != 0) { -- cgit v1.2.3