Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Maximizing flash lifespan using sector-sized file writes; cap limits on USB and SD card storage

Solved!
Go to solution

I'm using the sbRIO-9636 with 512 MB non-volatile storage (Flash I presume?).  I'm not finding the sector size in the Spec Docs I've found, and Measurement & Automation Explorer doesn't display it either, and I can't find a RT Hardware Property for it either.  I've built a "RIO File Writer" utility to buffer text writes until the sector size is full or until the file is closed using the utility VI, but it would help to know the sector size.  For now, I'll assume 32 KB as I've read the 9606 uses 16 KB with its 256 MB drive.

 

I've attached the Utility (a single LV 2012 VI) in case anyone else would find it useful.  I won't promise it's the most performance or memory efficient, but its purpose was to spare the Flash from my app, which supports logging CAN data (1000+ packets/sec) to file, and it does that very well.  Had I continued logging CAN data without it, with each CAN packet written separately (~40 characters / log record, or ~820 writes per 32KB sector), I likely would have started losing sectors in the next few weeks were it not for wear-leveling - perhaps even with wear-leveling.  With this, the lifespan should no longer be an issue (though capacity remains one, I may switch to USB storage if it does).

 

Come to think of it, this may help with any data being quickly logged to any drive, as all drives use sectors (or blocks of sectors), assuming you can sacrifice the RAM requirements to save your hard drive system (or that you need to).

 

More storage questions:  What is the capacity limit of the SD card and USB based storage on the sbRIO-9636?  The spec mentions SDHC support but doesn't specifically say SDXC is not supported.  Does it support the monstrously huge SDXC cards or the max for SDHC (32 GB)?  Also, with SD and USB storage, is block size a consideration?  Does LabVIEW have a Property I can read for any of this that I'm not seeing?

 

Thanks!

 

Erik Ledding

Design Test Engineer

Sub-Zero, Inc.

0 Kudos
Message 1 of 9
(8,623 Views)

Hi Erik,

 

Understanding and Extending the Life of my Solid-State Drive suggests a minimum block size of 8 KB. If you keep your writes to exactly 8 KB, the wear-leveling should manage the life of your drive adequately.

 

I would also like to point you toward this post about wear-leveling on the sbRIO:

http://forums.ni.com/t5/Real-Time-Measurement-and/Maximum-Write-operation-on-sbRIO-9601-128-Mb-non-v...

 

The sbRIO 9636 does support SDHC, meaning it accepts SD cards up to 32 GB.

 

I am not sure about block size considerations for SD or USB flash memory. I would recommend contacting the SD card or USB drive manufacturer. I am not aware of a LabVIEW property that would address this.

 

Thanks for sharing your VI!

 

Joey S.
Senior Product Manager, Software
National Instruments
Message 2 of 9
(8,601 Views)

Thanks for the response!

 

"Spex" said the sector size of 128 MB and 256 MB flash storage on the 9601 used 16 KB sector sizes, so I'll assume 32 KB for the 512 MB drive in the 9636.  I may write half as often as I could, but I'll guarantee not to write more than I should.  I saw Spex's post before posting my question.

 

Thanks for confirming the full SDHC range works with the sbRIOs in the 960x/962x/963x series, and that SDXC does not.  I think 32 GB should be more than sufficient.

 

Any idea on the capacity limit of a USB flash drive?  the spec also says the sbRIO supports USB-to-IDE adapters - how about USB-to-SATA?  As it supports FAT16 or FAT32 formats, I'll assume it can handle the capacity limits of FAT32 (2 TB).

 

Thanks!

Erik

0 Kudos
Message 3 of 9
(8,594 Views)
Solution
Accepted by topic author ErikL68

Hi Erik,

 

I was wrong, we do have a LabVIEW function that will find the sector size for a specific drive, this is the Get Volume Info.vi (link). You can run this VI and reference the flash drive on the sbRIO to find the minimum sector size for writes.

 

In terms of external drives for the USB port, I think you are right in your assumption about the limits of FAT16 and FAT 32. Keep in mind there are also file size limits of 2 GB or 3 GB maximum file size.

Most USB-to-IDE adapters will work for the sbRIO (or cRIO), but USB-to-SATA is not supported to work on sbRIO. You can still try using a USB-to-SATA HDD, but it might not work.

Joey S.
Senior Product Manager, Software
National Instruments
Message 4 of 9
(8,582 Views)

j_Spin, that worked - the Sector Size output feeds nicely into my RIO File Reader utility too - not even a coercion dot (U32 into U32 Ring).

 

Also, you were right about the sector size - 8 KB - for my 9636.  I had another thought:  Does the sector size of a flash drive necesarily correspond to the write size of the flash memory?  Is there a "Logical" and "Physical" sector size, and are they the same for flash?  I'm going to assume that due to the recognition of the limitations of flash, that they are always the same unless someone uses non-default settings when formatting (which we don't have the option for with sbRIO or cRIO), if that's even an option as it is on hard drives.

 

Thanks!

Erik

0 Kudos
Message 5 of 9
(8,576 Views)

You're welcome Erik!

 

This is a little outside my expertise, but my understanding is that flash sector size is completely software defined. When a drive is formatted, sector size is software-configured, and this is the property that will be read by the Get Volume Info VI. For the sbRIO, this sector size is defined by the VxWorks OS. For a flash drive, you have the ability to set it to what you want. So, in answer to your question, on flash drives, there is no "physical" sector size that correlates closely to the "logical" sector size. When a drive is formatted, its physical memory blocks are mapped to correspond to the sector size defined by the reformat.

 

This how-to illustrates this point and gives some general recommendations for setting sector (allocation unit) size:

http://www.makeuseof.com/tag/format-usb-drive/

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 6 of 9
(8,569 Views)

Joey,

 

Looking closer at Wikipedia's fine article on Flash memory, it appears the only major concern is with NAND flash (as it must write a Page at a time, vs. NOR flash with is fully random write capable) or any flash writes where you wish to replace a 0 with a 1, as that requires erasing the entire "block" back to all 1s before the write can be performed, and the block size can be as large as 256 KB.  It's this block size that I was mistakenly calling a "physical sector" in the prior post.

 

Any idea on the block size on the flash memory used on the sbRIOs and cRIOs?  That would be more useful than the sector size (unless they're the same) as I'd hate to have the controller read in an entire 256KB block just to change a few bytes from 0 to 1 and write it back.  Also, do the RIOs use NOR or NAND flash?

 

Thanks!

Erik

0 Kudos
Message 7 of 9
(8,566 Views)

Hi Erik,

 

According to the manual, the sbRIO 9636 uses a NAND flash chip. For our purposes of trying to extend the life of the flash, the sector size output of the Get Volume Info function will be functionally equivalent to the physical block size.

Joey S.
Senior Product Manager, Software
National Instruments
0 Kudos
Message 8 of 9
(8,539 Views)

Hello Joey,

 

I'll run with the Get Volume Info VI then.  With it and my little file write utility VI, I should expect the flash on the sbRIO to easily last the life of the board.

 

Thanks,

Erik

0 Kudos
Message 9 of 9
(8,520 Views)