As I still get deeper and deeper into why FAT doesn't work on my MT25Q NOR
flash device, I have found a minor error in m25px.c

The M25P devices have a bulk erase command (0xC7) but this is not supported
by the MT25Q, which has a "die erase" command (0xC4) instead and 0xC7 is
meaningless.

There is a #define for this as expected:

#define M25P_BE 0xc7

Adding

#define M25Q_DE 0xc4

Make sense but...

When the device manufacturer ID is read this is actually saved, so it can't
be tested at runtime to choose the right command.

The straightforward fix is to move the #define for M25_BE to within the code
that tests the manufacturer ID (to ensure it's a valid device for these
functions) but that is a bit messy and moves the #define away from all the
other related #defines. Doesn't feel right.

There is no unique CONFIG_ attribute that says whether it is or isn't
expecting to find an M25P or M25Q (which is reasonable) so I can't use
conditional #defines.

And don't want to mess up other people's boards by changing Kconfig in any
way that isn't backwards compatible, although the inviolable "Sometimes Code
Duplication is OK" might suggest it would be better to copy out m25px.c as
m25lx.c and make the change so that Kconfig demands you choose one or the
other or both of the two types...and if I find more errors/differences that
may ultimately make sense of course.

Can anyone suggest the "NuttX way" to do this, assuming I don't find a
myriad of other errors/differences that "force" duplication?



Reply via email to