aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanley.Miao <stanley.miao@windriver.com>2010-05-18 20:23:10 +0800
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-05-22 08:37:55 +0300
commita8214921bdc7d78b75d133a37ff9f8d4ec919650 (patch)
tree35ac6dd837cc2e520a94a0d65aec68851012cde3
parentf0d12d2079b8b2ea667073a6bcd603765466dc58 (diff)
nandwrite: check if the start address is page-aligned
Only page-aligned address is permitted in NAND subsystem. Signed-off-by: Stanley.Miao <stanley.miao@windriver.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--nandwrite.c8
1 files changed, 8 insertions, 0 deletions
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) {