Forum Rule: Always post complete source code & details to reproduce any issue!
Page 2 of 2 FirstFirst 1 2
Results 26 to 43 of 43

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

  1. #26
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,641
    Quote Originally Posted by SR61 View Post
    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)...

  2. #27
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    I haven't received the new flash chips yet, meanwhile I have made other tests (https://forum.pjrc.com/threads/62896...mories-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/c...=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".

    Quote Originally Posted by KurtE View Post
    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.

  3. #28
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    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/te...FFS-FLASH-ONLY

    Thanks in advance.

  4. #29
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,377
    Quote Originally Posted by edamas View Post
    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/te...FFS-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.

  5. #30
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    Quote Originally Posted by edamas View Post
    I haven't received the new flash chips yet, meanwhile I have made other tests (https://forum.pjrc.com/threads/62896...mories-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/c...=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.

  6. #31
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    Quote Originally Posted by defragster View Post
    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.

    Quote Originally Posted by defragster View Post
    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-deta...SIQ-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!
    ------------------

    Quote Originally Posted by mjs513 View Post
    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 by edamas; 09-07-2020 at 04:52 PM.

  7. #32
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    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.

  8. #33
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    @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.

  9. #34
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,452
    @mjs513: which cpp file are you referring to?

    Thanks
    Pete

  10. #35
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    Quote Originally Posted by el_supremo View Post
    @mjs513: which cpp file are you referring to?

    Thanks
    Pete
    Sorry Pete. Forgot. The file is spiffs_t4.cpp. It's at about line 131.

    Mike

  11. #36
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,452
    Thanks.

    Pete

  12. #37
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,452
    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 by el_supremo; 09-08-2020 at 05:20 PM. Reason: add info

  13. #38
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    Quote Originally Posted by el_supremo View Post
    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

  14. #39
    Senior Member
    Join Date
    Nov 2012
    Posts
    1,452
    I hadn't changed the clock - how would I do that?

    Pete

  15. #40
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    12,377
    Quote Originally Posted by el_supremo View Post
    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 ???

  16. #41
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    Quote Originally Posted by mjs513 View Post
    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.

    Quote Originally Posted by mjs513 View Post
    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.

  17. #42
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,588
    Quote Originally Posted by edamas View Post
    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.

  18. #43
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    Quote Originally Posted by mjs513 View Post
    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.

    Quote Originally Posted by mjs513 View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •