any tips really appreciated
Re:File transfer speed
2.5 M bytes per sec is a very high data rate for SPI transfer to SD card.
See
http://elm-chan.org/docs/mmc/mmc_e.html
We can overclock the SPI to 36MHz but I dont know if any SD cards go that fast.
I suspct you would need to use SDIO, but that feature is not available on the STM32F103C8 and we dont have a SDIO library for the libmaple core.
I am sure a F4 series MCU could process that much data from SDIO, but as there currently isn’t an SDIO library, You should probably try to get hold of a Raspberry Pi Zero or another high speed unix board e.g. Orange Pi
About your tests with a Teensy 3.1, which performance did you achieved ?
Something like these.
@ RogerClark , POV is the vision come with rotation of one line of LED to product the whole image , I did it with teensy3.1 connected to SD card which is simply read image, line by line and put in LED strip , to get benefits of ESP feature , I’ve tried to use SPIFF for hosting the image files and webserver feature to upload the images , however after couple of tried and many discuss in ESP gitter room , noticed the ESP not fast enough to read the image and beside file fragmentation hold the speed back to optimum
in best try I reach around 60ms for each frame , for 25 frame/s I should deliver 144 LED pixel * 3 byte RGB data * 200 line of image = about 85Kbyte for each frame and about 2 Mbyte/s
I thought with STMF103 DMA feature can reach such performance whereas it is connected to ESP module as slave module , I’m not yet decide to test it but some guys told me may ESP32 with two extra separated core with free DMA feature could handle it
if you guys have any experience for SD card fast reading by STMF103 I’ve really appreciated to have your hints
@ RogerClark , POV is the vision come with rotation of one line of LED to product the whole image , I did it with teensy3.1 connected to SD card which is simply read image, line by line and put in LED strip , to get benefits of ESP feature , I’ve tried to use SPIFF for hosting the image files and webserver feature to upload the images , however after couple of tried and many discuss in ESP gitter room , noticed the ESP not fast enough to read the image and beside file fragmentation hold the speed back to optimum
in best try I reach around 60ms for each frame , for 25 frame/s I should deliver 144 LED pixel * 3 byte RGB data * 200 line of image = about 85Kbyte for each frame and about 2 Mbyte/s
I thought with STMF103 DMA feature can reach such performance whereas it is connected to ESP module as slave module , I’m not yet decide to test it but some guys told me may ESP32 with two extra separated core with free DMA feature could handle it
if you guys have any experience for SD card fast reading by STMF103 I’ve really appreciated to have your hints
I’ve recently been encountering similar requirements with streaming small soundsamples i wanted to play on my maple mini, and to be honest, i never even bothered with SD cards… The current dma implementation is fast, but blocking, you can try altering that, but if you look at the code, the SD card filesystem overhead is HUGE (also the inconsistency of how & when it responds due to internal management doesn’t bode well either).
I don’t know how much data you need, but i ended up just buying some spi flash chips (the biggest ones i have are 1Gb (=128MByte)), and it’s sooo much easier working with them. A simple protocol to read data from them, i made a custom “filesystem” (the first 1k of the flash chip contains metadata & addresses of what is stored where, and i keep it into memory). And then i was able to quickly write a simple framework that allows me to stream many channels of wav audio data from the flash chip at the full speed of the SPI port, and nicely in the background with DMA
So unless you realy need gigabytes of data, you should really consider the flash chip option. The only usage of an SD card in my project was to load the data into the flash chip XD.
I’ve recently been encountering similar requirements with streaming small soundsamples i wanted to play on my maple mini, and to be honest, i never even bothered with SD cards… The current dma implementation is fast, but blocking, you can try altering that, but if you look at the code, the SD card filesystem overhead is HUGE (also the inconsistency of how & when it responds due to internal management doesn’t bode well either).
I don’t know how much data you need, but i ended up just buying some spi flash chips (the biggest ones i have are 1Gb (=128MByte)), and it’s sooo much easier working with them. A simple protocol to read data from them, i made a custom “filesystem” (the first 1k of the flash chip contains metadata & addresses of what is stored where, and i keep it into memory). And then i was able to quickly write a simple framework that allows me to stream many channels of wav audio data from the flash chip at the full speed of the SPI port, and nicely in the background with DMA
So unless you realy need gigabytes of data, you should really consider the flash chip option. The only usage of an SD card in my project was to load the data into the flash chip XD.
I don’t know much about the ESP capabilities. But for the stm32: the SPI port can at max do 32Mhz, that’s 32 MegaBIT/s, so 4Megabyte per second. No software implementation will come close to that. And you can look into the SDFAT thread about benchmarks of sd cards on the maple mini, i think they barely surpassed 1Megabyte/s…. if you want 2.5 megabyte/s speed, i’d suggest going for a flashchip and an stm32 handling the data & controlling the leds. you’ll need something with either a hardware port, or a much higher cpu speed than the esp/stm32 to get such datarates, and sd cards addressed via spi won’t get it either….
I don’t know much about the ESP capabilities. But for the stm32: the SPI port can at max do 32Mhz, that’s 32 MegaBIT/s, so 4Megabyte per second. No software implementation will come close to that. And you can look into the SDFAT thread about benchmarks of sd cards on the maple mini, i think they barely surpassed 1Megabyte/s…. if you want 2.5 megabyte/s speed, i’d suggest going for a flashchip and an stm32 handling the data & controlling the leds. you’ll need something with either a hardware port, or a much higher cpu speed than the esp/stm32 to get such datarates, and sd cards addressed via spi won’t get it either….
There are many flash chips you can find on sites like aliexpress, all with similar protocols & features
There are many flash chips you can find on sites like aliexpress, all with similar protocols & features
I’ve never done that with SDCard yet, but should be doable. The thing I’ve done which is a bit similar is reading an SPIFlash on STM32 using readBytes()
the ESP doesn’t have a hardware spi port, so you indeed won’t be able to get high datarates from it…
So your best bet is to use an stm32 as slave to do the heavy lifting for you
why the esp btw? can you wirelessly send it new pictures?
To verify that, we need to write some kind of benchmark, then, if results are good, hookup your WS2801 RGB LED strip.
I’ve never done that with SDCard yet, but should be doable. The thing I’ve done which is a bit similar is reading an SPIFlash on STM32 using readBytes()
To verify that, we need to write some kind of benchmark, then, if results are good, hookup your WS2801 RGB LED strip.
char mem[1024];
uint32_t flashStartAddress = (uint32_t)&_SPIFFS_start - 0x40200000;
uint32_t begin = millis();
uint32_t elapsed = 0;
p.println("Flash Mem Perf Test :");
for (int i = 0; i < 1024; i++) {
ESP.flashRead(flashStartAddress, (uint32_t *)&mem, sizeof(mem) / sizeof(uint32_t));
flashStartAddress += sizeof(mem) / sizeof(uint32_t);
}
elapsed = millis() - begin;
p.printf("\nelapsed time = %u \r\n", elapsed);
p.printf("throughput = %u bytes/sec \r\n", 1024 * 1024 * 1000 / elapsed);
char mem[1024];
uint32_t flashStartAddress = (uint32_t)&_SPIFFS_start - 0x40200000;
uint32_t begin = millis();
uint32_t elapsed = 0;
p.println("Flash Mem Perf Test :");
for (int i = 0; i < 1024; i++) {
ESP.flashRead(flashStartAddress, (uint32_t *)&mem, sizeof(mem) / sizeof(uint32_t));
flashStartAddress += sizeof(mem) / sizeof(uint32_t);
}
elapsed = millis() - begin;
p.printf("\nelapsed time = %u \r\n", elapsed);
p.printf("throughput = %u bytes/sec \r\n", 1024 * 1024 * 1000 / elapsed);
extern "C" uint32_t _SPIFFS_start;
Thanks
I can try to extract piece of code to debug, but I’m not sure which one : is it the raw reads pushed to LEDs or the copy from SPIFFS to raw writes ?
For the exceptions you still see, did you use the ExceptionDecoder to get meaningful stack trace ?
I can try to extract piece of code to debug, but I’m not sure which one : is it the raw reads pushed to LEDs or the copy from SPIFFS to raw writes ?
For the exceptions you still see, did you use the ExceptionDecoder to get meaningful stack trace ?
Is it a memcpy() that you are doing with a raw Flash address ?
If Yes, then I can tell you that this is not allowed, you need to memcpy_P() instead.
Is it a memcpy() that you are doing with a raw Flash address ?
If Yes, then I can tell you that this is not allowed, you need to memcpy_P() instead.
ESP.flashRead(_index,(uint32_t *)& LED_BUFFER, sizeof(LED_BUFFER)); 

