Does anyone have/know of a script that could be used to test the data writing speed of an Teensy 4.1 to External Ram, SD, or flash.

thedarthrevan

New member
I am working on a project and we want to get an idea of the potential data rates that we would when writing to one of the listed memories above. If anyone has a script that can test or know of a post that has done that please replay. If you need more info I can try my best to supply it but even I am a little uniformed on the technical stuff haha. Thanks in advance!
 
A bit of searching in the Teensy forums should yield some sample sketches. I know I've posted several over the last few years.

Note that , until very recently,"External RAM" meant the QSPI external Pseudo-Static RAM, which maxes out at about 30 to 40 MB/second. I've never tried writing to the program FLASH. SD Cards can be written at up to 20MB/second but need buffering to cover occasional long write times due to internal factors such as block erase or load-leveling block substitutions. If any of the preceding terms are new to you, several hours of research loom in your immediate future!
 
There are so many different use cases that I think you are going to have to carefully select what you want measured and likely do it yourself. The different segments of RAM have different speeds, RAM1 vs RAM2, ITCM vs DTCM.

Most people are using littleFS with EXTMEM, that's not necessary and results would be wildly different if that overhead were not imposed, I think. The SD card reader on the T4.1 is QSPI whereas the SD card reader on the audio shield is SPI. SD cards themselves have different speed ratings. If you have an EXFAT SD card, there is a syntax that looks much faster--file.read(buffer,length). File fragmentation on an SD card would drastically alter results...

One time I tried to measure copying something out of FLASH into EXTMEM and it seemed much slower than I expected. I switched to doing something else and didn't carefully explore it. The way FASTRUN code is copied from FLASH to RAM tends to confirm the idea that FLASH is slow...

And consider that you're measuring copying FROM somewhere TO somewhere. https://www.calculatorsoup.com/calculators/discretemathematics/combinations.php
 
You asked for potential data rates. That sort of info is only really useful if you're try to optimize an application, so you know whether you're getting close to the best case scenario. The reality of most practical applications achieve only a fraction of the best case speed. This is true with most computing, not just Teensy.

A far more important question to ask is what sort of performance obstacles typically come up with each type of media and whether you can deal with those in your application. As @mborgerson mentioned, we hear this often with SD cards where fairly high write speeds are possible, but occasionally the card will become busy for lengthy times. If your application needs to continuously stream data, whether you can continue collecting data and buffer it in RAM during those times becomes quite important.

Flash memory chips have much more predictable timing. But they're not very fast to write (about 0.5 to 1 Mbyte/sec), and even slower to erase. Also if you use the leftover space in the main flash memory on Teensy 4.x, the rest of your program can't run while it is writing or erasing. You can avoid this limit by soldering a flash chip to the bottom of Teensy 4.1.

So the honest answer is "it depends". In practice, the performance you could hope to achieve is much more a function of your application (and your skill) giving you the ability to work within the bounds of the limits of how these memories really work.
 
The combinatorial calculation underestimates the size of the problem. It doesn't count RAM2-->RAM2 and doesn't take into account that RAM2-->EXTMEM and EXTMEM-->RAM2 are different because write speed != read speed.
 
Back
Top