Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: psram with qspi flash on teensy 4.1

  1. #1
    Junior Member
    Join Date
    Sep 2018
    Posts
    13

    psram with qspi flash on teensy 4.1

    I added a psram (IPS6404 on the left) and a flash chip (Winbond 25Q128JVSQ) to the two pads (see image).

    The PSRAM works like a charm, the test program (teensy41_psram_memtest) works

    However, I can not figure out how to use the QSPI flash memory

    Any help would be appreciated, e.g. a link to a test program/library for accessing flash.

    Cheers
    scjurgen

    Click image for larger version. 

Name:	IMG_6205.jpg 
Views:	10 
Size:	312.3 KB 
ID:	21437

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    7,623
    You can simply just address the memory....

    However some of the support is not as complete as it hopefully will be:

    There is a new memory designation (EXTMEM) you can specify as part of a define that puts it in this range.

    With one of my debug setups, that uses this I have code like:

    Code:
    uint8_t debug_stream_buffer[2048 * 1024] EXTMEM;
    extern "C"
    {
      extern uint8_t external_psram_size;
    }
    ...
      if (external_psram_size == 0) {
        uint8_t * debug_buffer = (uint8_t*)malloc(256 * 1024);
        if (debug_buffer) {
          Serial.println("\n*** USBHost Debug data - No external PSRAM using DMAMEM ***");
          USBHostDebugStream.setBuffer(debug_buffer, 256 * 1024);
        } else {
          Serial.println("\n*** USBHost Debug data - No external PSRAM malloc failed ***");
          USBHostDebugStream.setBuffer(debug_buffer, 0);
          USBHostDebugStream.enable(false);
    
        }
      }
    The memory is defined starting at:
    Code:
    	ERAM (rwx):  ORIGIN = 0x70000000, LENGTH = 16384K
    Obviously the actual size of memory you have will influence if you have that full length or not.

    What we don't yet have is some official way to allocate the unused parts of this memory yet.

    We had proposals for doing this, but so far consensus on the APIs for doing this.
    Also so far there is no code in place to allow this region of memory to have initialized variables as part of it.

    Hope that at least gets you going.

  3. #3
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585
    You can take a look at these two libraries: https://github.com/PaulStoffregen/te...FFS-FLASH-ONLY

    The SPIFFS_t4 library will allow you to add a file system for the flash. Of course you can still address the flash directly. The flashtest6.ino example demonstrates both options, i.e., to use a file SPIFFS or directly address the FLASH.

    extRAM_t4 library is a helper library for PSRAM.

    Both libraries have several examples.

  4. #4
    Junior Member
    Join Date
    Sep 2018
    Posts
    13
    Quote Originally Posted by KurtE View Post
    You can simply just address the memory....

    There is a new memory designation (EXTMEM) you can specify as part of a define that puts it in this range.

    Code:
    	ERAM (rwx):  ORIGIN = 0x70000000, LENGTH = 16384K
    Thanks for the quick response.

    I think you are referring to the psram (which works without problems and shows 8M). The question was about the flash on the right (the winbond chip).

  5. #5
    Junior Member
    Join Date
    Sep 2018
    Posts
    13
    Quote Originally Posted by mjs513 View Post
    You can take a look at these two libraries: https://github.com/PaulStoffregen/te...FFS-FLASH-ONLY

    The SPIFFS_t4 library will allow you to add a file system for the flash. Of course you can still address the flash directly. The flashtest6.ino example demonstrates both options, i.e., to use a file SPIFFS or directly address the FLASH.

    extRAM_t4 library is a helper library for PSRAM.

    Both libraries have several examples.
    Thanks a lot, this looks just about right. I will clone it from git and have a try.

  6. #6
    Junior Member
    Join Date
    Sep 2018
    Posts
    13
    Quote Originally Posted by mjs513 View Post
    You can take a look at these two libraries: https://github.com/PaulStoffregen/te...FFS-FLASH-ONLY

    Both libraries have several examples.
    Thanks again, this library nailed it, both chips working now!

  7. #7
    Junior Member
    Join Date
    Aug 2020
    Posts
    18
    I have this same problem with the flash memory (25Q128JVSQ) and I already opened a specific topic about it but I didn't get an reply yet.

    https://forum.pjrc.com/threads/62710...ts-not-working

    Right now, I have tried the libraries recommended by @mjs513,

    https://github.com/PaulStoffregen/te...FFS-FLASH-ONLY

    and the example sketch, flashtest6.ino and, to begin with, there are many warnings (which I guess it means that may be something wrong),

    Code:
    flashtest6: In function 'void loopTest2()':
    flashtest6:112: warning: unused variable 'szLen' 
       int szLen;
           ^
    
    flashtest6:113: warning: unused variable 'xData2' 
       char xData[12048], xData1[12048], xData2[26];
                                         ^
    
    flashtest6: In function 'void loopTest()':
    ./SPIFFS_t4/examples/flashtest6/flashtest6.ino:161:49: warning: format '%c' expects argument of type 'int', but argument 4 has type 'const char*' [-Wformat=]
    
       sprintf(erName, "%s%c", "F_" ,__TIME__, fIdx++);
                                                     ^
    
    flashtest6:161: warning: too many arguments for format 
    ./SPIFFS_t4/examples/flashtest6/flashtest6.ino:161:49: warning: format '%c' expects argument of type 'int', but argument 4 has type 'const char*' [-Wformat=]
    
    flashtest6:161: warning: too many arguments for format 
    Sketch uses 57776 bytes (0%) of program storage space. Maximum is 8126464 bytes.
    Global variables use 82612 bytes (15%) of dynamic memory, leaving 441676 bytes for local variables. Maximum is 524288 bytes.
    anyway this test compiled and uploaded to my Teensy 4.1 but both the flash erasing process and the flash memory test itself, runs indefinitely and never end.

    Code:
    flashtest6.ino
    PSRAM: 8 MB
    Enter 'y' in 6 seconds to format FlashChip - other to skip
    Erasing... (may take some time)
    ......................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
    Code:
    flashtest6.ino
    PSRAM: 8 MB
    
     Enter 'y' in 6 seconds to format FlashChip - other to skip
    
    Mount SPIFFS:
    Mount ADDR 0x800000 with res: 0
    Write file:
    Hello World! What a wonderful World :)
    Click image for larger version. 

Name:	Teensy 4.1 PSRAM & Flash memory (0001).jpg 
Views:	8 
Size:	168.2 KB 
ID:	21588Click image for larger version. 

Name:	Teensy 4.1 PSRAM & Flash memory (0002).jpg 
Views:	13 
Size:	135.4 KB 
ID:	21589
    Last edited by edamas; 09-02-2020 at 07:03 AM.

  8. #8
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    5,585
    @edamas
    This is a duplicate of https://forum.pjrc.com/threads/62605...-on-teensy-4-1 and was answered in that thread so going to close this thread.

Posting Permissions

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