Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Slow I/O to MicroSD

MicroSD Memory I/O Class 2

  • Please log in to reply
2 replies to this topic

#1 HABOT

HABOT

    New Member

  • Members
  • Pip
  • 5 posts

Posted 28 April 2014 - 08:09 PM

Hello,

 

I'm reading an array of sensor on a periodic basis (every 10 milliseconds) and making some pre-parsing on the data before posting data to another MCU. I try to take care of the almost 192KB of available RAM that NP2 supports but some times other background running processes just hang up when some memory limit is reached.

 

The operation I'm taking about is very memory consuming so I decided to implement a "memory swapping" strategy by creating a library that writes data to disk (MicroSD) based on file segments and data block layout. A worker thread reads the cursor on the swapping area and takes the data back when needed. Data cursor is administered by the library.

 

It works perfectly but It slowed down the core loop because writing to the MicroSD and then reading again at a high rate seems to be very expensive or just very slow. I tried to find a 2GB MicroSD with a higher speed Class than Class 2, but they don't exist.

 

I also tried by formatting the MicroSD with different FAT32 allocation blocks and it worked at maximum rate by allocating blocks of 4096 bytes (using one allocation block on many writings therefore avoiding continuos allocation).

 

 

I wonder if is there another strategy or way to perform I/O at a high rate on the microSD card avoiding this bottleneck?

 

thanks!



#2 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7767 posts
  • LocationNew York, NY

Posted 28 April 2014 - 08:32 PM

Hi HABOT,

The speed bottleneck may be the SPI bus itself, rather than the card's flash erase/write speed.

Are there any optimizations you can do to your memory swapping strategy, to reduce reads/writes? It sounds like you're pushing the SD card pretty hard...the second person I've seen use SD for memory paging in four years. Very clever :)

Welcome to the Netduino community,

Chris

#3 HABOT

HABOT

    New Member

  • Members
  • Pip
  • 5 posts

Posted 28 April 2014 - 09:05 PM

Hi Chris, and thanks for your quick response!
 
Okey, I understand that maybe the bottleneck is not about the card itself but the speed of the SPI bus between the PIC and the SD driver.
 
Well, now I'm getting the most of memory buffers so I reutilize them as much as I can. Sensor data is now posted directly through a socket port to the AI MCU array. Now it works really fast but I feel a little sad because the sensor data acquisition MCU seems to be a little "misused" and the paging library is now just for exception and low pace state logging. I have many Netduino Plus 2 as handy weapons and after a long time trying them I know how to use them I'd say, very well. I hope to see a really nice improvement on this to put that SD really hot =)
 
Thanks again!






Also tagged with one or more of these keywords: MicroSD, Memory, I/O, Class 2

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.