psram with qspi flash on teensy 4.1

Status
Not open for further replies.

scjurgen

Member
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 :eek:

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

Cheers
scjurgen

IMG_6205.jpg
 
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.
 
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).
 
You can take a look at these two libraries: https://github.com/PaulStoffregen/teensy41_extram/tree/SPIFFS-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.
 
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/6271...ond-25Q128JVSQ-Flash-memory-tests-not-working

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

https://github.com/PaulStoffregen/teensy41_extram/tree/SPIFFS-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 :)

Teensy 4.1 PSRAM & Flash memory (0001).jpgTeensy 4.1 PSRAM & Flash memory (0002).jpg
 
Last edited:
Status
Not open for further replies.
Back
Top