mtd_debug usage

Ricard Wanderlof ricard.wanderlof at axis.com
Wed Nov 22 02:42:18 EST 2006


On Tue, 21 Nov 2006, Duke wrote:

>> I've seen usage where /dev/mtd2 is used instead of /dev/mtdblock2,
>> what is the difference here? which should it be. It seems to me that
>> /dev/mtd2 simply gives the node info (mtd_debug info )and
>> /dev/mtdblock2 is really what you want to used. Do I have this
>> correct?

mtdblock devices are normally only used with the mount/umount commands. 
For erase /dev/mtdX is required - the mtdblock devices don't support the 
required ioctls. Actually, since a while back, it's not necessary to use 
/dev/mtdblockX devices for mount/umount either since they understand 
'mtdX' directly as in  mount -t cramfs mtd1 /mnt/mountpoint .

mtdblock devices do support an automatic erase-before-write functionality 
when writing. This used to be buggy, don't know the status of this. As far 
as I'm concerned, it's of little use anyway, because if the image you are 
writing is smaller than the partition, using this feature will leave the 
end of the partition unerased which is probably not what you want. Doing 
separate erase and write operations is thus preferable IMHO.

> Creating 3 MTD partitions on "physmap-flash.0":
> 0x00000000-0x00040000 : "boot"
> 0x00040000-0x00200000 : "kernel"
> 0x00200000-0x00800000 : "cramfs"
>
> When I ran mtd_debug I get the following from the above mapping:
>
> # mtd_debug info /dev/mtd2
> mtd.size = 1835008 (1M)
>
> # mtd_debug info /dev/mtd1
> mtd.size = 262144 (256K)
>
> # mtd_debug info /dev/mtd0
> mtd.size = 262144 (256K)
>
> # mtd_debug info /dev/mtd3
> mtd.size = 1835008 (1M)

Looks like your minor numbers are screwed up for the /dev/mtd devices. 0 
and 1 seem to have the same size, as to 2 and 3. Normally mtd0 is the 
whole flash, with the first partition being in mtd1 (someone please 
correct me if I'm wrong here). mtd0/1 seems to refer to the first 256k 
boot partition, with mtd2/3 referring to the kernel partition with the 
size of 0x1c0000 = 1835008.

What does  ls -l /dev/mtd*  (and ls -l /dev/mtdblock*) say?

> # mtd_debug erase /dev/mtdblock2 0 0x600000
> MEMERASE: Inappropriate ioctl for device

You must use /dev/mtd2 for erasure.

> Clearly I'm missing something here. Could someone help me understand this?

The problem seems to have something to do with the device mapping, your 
commands look ok at least to start with.

/Ricard
--
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30




More information about the linux-mtd mailing list