From 72212c137c574b564723327af751c4054c7cfca6 Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Tue, 11 Apr 2006 19:09:16 -0400 Subject: Initial commit --- flash_info.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 flash_info.c (limited to 'flash_info.c') diff --git a/flash_info.c b/flash_info.c new file mode 100644 index 0000000..7157b9e --- /dev/null +++ b/flash_info.c @@ -0,0 +1,55 @@ +/* + * flash_info.c -- print info about a MTD device +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include + +int main(int argc,char *argv[]) +{ + int regcount; + int Fd; + + if (1 >= argc) + { + fprintf(stderr,"Usage: flash_info device\n"); + return 16; + } + + // Open and size the device + if ((Fd = open(argv[1],O_RDONLY)) < 0) + { + fprintf(stderr,"File open error\n"); + return 8; + } + + if (ioctl(Fd,MEMGETREGIONCOUNT,®count) == 0) + { + int i; + region_info_t reginfo; + printf("Device %s has %d erase regions\n", argv[1], regcount); + for (i = 0; i < regcount; i++) + { + reginfo.regionindex = i; + if(ioctl(Fd, MEMGETREGIONINFO, ®info) == 0) + { + printf("Region %d is at 0x%x with size 0x%x and " + "has 0x%x blocks\n", i, reginfo.offset, + reginfo.erasesize, reginfo.numblocks); + } + else + { + printf("Strange can not read region %d from a %d region device\n", + i, regcount); + } + } + } + return 0; +} -- cgit v1.2.3