SPIMemory don't work with flash memory and Arduino Zero

Hello,
i'm using arduino zero with 26F064B spi flash memory chip connected to icsp interface and chip select in D10. WP and HOLD/RESET are pulled high.

Running the FlashDiagnostics sketch of the SPIMemory latest library (Arduino IDE 1.8.13) this is the output of serial monitor.

`Initialising..........

SPIMemory Library version: < 2.5.0

JEDEC ID: 0xDF081B
Man ID: 0xDF
Memory ID: 0x8
Capacity: 0
Max Pages: 0


						Testing library code

		Function		Test result			     Runtime

		Power Down		   PASS				      0 us
		Power Up		   FAIL	

		Erase Chip		   FAIL	
		Erase 72KB		   FAIL	
		Erase 64KB		   FAIL	
		Erase 32KB		   FAIL	
		Erase 4KB		   FAIL	

		Data type		I/O Result	      Write time	      Read time

		Byte			   FAIL				      0 us
		Char			   FAIL				      0 us
		Word			   FAIL				      0 us
		Short			   FAIL				      0 us
		ULong			   FAIL				      0 us
		Long			   FAIL				      0 us
		Float			   FAIL				      0 us
		Struct			   FAIL				      0 us
		Byte Array		   FAIL	0, 	   FAIL	1, 	   FAIL	2, 	   FAIL	3, 	   FAIL	4, 	   FAIL	5, 	   FAIL	6, 	   FAIL	7, 	   FAIL	8, 	   FAIL	9, 	   FAIL	10, 	   FAIL	11, 	   FAIL	12, 	   FAIL	13, 	   FAIL	14, 	   FAIL	15, 	   FAIL	16, 	   FAIL	17, 	   FAIL	18, 	   FAIL	19, 	   FAIL	20, 	   FAIL	21, 	   FAIL	22, 	   FAIL	23, 	   FAIL	24, 	   FAIL	25, 	   FAIL	26, 	   FAIL	27, 	   FAIL	28, 	   FAIL	29, 	   FAIL	30, 	   FAIL	31, 	   FAIL	32, 	   FAIL	33, 	   FAIL	34, 	   FAIL	35, 	   FAIL	36, 	   FAIL	37, 	   FAIL	38, 	   FAIL	39, 	   FAIL	40, 	   FAIL	41, 	   FAIL	42, 	   FAIL	43, 	   FAIL	44, 	   FAIL	45, 	   FAIL	46, 	   FAIL	47, 	   FAIL	48, 	   FAIL	49, 	   FAIL	50, 	   FAIL	51, 	   FAIL	52, 	   FAIL	53, 	   FAIL	54, 	   FAIL	55, 	   FAIL	56, 	   FAIL	57, 	   FAIL	58, 	   FAIL	59, 	   FAIL	60, 	   FAIL	61, 	   FAIL	62, 	   FAIL	63, 	   FAIL	64, 	   FAIL	65, 	   FAIL	66, 	   FAIL	67, 	   FAIL	68, 	   FAIL	69, 	   FAIL	70, 	   FAIL	71, 	   FAIL	72, 	   FAIL	73, 	   FAIL	74, 	   FAIL	75, 	   FAIL	76, 	   FAIL	77, 	   FAIL	78, 	   FAIL	79, 	   FAIL	80, 	   FAIL	81, 	   FAIL	82, 	   FAIL	83, 	   FAIL	84, 	   FAIL	85, 	   FAIL	86, 	   FAIL	87, 	   FAIL	88, 	   FAIL	89, 	   FAIL	90, 	   FAIL	91, 	   FAIL	92, 	   FAIL	93, 	   FAIL	94, 	   FAIL	95, 	   FAIL	96, 	   FAIL	97, 	   FAIL	98, 	   FAIL	99, 	   FAIL	100, 	   FAIL	101, 	   FAIL	102, 	   FAIL	103, 	   FAIL	104, 	   FAIL	105, 	   FAIL	106, 	   FAIL	107, 	   FAIL	108, 	   FAIL	109, 	   FAIL	110, 	   FAIL	111, 	   FAIL	112, 	   FAIL	113, 	   FAIL	114, 	   FAIL	115, 	   FAIL	116, 	   FAIL	117, 	   FAIL	118, 	   FAIL	119, 	   FAIL	120, 	   FAIL	121, 	   FAIL	122, 	   FAIL	123, 	   FAIL	124, 	   FAIL	125, 	   FAIL	126, 	   FAIL	127, 	   FAIL	128, 	   FAIL	129, 	   FAIL	130, 	   FAIL	131, 	   FAIL	132, 	   FAIL	133, 	   FAIL	134, 	   FAIL	135, 	   FAIL	136, 	   FAIL	137, 	   FAIL	138, 	   FAIL	139, 	   FAIL	140, 	   FAIL	141, 	   FAIL	142, 	   FAIL	143, 	   FAIL	144, 	   FAIL	145, 	   FAIL	146, 	   FAIL	147, 	   FAIL	148, 	   FAIL	149, 	   FAIL	150, 	   FAIL	151, 	   FAIL	152, 	   FAIL	153, 	   FAIL	154, 	   FAIL	155, 	   FAIL	156, 	   FAIL	157, 	   FAIL	158, 	   FAIL	159, 	   FAIL	160, 	   FAIL	161, 	   FAIL	162, 	   FAIL	163, 	   FAIL	164, 	   FAIL	165, 	   FAIL	166, 	   FAIL	167, 	   FAIL	169, 	   FAIL	170, 	   FAIL	171, 	   FAIL	172, 	   FAIL	173, 	   FAIL	174, 	   FAIL	175, 	   FAIL	176, 	   FAIL	177, 	   FAIL	178, 	   FAIL	179, 	   FAIL	180, 	   FAIL	181, 	   FAIL	182, 	   FAIL	183, 	   FAIL	184, 	   FAIL	185, 	   FAIL	186, 	   FAIL	187, 	   FAIL	188, 	   FAIL	189, 	   FAIL	190, 	   FAIL	191, 	   FAIL	192, 	   FAIL	193, 	   FAIL	194, 	   FAIL	195, 	   FAIL	196, 	   FAIL	197, 	   FAIL	198, 	   FAIL	199, 	   FAIL	200, 	   FAIL	201, 	   FAIL	202, 	   FAIL	203, 	   FAIL	204, 	   FAIL	205, 	   FAIL	206, 	   FAIL	207, 	   FAIL	208, 	   FAIL	209, 	   FAIL	210, 	   FAIL	211, 	   FAIL	212, 	   FAIL	213, 	   FAIL	214, 	   FAIL	215, 	   FAIL	216, 	   FAIL	217, 	   FAIL	218, 	   FAIL	219, 	   FAIL	220, 	   FAIL	221, 	   FAIL	222, 	   FAIL	223, 	   FAIL	224, 	   FAIL	225, 	   FAIL	226, 	   FAIL	227, 	   FAIL	228, 	   FAIL	229, 	   FAIL	230, 	   FAIL	231, 	   FAIL	232, 	   FAIL	233, 	   FAIL	234, 	   FAIL	235, 	   FAIL	236, 	   FAIL	237, 	   FAIL	238, 	   FAIL	239, 	   FAIL	240, 	   FAIL	241, 	   FAIL	242, 	   FAIL	243, 	   FAIL	244, 	   FAIL	245, 	   FAIL	246, 	   FAIL	247, 	   FAIL	248, 	   FAIL	249, 	   FAIL	250, 	   FAIL	251, 	   FAIL	252, 	   FAIL	253, 	   FAIL	254, 	   FAIL	255, 	   PASS				      0 us
		String			   FAIL				      0 us

To see function runtimes ncomment RUNDIAGNOSTIC in SPIMemory.h.
`
The memory chip has been tested by the author of the library. The connections are OK and i have checked them several times.

If i read the output from flash.begin() it says 0.

Anyone have faced to similar problem?
thanks

Which library are you using? Is it this one on github? I can't see a 26F064B device in the "Flash memory compatibility - Actually tested with" table.

Sorry, that is the code marked on the chip, but im using breakout board of that chip that is SST26VF064B (tested with library).
Im using the latest lib version 3.4.0.

I've not used flash memory much so i'm not entirely sure that i'm interpreting the Microchip datasheet correctly for a SST26VF064B. The datasheet from their website says on page 24 - section 5.14 "JEDEC-ID Read (SPI Protocol)" that the manufacturer ID is 0xBF rather than the 0xDF that is being reported.

It might be nothing (because I can't interpret the datasheet correctly!) or it might indicate you don't have the device you think you have ...

I do not know if the ID is different so the memory is incompatible. The memory part number is the same tested by the author...

A quick look at the datasheet for the Microchip SST26VF064B shows that on the top of the actual chip there will be some identifying information - i.e. 26F064B plus some other letters/numbers relating to the year of manufacture etc, and the Microchip logo - an M in a circle.

Hopefully you have the Microchip logo on yours?

yes there is the logo. the breakout board is this one: MIKROE-2267 from MikroElektronika

That looks pretty genuine. I had a look at that website for details on the board you have. I think you would wire it up as follows:

FLASH SDI -> SPI Header pin 4 (MOSI)
FLASH SDO -> SPI Header pin 1 (MISO)
FLASK SCK -> SPI Header pin 3 (SCK)
FLASH CS -> D10
FLASH GND -> SPI Header pin 6 (GND)
FLASH 3V3 -> +3V3 - NOT SPI Header pin 2 as that's 5V.

The schematic for the breakout board shows pullup resistors fitted to WP and HOLD so you should not need them externally.

Putting some print inside the begin() function i found it blocks at this line

#ifdef SPI_HAS_TRANSACTION
  //Define the settings to be used by the SPI bus
  if (!_SPISettingsSet) {
    _settings = SPISettings(SPI_CLK, MSBFIRST, SPI_MODE0);
  }

I do not know how to debug anymore

@markd833 it is already connected like you say, despite the gnd is taken near to the 3v3 header pin.

Ok, as a sanity check, if you disconnect the SDO/MISO wire, what happens?

It might hang the code or report an error. Just trying to check that there isn't another device on the board or elsewhere that the code is talking to instead of the flash chip.

I'm also trying the PaulStoffregen/SerialFlash to check if something happen.
with this one i get this

`Raw SerialFlash Hardware Test
1

Read Chip Identification:
JEDEC ID: BF 26 43
Part Nummber: (unknown chip)
Memory Size: 1048576 bytes
Block Size: 65536 bytes

Reading Chip...

Writing 512 signatures
error writing signature at 0
Read this: FF FF FF FF FF FF FF FF
Expected: 00 00 00 00 15 F5 95 4B

Tests Failed :{

The flash chip may be left in an improper state.
You might need to power cycle to return to normal.
`
If i disconnect the CS pin i cant get info from flash. The memory seems erased since i read FF but is not able to write on it.
If i try to disconnect one of the communication wires the sketch is not able to read any info from the memory.

Before getting this quite working i have slow down the clock frequency of spi (into the library) from 50MHz to 4MHz.
There is a way to do the same with the SPIMemory library?

If you can read the JEDEC ID, this means your SPI connection is already good. As for failing the write test, maybe the library is not handling the WEL (write-enable latch) command properly. This WEL command is pretty common to all NOR flash that I've dealt with.

Progress. :boom: That's the correct ID for the chip you have according to the Microchip datasheet. I don't know why your earlier library displayed the wrong ID. I don't think Pauls library supports the chip you have, which is a shame as it seems to correctly interact with the chip registers.

The first id reading has been done with the spimemory lib. This last one with the pauls lib after slowing down the spi clk speed (possible in this lib).
So i think i have to shorten my electrical wires from arduino to memory.

It looks like the SPIMemory library has a setClock() function that takes a speed like the SPISettings takes. You could try that to slow your clock down and see if that helps.

SOLUTION: shortened the wires and set the max clock frequency to 10MHz with setClock(1000000);

In this way the SPIMemory lib works with my chip.

Thanks