Trying to read the badblock list / Using MTD devices
Visti Andresen
talpa at galnet.dk
Sat Aug 4 23:52:44 CEST 2007
On Sat, 4 Aug 2007 13:45:52 +0200
Visti Andresen <talpa at galnet.dk> wrote:
> Hi I'm trying to create an application that reads Out Of Band information
> from the flash chip.
> The goal being to create an application that can display/backup the
> badblock information from the flash.
>
> I have had some problems reading correct CRC type values
> (getting illegal values like -1)
> Anso I didn't find any badblocks at all.
>
> I then discovered that my problems ran deeper that fist expected.
> If I open /dev/mtd0 and close it again the entire flash filesystem returns
> "Input/output error"
> Took some time to discover this as I was scp'ing to /tmp and things inside the
> disk cache can still be read/executed.
>
> Below is a small test program that can cause the crash, I compile it using:
> ./build/tmp/cross/arm-linux/bin/gcc -Wall -o mtd_test mtd_test.c
>
> Any one know why I get the "Input/output error" after I have executed the
> program on the Neo?
>
> Btw. the O_NONBLOCK option was something I picked up a some web page
> claiming that otherwise the result would not be as expected.
> Removing it gives the same behaviour.
>
> The output of the program is:
> root at fic-gta01:~$ ./mtd_test
> Opened MTD device /dev/mtd0 OK
> Closed MTD device /dev/mtd0 OK
>
>
> =====
>
> #include <stdio.h>
> #include <fcntl.h>
> #include <errno.h>
> #include <stdlib.h>
> #include <string.h>
> #include <unistd.h>
>
> char verbose_ = 1;
>
> void test(char *mtdDevice);
>
>
> int main()
> {
> test("/dev/mtd0");
> return 0;
> }
>
> void test(char *mtdDevice)
> {
> int device;
>
> device = open(mtdDevice, O_RDONLY|O_NONBLOCK);
> if (device < 0) {
> fprintf(stderr, "Unable to open MTD device %s: %s\n", mtdDevice, strerror(errno));
> return;
> }
> else {
> printf("Opened MTD device %s OK\n", mtdDevice);
> }
>
>
> if (0!=close(device)){
> printf("Failed to close MTD device %s: %s\n", mtdDevice, strerror(errno));
> }
> else {
> printf("Closed MTD device %s OK\n", mtdDevice);
> }
> }
>
An odd detail if I do a "dd if=/dev/mtd0 of=test.bin bs=512 count=32"
on my Nokia 770 the file system remains operational.
On the Neo1973 this results in a "crashed" file system that returns
"Input/output error"
A BUG in the MTD system?
More information about the openmoko-devel
mailing list