SerialFlash.begin always returns true, even when no SPI flash is connected

Ben

Well-known member
Hi,

I today tried to determine if an SPI flash IC is connected by checking the SerialFlash.begin return value. Turns out the function returns true unconditionally.

I reproduced this with a Teensy 3.2 with nothing attached and the ListFiles example. This error message:

Code:
if (!SerialFlash.begin(FlashChipSelect)) {
    error("Unable to access SPI Flash chip");
  }
is never printed over Serial.

Ben
 
Hmmm, looks like the library's begin() should check some of the readID() bytes and if all 0 or all 0xff return false. capacity() already does such a check, so maybe in begin() one would add
Code:
...
       readID(id);
       [B]if ((id[0]==0 && id[1]==0 && id[2]==0) || 
		(id[0]==255 && id[1]==255 && id[2]==255)) {
		return false;
       }[/B]
       f = 0;
 
Last edited:
Back
Top