MTD device read from kernel module
Elias
dilu666 at gmail.com
Mon Jul 7 05:45:51 EDT 2008
Hi!
I'm new to this list and a newbie in MTD manipulation from the kernel space.
I'm trying to implement a module for a 2.6.10 linux kernel on a mips
machine that will write and read data from a specific partition of a
Spansion NOR flash chip.
I've understood that the first step in order to read or write to the
flash from a module
is to lock the partition using the get_mtd_device(struct mtd_info
*mtd,int minorNum).
The partition I'm trying to handle is the /dev/mtd2, which has the
major number 90 and the minor number 4, and, thus, I execute right at
the beginning of the module a:
"struct mtd_info *debug=get_mtd_device(NULL,4);"
The get_mtd_device returns immediately with NULL after the insertion
of the module,
so, I figured (after going through the source code of the kernel
(mtdcore.c)) that the
reason probably is that the mtd_table does not contain an entry for
this device. After investigating the contents of the mtd_table, I
found out that only the first 4 positions have contents, so I replaced
the minor number (4) with 2. The get_mtd_device causes a segmentation
fault in that case.
The partition is not mounted during the test. Though, the device can
be mounted using the mtdblock2 (major 31, minor 2), and data can be
accessed using the /dev/mtd2; two facts that suggest that the mtd
partition is functioning properly and the minor number is valid.
What am I doing wrong?
Thanks a priori,
--
elias a.k.a. diluted
More information about the linux-mtd
mailing list