Teensy 4.1 + PSRAM + Winbond 25Q128JVSQ: Flash memory tests not working

Status
Not open for further replies.
Just FYI,

I have two Teensy 4.1 boards with that exact setup. So I gave flashtest6.ino a try (with the #if 0 changed to 1 in spiffs_t4.cpp as noted in post #5).
Here is what I got (framed by asterisks since I don't how to frame it):

As mentioned you can use the code tags...
The easiest way to add them in this forum is using the # button in to toolbar (Usually the last one, near the Quote button)...
 
I haven't received the new flash chips yet, meanwhile I have made other tests (https://forum.pjrc.com/threads/62896-Teensy-4-vs-Mega-2560-External-flash-memories-and-SPI) but I have also read all the forum topics I could about flash memories and Teensy 4.1. I suspect -at the moment I haven't been able to check- that the flash memories that work smoothly in Teensy 4.1 are those which supports SPI, QPI and DTR, that is the W25Q128JV_DTR while mine is the W25Q128JV (check the table below).

https://www.winbond.com/hq/product/...nor-flash/?__locale=en&selected=128Mb#Density

On the other hand, I confirm the small error in the comments of the code mentioned in post #5 that possibly comes from some previous tests. Where it says "528/5 = 132MHz" it should say "665/5 = 133MHz" because it is using "SEL: 2 DIV: 0 = 664.62000 MHz" (see the table in post #22) and not "SEL: 3 DIV: 0 = 528.00000 MHz".

The easiest way to add them in this forum is using the # button in to toolbar (Usually the last one, near the Quote button)...
I thought I had also mentioned it in my previous message. Thank you for the clarification.
 
Two more questions,

Where may I download the Teensy/FlexSPI documentation?

Can the library SPIFFS-FLASH-ONLY be modified to use an external flash memory (Winbond 25Q128JV) using CS, SCK, MISO and MOSI pins? How?
https://github.com/PaulStoffregen/teensy41_extram/tree/SPIFFS-FLASH-ONLY

Thanks in advance.

The processor has inbuilt QSPI mapping and control - documentation and details like the noted clocks and other elements are in the REF manual linked on the PJRC.com / Teensy / Datasheet section - the NXP 1060/1062 processor.

SPIFFS was implemented using the above noted hardware interface with QSPI 4 bit transfers controlled by the processor and direct memory mapping. Taking that to a single bit SPI interface would involve replacing that direct addressing code with needed overhead to read and write the and address an external chip directly.
 
I haven't received the new flash chips yet, meanwhile I have made other tests (https://forum.pjrc.com/threads/62896-Teensy-4-vs-Mega-2560-External-flash-memories-and-SPI) but I have also read all the forum topics I could about flash memories and Teensy 4.1. I suspect -at the moment I haven't been able to check- that the flash memories that work smoothly in Teensy 4.1 are those which supports SPI, QPI and DTR, that is the W25Q128JV_DTR while mine is the W25Q128JV (check the table below).

https://www.winbond.com/hq/product/...nor-flash/?__locale=en&selected=128Mb#Density

On the other hand, I confirm the small error in the comments of the code mentioned in post #5 that possibly comes from some previous tests. Where it says "528/5 = 132MHz" it should say "665/5 = 133MHz" because it is using "SEL: 2 DIV: 0 = 664.62000 MHz" (see the table in post #22) and not "SEL: 3 DIV: 0 = 528.00000 MHz".

I thought I had also mentioned it in my previous message. Thank you for the clarification.

Sorry I didn't get back to you sooner on this but I spent the day yesterday trying to get the sketch you posted working with my W25Q128JVM chip. However, no matter what I tried it would return all 0's for JEDEC. So this morning I tried @PaulStoffregen SerFlash library and it worked without an issue. Think there is a problem with your sketch SPI implementation with the Teensy.

Running the RawHardwareTest sketch from the library, after changing the ChipSelect pin to 10 I got the following info from the chip:
Code:
Raw SerialFlash Hardware Test

Read Chip Identification:
  JEDEC ID:     EF 70 18
  Part Nummber: (unknown chip)
  Memory Size:  16777216 bytes
  Block Size:   65536 bytes

Reading Chip...

Writing 32 signatures

Double Checking All Signatures:
  all 8192 signatures read ok

Checking Signature Pairs
  all 4095 signature pairs read ok

Checking Read-While-Write (Program Suspend)
  write 256 bytes at 512
  write time was 373 microseconds.
  read-while-writing: 00 00 00 00 15 F5 95 4B 
  test passed, good read while writing

Checking Read-While-Erase (Erase Suspend)
  erase time was 169338 microseconds.
  erase correctly erased 65536 bytes
  read-while-erasing: 00 00 00 00 15 F5 95 4B 
  test passed, good read while erasing

All Tests Passed  :-)

Test data was written to your chip.  You must run

EraseEverything before using this chip for files.
which is correct for the chip.

My wiring hookup:
Code:
Pin 1 (CS) -> pin 10 on T4.1
Pin 2 (DO) -> pin 12 (MISO)
Pin 3 (/WP) -> 3.3v
Pin 4 (GND) -> GND
Pin 5 (DI) -> pin 11 (MOSI)
Pin 6 (CLK) -> pin 13 (CLK)
Pin 7 (HOLD/RESET) -> 3.3v
Pin 8 (VCC) -> 3.3v

You might want to give this a go with your chip.
 
The processor has inbuilt QSPI mapping and control - documentation and details like the noted clocks and other elements are in the REF manual linked on the PJRC.com / Teensy / Datasheet section - the NXP 1060/1062 processor
Thank you very much. That is exactly what I was looking for.

SPIFFS was implemented using the above noted hardware interface with QSPI 4 bit transfers controlled by the processor and direct memory mapping. Taking that to a single bit SPI interface would involve replacing that direct addressing code with needed overhead to read and write the and address an external chip directly.
I understand, I will work with the sketch I posted in the other thread. Thanks.

On the other hand, I have received the new flash memories and as I suspected the problem was neither the library nor the quality of the soldering but the exact product number to be used with the Teensy 4.1 which should be Winbond W25Q128JV-DTR (Winbond W25Q128JV-DTR datasheet).

As I was saying, in other topics that I have read in the forum I have checked that tests ran by other users (f.e. @Han) began to work just when they installed a different flash memory. Following the Digikey links of @Han, @mjs513 and others it was obvious that the flash memory that works with Teensy 4.1 is the Winbond W25Q128JV-DTR.

Below I leave links to Mouser and Digikey:

https://www.mouser.es/ProductDetail/454-W25Q128JVSIM
https://www.digikey.com/product-detail/en/winbond-electronics/W25Q128JVSIQ/W25Q128JVSIQ-ND/5803943

and the result of the flashtest6.ino (from the SPIFFS-FLASH-ONLY library) with this new chip.

Code:
PSRAM: 8 MB

Enter 'y' in 6 seconds to format FlashChip - other to skip
FLASH ID: EF 40 18 00 00 00 00 00
at 0x 800000
Erasing... (may take some time)
.........................................................
Chip erased in 28 seconds.

Mount SPIFFS:
FLASH ID: EF 40 18 00 00 00 00 00
at 0x 800000
Mount ADDR 0x800000 with res: 0
Write file:
Hello World! What a wonderful World :)

Directory contents:
my_file1 [0001] size:38
Read file:
Hello World! What a wonderful World :)


    ERAM ========== memory map ===== array* ======== check24() : WRITE !!!!
		ERAM length 0x7FFFFE element size of 1
	 took 227424 elapsed us
    ERAM ============================ check24() : COMPARE !!!!
	 took 225150 elapsed us
Good, 	Found 24 in ERAM 7FFFFE Times

Mount SPIFFS:
Mount ADDR 0x800000 with res: 0
Directory contents:
my_file1 [0001] size:38

It's working!
------------------

Running the RawHardwareTest sketch from the library, after changing the ChipSelect pin to 10 I got the following info from the chip:
Thank you very much, I have tried with RawHardwareTest and it works like a charm. By the way I'm using the same wiring hookup.

I have noticed that this test does not distinguish between W25Q128FV and W25Q128JV flash drives because having a W25Q128JV on my SOIC-8 socket says it is a W25Q128FV. I will try to modify this test to find a direct or indirect way to know when it is a W25Q128FV and when a W25Q128JV.

Code:
Raw SerialFlash Hardware Test

Read Chip Identification:
  JEDEC ID:     EF 40 18
  Part Number:  W25Q128FV
  Memory Size:  16777216 bytes
  Block Size:   65536 bytes
Thank you again.

Definitely something must be wrong with Peter J. Torelli's windbond_serial_debug sketch for it not to work on the Teensy, but I still have no explanation as to why it works correctly with the Arduino Mega 2560, just like Prajwal Bhattaram's TestFlash sketch. By chance I have checked that if after running the RawHardwareTest sketch and restarting Teensy, I run Torelli's windbond_serial_debug, the first command always works. Surprising!
 
Last edited:
I have noticed that this test does not distinguish between W25Q128FV and W25Q128JV flash drives because having a W25Q128JV on my SOIC-8 socket says it is a W25Q128FV. I will try to modify this test to find a direct or indirect way to know when it is a W25Q128FV and when a W25Q128JV.
If you look at data sheet for the FV chip they both have the same device ID when in SPI Mode. It appears that when its in QSPI mode the device ID changes to 0x6018 but in SPI mode its 0x4018 (see page 15) which is making me wonder if initialization for the FV chip is compatible would have to do a dive into the spec sheet.

Definitely something must be wrong with Peter J. Torelli's windbond_serial_debug sketch for it not to work on the Teensy, but I still have no explanation as to why it works correctly with the Arduino Mega 2560, just like Prajwal Bhattaram's TestFlash sketch. By chance I have checked that if after running the RawHardwareTest sketch and restarting Teensy, I run Torelli's windbond_serial_debug, the first command always works. Surprising
Have to remember what works on the AVR Mega 2560 may not work on the Teensy directly without some rework. Compare the 2 libraries and you can see the differences.
 
@edamas and all interested parties

In reading the spec sheet in a bit more detail for the Winbond W25Q128FV as a result of testing with the SerFlash library I found the issue with using the FV chip.

Basically it boils down the fact that for the Chip to work in QSPI mode the QE bit in the status register 2 has to be enabled like we do the JVSIM flash chip. To be identified as a FV you have to put the chip in QSPI Mode and reread the JEDEC which is not done for the JV chip.

As a quick test of the FV chip you can change this in the begin of the cpp file:
Code:
	  if( flashID[1] == 0x70){
		uint8_t val[0];
		flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 );	

		val[0] |= 1<<1;

		FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x50);
		flexspi_ip_command(7, flashBaseAddr[_spiffs_region]);

		  FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x31) | LUT1(WRITE_SDR, PINS1, 1);
		  flexspi_ip_write(7, flashBaseAddr[_spiffs_region], val, 1);
	  }
to
Code:
	  //if( flashID[1] == 0x70){
		uint8_t val[0];
		flexspi_ip_read(9, flashBaseAddr[_spiffs_region], &val, 1 );	

		val[0] |= 1<<1;

		FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x50);
		flexspi_ip_command(7, flashBaseAddr[_spiffs_region]);

		  FLEXSPI2_LUT28 = LUT0(CMD_SDR, PINS1, 0x31) | LUT1(WRITE_SDR, PINS1, 1);
		  flexspi_ip_write(7, flashBaseAddr[_spiffs_region], val, 1);
	  //}
The change doesn't appear to affect the JVSIQ flash.
 
WOW! It works! This is an FV chip which never completed an erase before.
Code:
PSRAM: 0 MB

 Enter 'y' in 6 seconds to format FlashChip - other to skip

Erasing... (may take some time)

...................................................................................................
Chip erased in 49 seconds.


Mount SPIFFS:

Mount ADDR 0x800000 with res: 0
Write file:

Hello World! What a wonderful World :)



Directory contents:

my_file1 [0001] size:38
Read file:

Hello World! What a wonderful World :)





Mount SPIFFS:

Mount ADDR 0x800000 with res: 0
Directory contents:

my_file1 [0001] size:38

Thanks very much!

+ MultiFileTest works as well.

Pete
 
Last edited:
WOW! It works! This is an FV chip which never completed an erase before.
Code:
PSRAM: 0 MB
 Enter 'y' in 6 seconds to format FlashChip - other to skip
Erasing... (may take some time)
..................................................................................................
Chip erased in 49 seconds.

Thanks very much!

+ MultiFileTest works as well.

Pete

Glad we got it working I will go ahead and push the change to the repository,

Interesting that its taking 49 seconds to erase the FV. My JV takes about 26seconds. Did you change the clock setting by any chance?

Mike
 
I hadn't changed the clock - how would I do that?

IIRC - using the SPIFFS library sets the QSPI clock to 132 MHz from the otherwise default ~80 MHz QSPI clock set when PSRAM is detected.

Using that without change as that code does setup should have that clock setting at 132 ???
 
In reading the spec sheet in a bit more detail for the Winbond W25Q128FV as a result of testing with the SerFlash library I found the issue with using the FV chip.
Great news! Thank you @mjs513.

Interesting that its taking 49 seconds to erase the FV. My JV takes about 26seconds. Did you change the clock setting by any chance?
Mike, If I remember correctly the JV memory works at 132MHz while the FV works at 104MHz. What would be the values to set the clock to work with a 25Q128FV? Thanks in advance.
 
Great news! Thank you @mjs513.


Mike, If I remember correctly the JV memory works at 132MHz while the FV works at 104MHz. What would be the values to set the clock to work with a 25Q128FV? Thanks in advance.

Well to be on the safe size you can just comment the clock code out and it will use the default clock of 88Mhz, otherwise use that table I posted to set the correct settings for 104 Mhz.
 
Well to be on the safe size you can just comment the clock code out and it will use the default clock of 88Mhz,

Thank you. That may be the best choice.

otherwise use that table I posted to set the correct settings for 104 Mhz.

That is, one of these two values that are the closest without exceeding 104MHz:

Code:
SEL: 0  DIV: 3 = 99.00000 MHz ok
SEL: 1  DIV: 6 = 102.85714 MHz ok
 
I ordered some flashmem and what I ordered, was not what I got.

Apparently they sent me 25Q128JVSQ chips.

Soooo.... is there A "25Q128JVSQ for dummies" guide to reduce all this down to make it usable?

Or should I just return and order else where to get right chips?

And as of today, 11/10/21 , what is best libraries to use to access this?

Thread is aged A bit so want to make sure not doing something I shouldn't or stuff already fixed code wise to work.
 
If you look at the LittleFS Readme page: https://github.com/PaulStoffregen/LittleFS

I think I saw something similar with the 25Q128JVSQ
When I looked last week. I think that is the markings on the chip for the W25Q128JVSIQ which is on the list...

You will see a set of chips that are supported by the library:

Just an FYI - I just happened to order a few different ones to play with today:
screenshot.jpg

Aarg looks like my test board lost it's last set of edits...
screenshot2.jpg
I had edited the last one to move to use pin 6 instead of Pin 7, for the 4th memory, but looks like the edit was lost...

Will probably edit again and order new set... With that change can then run with Audio board as well...

As fir best library I am using LittleFS as that is the one that comes with Teensyduino.
 
If you look at the LittleFS Readme page: https://github.com/PaulStoffregen/LittleFS

I think I saw something similar with the 25Q128JVSQ
When I looked last week. I think that is the markings on the chip for the W25Q128JVSIQ which is on the list...

You will see a set of chips that are supported by the library:

Just an FYI - I just happened to order a few different ones to play with today:
View attachment 26479

Aarg looks like my test board lost it's last set of edits...
View attachment 26480
I had edited the last one to move to use pin 6 instead of Pin 7, for the 4th memory, but looks like the edit was lost...

Will probably edit again and order new set... With that change can then run with Audio board as well...

As fir best library I am using LittleFS as that is the one that comes with Teensyduino.

Using the LittleFS QSPI example to test it and it worked fine. Detected the full 16mb size.
Able to format/read/write/ect.

So pretty happy it worked out in the end. Just when I opened up package and read chip model, I was worried things would have been ugly.
Luckly I am late to the party, so all you guys figured this out to make it easy for people like me :)

I was able to move my code away from saving my settings data and such to the flashmem away from the SD card.

This is so nice :)
 
Last edited:
Status
Not open for further replies.
Back
Top