I would like to share my first experience using PSRAM (SPI RAM) on the Teensy 4.0.
Few weeks ago I decided to port one more emulator core to my MCUME project.
https://github.com/Jean-MarcHarvengt/MCUME
The core is TGEmu, a PC engine emulator written by Charles MacDonalds.
It is a challenging emulator wrt RAM requirement.
In addition to the 128k ILI9341 frame buffer, the core has about 200k of local variables + 128k of background cache + 512k of sprites object cache. Finally ROMS loaded into RAM are between 256kb and 1MB!
There was clearly not enough memory in the T4 for it but I had ordered few IPS6404 PSRAM devices some time ago, so I had an opportunity to try them.
I connected the PSRAM to SPI2 (SPI mode, not QUAD SPI)
That means that I could forget the 'build in' SD card for my disk I/O.
The ILI 9341 is connected on SPI0.
I use one MQS channel for Audio (pin 10).
My plan was to use the PSRAM for storing the game rom image. Using the PSRAM mostly in reading mode.
The rest I could almost store in the RAM of the teensy.
The game image is loaded to the PSRAM at startup. Initially it was read from USB storage but I had some hang up when reading the image from USB to PSRAM (not clear why). Another problem is that the uFS + USB library are using almost 70k of RAM.
So I decided to go back to the good old SD library and connect the SD port of the ILI display on SPI0, together with the display (using another CS of course)
As the image is copied at startup from SD to PSRAM, SPI0 can be used exclusively in DMA mode for the display later on.
For the PSRAM driver, I used a cache of 16 pages of 16/32 bytes in RAM. depending of the game, the emulated CPU accesses and jumps at few locations.
Bigger page size results is freezing the game continuously.
CPU usage in TGEmu is also extensive. I had to compile the code for fastest and overclock the T4 to 800Mhz.
You can see the result in this video
https://youtu.be/Ot9RgDMqdF4
I said that I could almost fit all RAM buffers (except the game image) into the T4 memory.
In fact I had to cheat for the 512k RAM objects buffer which results in buggy display in some games. To go around I really would need the all heap (malloc area) to be available for the emulator.
Few weeks ago I decided to port one more emulator core to my MCUME project.
https://github.com/Jean-MarcHarvengt/MCUME
The core is TGEmu, a PC engine emulator written by Charles MacDonalds.
It is a challenging emulator wrt RAM requirement.
In addition to the 128k ILI9341 frame buffer, the core has about 200k of local variables + 128k of background cache + 512k of sprites object cache. Finally ROMS loaded into RAM are between 256kb and 1MB!
There was clearly not enough memory in the T4 for it but I had ordered few IPS6404 PSRAM devices some time ago, so I had an opportunity to try them.
I connected the PSRAM to SPI2 (SPI mode, not QUAD SPI)
That means that I could forget the 'build in' SD card for my disk I/O.
The ILI 9341 is connected on SPI0.
I use one MQS channel for Audio (pin 10).
My plan was to use the PSRAM for storing the game rom image. Using the PSRAM mostly in reading mode.
The rest I could almost store in the RAM of the teensy.
The game image is loaded to the PSRAM at startup. Initially it was read from USB storage but I had some hang up when reading the image from USB to PSRAM (not clear why). Another problem is that the uFS + USB library are using almost 70k of RAM.
So I decided to go back to the good old SD library and connect the SD port of the ILI display on SPI0, together with the display (using another CS of course)
As the image is copied at startup from SD to PSRAM, SPI0 can be used exclusively in DMA mode for the display later on.
For the PSRAM driver, I used a cache of 16 pages of 16/32 bytes in RAM. depending of the game, the emulated CPU accesses and jumps at few locations.
Bigger page size results is freezing the game continuously.
CPU usage in TGEmu is also extensive. I had to compile the code for fastest and overclock the T4 to 800Mhz.
You can see the result in this video
https://youtu.be/Ot9RgDMqdF4
I said that I could almost fit all RAM buffers (except the game image) into the T4 memory.
In fact I had to cheat for the 512k RAM objects buffer which results in buggy display in some games. To go around I really would need the all heap (malloc area) to be available for the emulator.