Problem writing to NOR flash
Hi all,
We're using a 2.4.20 derived kernel, and a while back updated to a recent MTD snapshot to get support for the Samsung NAND 128MiB on our hardware).
However, we found that with this snapshot, we could no longer write to the NOR flash on our board (I posted a message about this on 19th July, but had no responses).
To see if this problem has now been fixed, I have just downloaded the latest snapshot to try. However, I can no longer get this to compile. After changing some Makefiles, I have now found that the new code uses 'kvec' in place of 'iovec'. Is this a 2.6 feature?
If so, are there any plans to make the current MTD code work with 2.4?
What would people recommend we do in order to get working MTD support for the chips on our board for a 2.4 kernel?
Many thanks.
Andy
Quoted 2 lines · Andy Hawkins
We're using a 2.4.20 derived kernel, and a while back updated to a recent MTD snapshot
The same for 2.4.26.
Quoted 6 lines
To see if this problem has now been fixed, I have just downloaded the latest snapshot to try. However, I can no longer get this to compile. After changing some Makefiles, I have now found that the new code uses 'kvec' in place of 'iovec'. Is this a 2.6 feature?
If so, are there any plans to make the current MTD code work with 2.4?
Porting of current MTD snapshot that oriented to 2.6 kernel is not simple task. I did it for my hardware and have some patch set.
Quoted 2 lines
What would people recommend we do in order to get working MTD support for the chips on our board for a 2.4 kernel?
Ask me for these patches, extend it for your hardware set and try to push it back to MTD source.
Hi,
Quoted 8 lines
Porting of current MTD snapshot that oriented to 2.6 kernel is not simple task. I did it for my hardware and have some patch set.
Quoted 2 lines
What would people recommend we do in order to get working MTD support for the chips on our board for a 2.4 kernel?
Ask me for these patches, extend it for your hardware set and try to push it back to MTD source.
Can I have a copy of these patches then? Have you had any problems writing to NOR?
Thanks.
Andy
Quoted 10 lines · Andy Hawkins
Quoted 8 lines
Porting of current MTD snapshot that oriented to 2.6 kernel is not simple task. I did it for my hardware and have some patch set.
Quoted 2 lines
What would people recommend we do in order to get working MTD support for the chips on our board for a 2.4 kernel?
Ask me for these patches, extend it for your hardware set and try to push it back to MTD source.
Can I have a copy of these patches then?
Some time later (a few days).
Quoted 1 line
Have you had any problems writing to NOR?
No, after upgrade from the MTD snapshot.
There were problems with erase (ioctl call did not wait of completion of erase operation) and jffs2 did not allowed to write. Now it works properly.
Hi,
Quoted 3 lines · Dmitry A. Fedorov
Quoted 1 line
Can I have a copy of these patches then?
Some time later (a few days).
Thanks for that.
Quoted 7 lines
Quoted 2 lines
Have you had any problems writing to NOR?
No, after upgrade from the MTD snapshot.
There were problems with erase (ioctl call did not wait of completion of erase operation) and jffs2 did not allowed to write. Now it works properly.
Ah, should have been more clear. This is a 'raw' write to the NOR device. It appears that it's crashing inside do_xxlock_oneblock in cfi_cmdset_0002.c (where it does the 'cfi_write').
There's a comment at the top of the code saying that it's very chip specific, and hasn't been tested on an interleaved device (which I think mine is).
Anyone help?
Thanks.
Andy
Quoted 7 lines · Andy Hawkins
Quoted 6 lines
Quoted 1 line
Have you had any problems writing to NOR?
No, after upgrade from the MTD snapshot.
There were problems with erase (ioctl call did not wait of completion of erase operation) and jffs2 did not allowed to write. Now it works properly.
Quoted 6 lines
Ah, should have been more clear. This is a 'raw' write to the NOR device. It appears that it's crashing inside
do_xxlock_oneblockincfi_cmdset_0002.c(where it does the 'cfi_write').
There's a comment at the top of the code saying that it's very chip specific, and hasn't been tested on an interleaved device (which I think mine is).
I have use the same cmdset (exactly) but single (interleave 1) 16 bit wide chip Am29LV640. No problems yet with backported code.
Hi,
Quoted 2 lines · Dmitry A. Fedorov
I have use the same cmdset (exactly) but single (interleave 1) 16 bit wide chip Am29LV640. No problems yet with backported code.
I've been doing a bit of digging now. The chip in question is an ST M29W320DB (32MBit)
do_xxlock_oneblock is called, with an address of 0. However, this is translated in the function to an address of ffc00002. This address is then (eventually) passed into map_write16, which adds the virtual address of the flash onto this address...
This to me appears to be invalid, but I'm not entirely sure what *should* be happening here. The chip's start address is added on to the address inside do_xxlock_oneblock (although this is zero), and then the virtual address is added on again. However, the translation doesn't appear correct to me:
adr = ((adr & ~0xffff) | 0x2) + ~0x3fffff;
As you can probably tell, I don't fully understand how the code is *supposed* to work, so it's difficult to know exactly what is going wrong here.
Thanks.
Andy
Hi all,
After a bit more digging and reading of the data sheet, it appears the the chip I'm using doesn't need locking and unlocking. I then went back to the version of the code where we had this working (whatever came with the 2.4.20 kernel) and found that none of this locking / unlocking mechanism was present.
So, to test I commented out the contents of cfi_amdstd_lock_varsize and cfi_amdstd_unlock_varsize, and I can now successfully write to the NOR!
Are these functions only required for some very specific chips? If so, what is the *correct* way for this code to determine whether or not they are needed (this code is in a 'generic' file, so I'm surprised that there's chip specific information in there).
Thanks for any advice you can offer.
Andy
Quoted 4 lines · Andy Hawkins
To see if this problem has now been fixed, I have just downloaded the latest snapshot to try. However, I can no longer get this to compile. After changing some Makefiles, I have now found that the new code uses 'kvec' in place of 'iovec'. Is this a 2.6 feature?
Yes.
Quoted 1 line
If so, are there any plans to make the current MTD code work with 2.4?
No.
Quoted 2 lines
What would people recommend we do in order to get working MTD support for the chips on our board for a 2.4 kernel?
Use 2.6.
Signature · 1 line
dwmw2
Quoted 8 lines · Andy Hawkins
Hi all,
After a bit more digging and reading of the data sheet, it appears the the chip I'm using doesn't need locking and unlocking. I then went back to the version of the code where we had this working (whatever came with the 2.4.20 kernel) and found that none of this locking / unlocking mechanism was present.
Quoted 4 lines
So, to test I commented out the contents of
cfi_amdstd_lock_varsizeandcfi_amdstd_unlock_varsize, and I can now successfully write to the NOR!Are these functions only required for some very specific chips?
Yes.
Quoted 4 lines
If so,
what is the *correct* way for this code to determine whether or not they are needed (this code is in a 'generic' file, so I'm surprised that there's chip specific information in there).
When Thayne wrote the code he was assuming that since there were no lock/unlock functions the lock/unlock entry points were simply not called. And he figured if it actually broken something someone would scream. And then he thought someone had removed the code when cfi_cmdset_0002 was scrubbed a while ago.
In addition that code really is generic, it applies to firmware hub parts and there are chips that use both cfi_cmdset_0001 and cfi_cmdset_0002 that can use it.
When I get a chance it is my intention to refactor the probing routines to make handling of chips with special capabilities simpler.
As a first step I am putting a few conditionals in cfi_amdstd_setup so that chips that we won't use those methods on chips that don't support them. Then we can look at better ways to organize the probe code so the probe/setup code is not such a mess.
I have the first chunk done but I'm not ready to check it in until I have a chance to test it. And I am swamped right now...
Eric
Quoted 11 lines · [email protected] (Eric W. Biederman) writes:
Quoted 4 lines · Andy Hawkins
If so,
what is the *correct* way for this code to determine whether or not they are needed (this code is in a 'generic' file, so I'm surprised that there's chip specific information in there).I have the first chunk done but I'm not ready to check it in until I have a chance to test it. And I am swamped right now..
Well the changes wound up being a little more extensive than
I described them. But the code in cfi_cmdset_0001 and cfi_cmdset_0002 should now be free of incorrect assumptions about what a flash chip can do.
As for the correct way to do this it probably still needs a little more code review but there are fixup functions that are called when command sets are initialized that allow for weird cases to be special cased.
Eric