Skip to contentSkip to conversation

How can I prevent MTD to access the end of a flash device ?

DISCUSSION Franck 4 participants 11 messages Nov 7, 2005 – Apr 24, 2006 Memory technology devices (MTD)

lore
Share & tools
lore

Franck

author
#0 lore raw

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The second question is about the "cacheable" mapping field in map_info structure. I looked at others drivers and this field seems to be optional. Does this field, if set, improve flash access a lot ? Should I set up a cacheable mapping ?

Thanks
--
Franck

PS: could you CC me in your answer since I'm not subscribed to the list

author
#1 lore raw

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The second question is about the "cacheable" mapping field in map_info structure. I looked at others drivers and this field seems to be optional. Does this field, if set, improve flash access a lot ? Should I set up a cacheable mapping ?

Thanks
--
Franck

#2 lore raw
Quoted 10 lines · Franck

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The chip driver will detect a 32MiB chip from the CFI probe. The map size isn't really used by the chip driver, it's just needed to ensure that the area is accessible. What you could try doing is adding a cfi_fixup function that changes the CFI data read in to remove the last 64KiB of the chip... not sure if that will work though.

Quoted 4 lines

The second question is about the "cacheable" mapping field in map_info structure. I looked at others drivers and this field seems to be optional. Does this field, if set, improve flash access a lot ? Should I set up a cacheable mapping ?

Usually this isn't something you want to do especially with flash. If a cache line is flushed back to the chip it's probably not going to work. The cacheable mappings work for RAM based devices though.

josh

#3 lore raw
In reply to Franck
Quoted 4 lines · Franck

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

Please consider using the MTD mailing list next time (you certainly read about it on the MTD web site).

Quoted 5 lines

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The easiest thing to do is to define MTD partitions, the last one being the excluded flash area.

Quoted 3 lines

The second question is about the "cacheable" mapping field in map_info structure. I looked at others drivers and this field seems to be optional.

It is.

Quoted 1 line

Does this field, if set, improve flash access a lot ?

Yes. It was tested on ARM only though. Some architectures like i386 for example might need special tricks to implement this.

Quoted 1 line

Should I set up a cacheable mapping ?

Consider the comment for the inval_cache method in include/linux/mtd/map.h and look at lubbock-flash.c for example.

Nicolas

author
#4 lore raw

Hi.

2005/11/22, Nicolas Pitre <[email protected]>:

Quoted 3 lines

Please consider using the MTD mailing list next time (you certainly read about it on the MTD web site).

I did....

Quoted 3 lines

Yes. It was tested on ARM only though. Some architectures like i386 for example might need special tricks to implement this.

do you know why ? What was the gain on ARM ?

Thanks
--
Franck

#5 lore raw
Quoted 5 lines · Franck
Quoted 3 lines

Yes. It was tested on ARM only though. Some architectures like i386 for example might need special tricks to implement this.

do you know why ?

Apparently i386 might have issues having two virtual mappings for the same physical address range. This can be worked around in the map driver by relying on the knowledge of flash aliases on the bus.

Quoted 1 line

What was the gain on ARM ?

The ability to use burst transfers which are only activated with cached memory, hence twice the read speed or more.

Nicolas

#6 lore raw
In reply to Nicolas Pitre

Nicolas,

2005/11/22, Nicolas Pitre <[email protected]>:

Quoted 10 lines · Franck
Quoted 5 lines

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

Please consider using the MTD mailing list next time (you certainly read about it on the MTD web site).

Quoted 9 lines
Quoted 5 lines

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The easiest thing to do is to define MTD partitions, the last one being the excluded flash area.

I hope you don't mind if I continue this thread 5 months later...I put this issue in my TODO list and now I really need to fix it.

Your advice seems fine, but it brings some restrictions on flash
concatenations: for example, if I have 2 flashes of 32Mbytes, I need to create 2 partitions whose sizes are 32M - 64K bytes but then I can't concatenate these two partitions anymore since concatenation works with mtd devices, not partitions, does it ?

It seems easier to simply probe the flash, then check for its size and eventually restrict the end of it if needed:

        *mtd = do_map_probe("xxx_probe", map);
        while (mtd->size > 32Mb - 64Kb)
                (*mtd)->size -= (*mtd)->erasesize;

But I don't know if the MTD layer allows this kind of operation, do you ?

Thanks
--
Franck

#7 lore raw
Quoted 23 lines · Franck Bui-Huu

Nicolas,

2005/11/22, Nicolas Pitre <[email protected]>:

Quoted 10 lines · Franck
Quoted 5 lines

Hi,

I have two questions that I can't answer by my own. I tried to look at FAQ and documentation on MTD website but found no answer.

Please consider using the MTD mailing list next time (you certainly read about it on the MTD web site).

Quoted 9 lines
Quoted 5 lines

First question is about size of flash. I have a Intel strataflash whose size is 32MB but because of a buggy platform hardware I can't access to the last 64KB of the flash. How can I make MTD module aware of this new size. The restricted map size is initialized by my driver but it doesn't seem to be used by MTD.

The easiest thing to do is to define MTD partitions, the last one being the excluded flash area.

Quoted 8 lines

I hope you don't mind if I continue this thread 5 months later...I put this issue in my TODO list and now I really need to fix it.

Your advice seems fine, but it brings some restrictions on flash
concatenations: for example, if I have 2 flashes of 32Mbytes, I need to create 2 partitions whose sizes are 32M - 64K bytes but then I can't concatenate these two partitions anymore since concatenation works with mtd devices, not partitions, does it ?

MTD partitions are MTD "devices" as well.

Nicolas

#8 lore raw

2006/4/23, Nicolas Pitre <[email protected]>:

Quoted 10 lines · Franck Bui-Huu
Quoted 6 lines

Your advice seems fine, but it brings some restrictions on flash
concatenations: for example, if I have 2 flashes of 32Mbytes, I need to create 2 partitions whose sizes are 32M - 64K bytes but then I can't concatenate these two partitions anymore since concatenation works with mtd devices, not partitions, does it ?

MTD partitions are MTD "devices" as well.

well, mtd_concat_create() functions doesn't use MTD partitions...and what's happening if the user needs to use its own partitions based on a device resulting of several concatenated flashes? It migth be possible to still use your solution and just fix user partitions but it really seems easier to fix the MTD size after it the flash has been probed.

Do you think it's possible to change the size of a mtd device rigth after probing it ?

Thanks
--
Franck

#9 lore raw
Quoted 6 lines · Franck Bui-Huu

well, mtd_concat_create() functions doesn't use MTD partitions...and what's happening if the user needs to use its own partitions based on a device resulting of several concatenated flashes? It migth be possible to still use your solution and just fix user partitions but it really seems easier to fix the MTD size after it the flash has been probed.

MTD partitions aren't like block device partitions. You just get a set of MTD devices which are like a wrapper around the original.

MTD concat is the same. You should be able to partition and concat and partition and concat on top of each other to your heart's content. If you so desire.

Quoted 2 lines

Do you think it's possible to change the size of a mtd device rigth after probing it ?

Yes, that works too.

Signature · 1 line
dwmw2
#10 lore raw

2006/4/24, David Woodhouse <[email protected]>:

Quoted 7 lines

MTD partitions aren't like block device partitions. You just get a set of MTD devices which are like a wrapper around the original.

MTD concat is the same. You should be able to partition and concat and partition and concat on top of each other to your heart's content. If you so desire.

oh ok...should I simply use add_mtd_partitions(...) function to create a new MTD device based on a given partition ?

Quoted 5 lines
Quoted 2 lines

Do you think it's possible to change the size of a mtd device rigth after probing it ?

Yes, that works too.

In your opinion, what is the right thing to do ?

thanks
--
Franck