Skip to contentSkip to conversation

Access entire device with mtdblock0

DISCUSSION Adam Yergovich 7 participants 13 messages Jan 10, 2009 – Feb 9, 2009 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hello MTD,

There was a grand feature in the 2.4 flavor of MTD that i used wherein mtdblock0 was assigned the entirety of the device. This made updating the flash image very easy.

I've since started messing around with 2.6 flavors, and while i have a working map that gives the partitions i can no longer access the entire device. I've tried a few things without success to get it to work.

Any recommendations on a simple way to create a partition using the entirety of flash?

-Adam

#1 lore raw
Quoted 10 lines · Adam Yergovich

There was a grand feature in the 2.4 flavor of MTD that i used wherein mtdblock0 was assigned the entirety of the device. This made updating the flash image very easy.

I've since started messing around with 2.6 flavors, and while i have a working map that gives the partitions i can no longer access the entire device. I've tried a few things without success to get it to work.

Any recommendations on a simple way to create a partition using the entirety of flash?

Hey, I use that feature with 2.4 too, and I'm looking at porting a device to 2.6. I'll be interested in the answer.

-- Jamie

#2 lore raw
In reply to Adam Yergovich
Quoted 10 lines · Adam Yergovich

There was a grand feature in the 2.4 flavor of MTD that i used wherein mtdblock0 was assigned the entirety of the device. This made updating the flash image very easy.

I've since started messing around with 2.6 flavors, and while i have a working map that gives the partitions i can no longer access the entire device. I've tried a few things without success to get it to work.

Any recommendations on a simple way to create a partition using the entirety of flash?

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions(). -mike

#3 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

Mike> looks like no one responded. i'm pretty sure the answer is to use Mike> add_mtd_device() even in face of add_mtd_partitions().

Why not just add a partition spanning the entire device in addition to the other partitions?

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw
Quoted 9 lines · Peter Korsgaard
Quoted 5 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions().

Why not just add a partition spanning the entire device in addition to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ... -mike

#5 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Why not just add a partition spanning the entire device in addition to the other partitions?

Mike> i was not aware partition tables allowed for overlaps. if Mike> that's true, then the answer is obvious and easy to implement Mike> in boards ...

I'm pretty sure it does, and I don't see any checks for it in mtdpart.c:add_one_partition()

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw
In reply to Mike Frysinger
Quoted 10 lines · Mike Frysinger
Quoted 6 lines · Peter Korsgaard
Quoted 3 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

Why not just add a partition spanning the entire device in addition to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ...

Sure does. We've used it for quite a while, using /dev/mtd0 to refer to the whole flash, with /dev/mtd1,2,3... referring to the individual partitions.

/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

#7 lore raw
In reply to Mike Frysinger
Quoted 5 lines · Mike Frysinger
Quoted 4 lines · Peter Korsgaard
Quoted 3 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions().

Why not just add a partition spanning the entire device in addition to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ...

They are allowed, but I have not been able yet to do a correct query for erase_size in case of a partition covering a whole device having multiple different-sized erase regions.

Regards,
Wolfgang

#8 lore raw
Quoted 7 lines · Wolfgang Wegner
Quoted 6 lines · Mike Frysinger
Quoted 5 lines · Peter Korsgaard
Quoted 4 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions().

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Why not just add a partition spanning the entire device in addition to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ...

They are allowed, but I have not been able yet to do a correct query for erase_size in case of a partition covering a whole device having multiple different-sized erase regions.

Thanks for the advice all. I will give these a go in the next day or two.

-Adam

#9 lore raw
In reply to Wolfgang Wegner
Quoted 12 lines · Wolfgang Wegner
Quoted 10 lines · Mike Frysinger
Quoted 7 lines · Peter Korsgaard
Quoted 4 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions().

Why not just add a partition spanning the entire device in addition to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ...

Quoted 6 lines

They are allowed, but I have not been able yet to do a correct query for erase_size in case of a partition covering a whole device having multiple different-sized erase regions.

Regards,
Wolfgang

Hello All,

Sorry for the delay in trying this out, I have been exceptionally busy.

The short story is: i got it all to work.

The long story is:

In reviewing the code i found that add_mtd_device was already being called after the partitioning. As it wasn't giving mtdblock0 as the entire region it didn't seem to be the solution.

I played around some more, and found disabling the mtd partitioning would give me one partition including all of flash. If you'll note in the code (which has been present in physmap.c for some time i believe) it was getting to the add_mtd_device and adding it if and only if the redboot section was not called.

I moved the add_mtd_device() call to before the redboot partitioning and it all worked brilliantly.

I would like to suggest that this is perhaps a better construct overall as it adds a nice feature.

Hopefully this is at very least useful to someone who looks at this in the future. I thank you all for your help in this.

-Adam

#10 lore raw
Quoted 18 lines · Adam Yergovich
Quoted 17 lines · Wolfgang Wegner
Quoted 11 lines · Mike Frysinger
Quoted 8 lines · Peter Korsgaard
Quoted 4 lines · "Mike" == Mike Frysinger <writes:
Quoted 2 lines

Any recommendations on a simple way to create a partition using the entirety of flash?

looks like no one responded. i'm pretty sure the answer is to use add_mtd_device() even in face of add_mtd_partitions().

Why not just add a partition spanning the entire device in addition

to the other partitions?

i was not aware partition tables allowed for overlaps. if that's true, then the answer is obvious and easy to implement in boards ...

They are allowed, but I have not been able yet to do a correct query for erase_size in case of a partition covering a whole device having multiple different-sized erase regions.

Quoted 6 lines
Quoted 2 lines

Regards,
Wolfgang

Hello All,

Sorry for the delay in trying this out, I have been exceptionally

busy.

Quoted 15 lines

The short story is: i got it all to work.

The long story is:

In reviewing the code i found that add_mtd_device was already being called after the partitioning. As it wasn't giving mtdblock0 as the entire region it didn't seem to be the solution.

I played around some more, and found disabling the mtd partitioning would give me one partition including all of flash. If you'll note in the code (which has been present in physmap.c for some time I believe) it was getting to the add_mtd_device and adding it if and only if the redboot section was not called.

Quoted 8 lines

I moved the add_mtd_device() call to before the redboot partitioning and it all worked brilliantly.

I would like to suggest that this is perhaps a better construct overall as it adds a nice feature.

Hopefully this is at very least useful to someone who looks at this in the future. I thank you all for your help in this.

It appears this was originally thought about for mtd partitions.

In mdtpart.c, add_mtd_partitions() has a comment above it:

/*
* This function, given a master MTD object and a partition table,
creates
* and registers slave MTD objects which are bound to the master
according to
* the partition definitions.
* (Q: should we register the master MTD object as well?) */

Maybe it was just never revisited?

Hartley

#11 lore raw
Quoted 13 lines · hartleys

It appears this was originally thought about for mtd partitions.

In mdtpart.c, add_mtd_partitions() has a comment above it:

/*
* This function, given a master MTD object and a partition table,
creates
* and registers slave MTD objects which are bound to the master
according to
* the partition definitions.
* (Q: should we register the master MTD object as well?) */

Quoted 2 lines

Maybe it was just never revisited?

Could well be, some great sleuthing there. I think the bigger question is "Does calling add_mtd_device() after the partitioning has been done work?"

I believe the answer to this is no, though some confirmation would be a good idea.

If that assumption is correct, I think it should be changed to either:

1) Call it before partitioning so it does add the device.

-or-

2) Change the function such that it works any time and thus the physmap call should work as originally written.

I'm not familiar enough with the intended function to know though. The best i can say is that it seems to behave in this way, and it appears to me to have been intended to behave differently.

-Adam

#12 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Adam" == Adam Yergovich <[email protected]> writes:

Hi,

Adam> If that assumption is correct, I think it should be changed to either:

Adam> 1) Call it before partitioning so it does add the device.

Adam> -or-

Adam> 2) Change the function such that it works any time and thus the physmap Adam> call should work as originally written.

It would be bad to change this now to do it automatically as it would screw up the mtd numbering.

Why not just create an extra partition with the entire size if you need it?

Signature · 1 line
Bye, Peter Korsgaard