[U-Boot] Obtaining start/end address of an MTD partition

Matthew Lear matt at bubblegen.co.uk
Tue May 4 18:31:18 CEST 2010


Hello all,

I've posted this to the MTD mailing list to no avail :-( I'm hoping that
somebody can help me here...

Is it possible to obtain an MTD partition's start address (either through
usage of the MTD ioctls or some other means)? I've had a very quick look
and from what I can tell, this doesn't appear to be possible.

To be clear, I'd like to obtain the address below (displayed by Linux
when it detects the MTD partitions on boot) on the left hand side (ie the
start address / offset into the flash device itself).

Creating 6 MTD partitions on "physmap-flash.0":
0x00000000-0x00120000 : "RedBoot"
0x00120000-0x01000000 : "foo"
0x01000000-0x01400000 : "bar"

I can obviously use the MEMGETINFO ioctl on a particular MTD device to
return info in struct mtd_info_user, but this doesn't give me all the
information I need for that particular partition (specifically, the start
offset of the partition on the device).

Basically, I'm trying to cater for using another flash driver instead of
the MTD sub-system on some custom hw in order to access the flash device.
I'd like to be able to get the MTD partition start addresses so I
know where to operate on this other device. A bit clunky, I know (if it
were my decision MTD would be used).

RedBoot creates the FIS entries above and Linux parses this just fine at
boot thus creating the MTD partition listing. If I were using MTD to
access the flash device I could open /dev/mtd<x> or /dev/mtdblock<x>
accordingly. However, there is a requirement to access the flash through
another device (/dev/flash). For example, if I wanted to write to the area
covered by /dev/mtd1, I need to be able to:

i)  get the start address of /dev/mtd1
ii) open /dev/flash and seek to the offset provided by (i) above.
iii) perform the operation(s).

...so I need the partition start addresses.

I could obtain the start address of a particular partition using /proc/mtd
and by keep an incrementing count of the sizes of each previous MTD
partition. However, this method comes unstuck if there is unpartitioned
space that preceeds an MTD partition...

Can anybody offer any advice / thoughts?

Many thanks,
--  Matt




More information about the U-Boot mailing list