Silicon ChipSecure Digital Cards: Clearing Up The Confusion - July 2013 SILICON CHIP
  1. Outer Front Cover
  2. Contents
  3. Publisher's Letter: Nuclear power is the answer
  4. Feature: 100 Years Of AWA by Kevin Poulter
  5. Feature: Cheap & Cheerful Smart TV Conversion by Julian James
  6. Project: DIY Wireless Audio Streaming by Nicholas Vinen
  7. Project: Li'l Pulser Model Train Controller, Mk.2 by John Clarke
  8. Feature: Secure Digital Cards: Clearing Up The Confusion by Nicholas Vinen
  9. Project: Add A UHF Link To A Universal Remote Control by John Clarke
  10. Subscriptions
  11. Project: Build A USB Port Voltage Checker by Nicholas Vinen
  12. Vintage Radio: Restoring an AWA B15 AM broadcast receiver by Rodney Champness
  13. PartShop
  14. Market Centre
  15. Advertising Index
  16. Outer Back Cover

This is only a preview of the July 2013 issue of Silicon Chip.

You can view 19 of the 104 pages in the full issue, including the advertisments.

For full access, purchase the issue for $10.00 or subscribe for access to the latest issues.

Items relevant to "DIY Wireless Audio Streaming":
  • Software for DIY Wireless Audio Streaming (Free)
Items relevant to "Li'l Pulser Model Train Controller, Mk.2":
  • Li'l Pulser Mk2 Revised PCB [09107134] (AUD $15.00)
  • Li'l Pulser Mk2 front & rear panels [09107132/3] (PCB, AUD $20.00)
  • Li'l Pulser Mk2 Revised PCB pattern (PDF download) [09107134] (Free)
  • Li'l Pulser Mk2 panel artwork (PDF download) (Free)
  • Li'l Pulser Mk2 PCB pattern (PDF download) [09107131] (Free)
Articles in this series:
  • Li'l Pulser Model Train Controller, Mk.2 (July 2013)
  • Li'l Pulser Model Train Controller, Mk.2 (July 2013)
  • Li'l Pulser Mk2: Fixing The Switch-Off Lurch (January 2014)
  • Li'l Pulser Mk2: Fixing The Switch-Off Lurch (January 2014)
Items relevant to "Add A UHF Link To A Universal Remote Control":
  • Infrared to UHF Converter PCB [15107131] (AUD $5.00)
  • UHF to Infrared Converter PCB [15107132] (AUD $10.00)
  • Revised 10-Channel Remote Control Receiver PCB [15106133] (AUD $12.50)
  • PIC12F675-I/P programmed for the IR-to-UHF Converter [1510713A.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC12F675-I/P programmed for the UHF-to-IR Converter [1510713B.HEX] (Programmed Microcontroller, AUD $10.00)
  • PIC16F88-I/P programmed for the revised 10-Channel Remote Control Receiver [1510613B.HEX] (Programmed Microcontroller, AUD $15.00)
  • Firmware (ASM and HEX) files for the IR/UHF Link [1510713A/B.HEX] (Software, Free)
  • Firmware (ASM and HEX) files for the Revised Versatile 10-Channel Remote Control Receiver [1510613B.HEX] (Software, Free)
  • IR/UHF Link PCB patterns (PDF download) [15107131/2] (Free)
  • 10-Channel Remote Control Receiver revised PCB pattern (PDF download) [15106133] (Free)
  • Infrared/UHF Link lid panel artwork (PDF download) (Free)
Items relevant to "Build A USB Port Voltage Checker":
  • USB Port Checker PCB [24107131] (AUD $5.00)
  • USB Port Checker PCB pattern (PDF download) [24107131] (Free)

Purchase a printed copy of this issue for $10.00.

Secure Digital Cards – Clearing Up the Confusion Secure Digital cards and their smaller siblings, Mini and MicroSD cards have become the defacto standard for flash memory storage, winning out over competitors such as Compact Flash due to their smaller size, constantly increasing speed and capacity as well as widespread device support. But there are many different kinds of SD card and here we take a look at the differences between them and some of the technology behind them. T ake a look on the shelf of a store selling flash memory cards (or on the web page of an online retailer) and you will find many different kinds of SD cards: SD, SDHC and SDXC with a speed rating of Class 0, Class 2, Class 4, Class 6, Class 10, UHS-I (ultra high-speed) and so on. Each type is generally available in a variety of capacities and brands in both full-size, mini and micro format. MiniSD and MicroSD cards, by the way, can be be used in devices expecting full-size SD cards with the use of a passive adaptor. In many cases, this adaptor, which is exactly the same size as a standard SD card, comes with the Mini or MicroSD card. That’s a lot of different options – possibly hundreds. The various “classes” refer to the read/write speed that the card can manage and this is important if you are going to use it in a video camera or digital SLR still camera - especially with a video camera as a slow card will limit the video quality you can record at. Just how fast the card needs to be for a video camera depends on the shooting resolution (eg, 640x480, 1280x720 [720p] or 1920x1080 [1080p]), the 44  Silicon Chip A micro SD card, also known as a “Transflash” Card. frame rate and the video compression format being used. Some newer cameras can even record in resolutions above 1080p such as “2.7K” (eg, GoPro Hero 3 Black). The SD card being used for recording needs to be pretty fast to keep up. The main difference between SD, SDHC and SDXC is the maximum capacity that type of card can have, although higher transfer speeds are also restricted to the newer SDHC and SDXC formats. But some devices may not support all the latest types of SD card; generally this will mean the performance is restricted although in some cases, it may not work at all. Card classes Some SD cards indicate a speed in MB/s, or relative to CD speeds (eg, by Nicholas Vinen 600x = 90MB/s). But those ratings can be a bit “optimistic” so the SD Card Association came up with an official class rating system. If a card is “Class 0” or doesn’t indicate a class at all (and isn’t a UHS type) then that means the speed isn’t guaranteed. It isn’t very common to see such a device any more and this type of card would best be used in an application where speed is not critical, eg, data logging. Cards labelled class 2, 4, 6 or 10 (the logo being a number inside a big “C”) indicate the minimum sustained write speed, in megabytes per second, of the card in an unfragmented state. In addition, classes 2, 4 and 6 assert that the card’s write speed must degrade gracefully as the free space on the card becomes increasingly fragmented. This occurs as files are repeatedly written and deleted. Class 2 is reckoned to be fast enough for recording standard definition video while class 4 is required for HD video. Class 6 offers improved HD recording quality or higher frame rates. Class 10 is identical to class 6 except in the case where the recording is going to a completely empty area of the SD card (eg, after formatting the card), siliconchip.com.au where the minimum continuous write speed must be at least 10MB/s. Card labelled UHS-I or UHS-II use a faster interface with the host device/ computer and generally are indicated as either “speed grade 0” (<10MB/s) or “speed grade 1” (>10MB/s). This latter speed grade is indicated with a 1 inside a U and most UHS-I cards will manage at least 10MB/s. This is effectively the same as Class 10. Note that to achieve the rated performance, you must used a particular file system on the card, for reasons explained below. That means you shouldn’t reformat an SD card unless it is absolutely necessary, as the newly formatted file system may not be the correct one for best performance. If you must format it, there is a utility available from the SD Card Association (see link at end of article) which will do the job properly. Card types and file systems The latest type of SD card is called SDXC for eXtended Capacity which allows capacities up to 2048GB (2TB). The previous generation is SDHC for High Capacity which supports up to 32GB. There is some cross-over with 32GB cards available in both types. Besides the increased maximum capacity, there is relatively little difference between SDHC and SDXC cards. In fact they are similar enough that SDXC cards up to 128GB will work in some devices designed before SDXC came along. The main issue with backwards-compatibility is in the file system. All SDXC cards come formatted with exFAT which is a new version of the FAT file system (“file allocation table”), designed to support higher capacities. Unfortunately, this is not a licensefree format and it is currently proprietary to Microsoft although some third-party software allows access to exFAT from other operating systems such as Linux. This also means though that older versions of Windows (before Vista SP1) and MacOS will not be able to access the contents of SDXC cards. However, FAT32 actually works for capacities up to about 2TB. So for SDXC cards, you have the option to re-format them with FAT32 and they will then work in most devices, with the caveat that the maximum file size is then 4GB. siliconchip.com.au Other types of flash memory cards There have been several different types of flash memory cards developed over the years (years? They’ve only been around since the mid 1990s!) SD cards, which this article has concentrated on, might be the most popular but they are in fact a spin-off from the earlier MMC or multi-media card. It’s getting difficult to find MMC cards these days because of the popularity of SD cards. The two are often considered interchangeable but that’s not strictly true. SD cards are thicker than MMC (2.1mm vs 1.4mm) so MMC cards will usually fit into a dedicated SD reader; the reverse is usually not true. The file structure is also slightly different but the main difference between the two is that “secure” area (hence SD card) which was first developed for digital rights management in music, etc. Transflash is simply another name for microSD cards. Still fairly popular and relatively easy to get are Compact Flash cards, although they too have largely given way to SD cards. The main reason for this is size – CF cards (there are actually two, CFI and CFII) are significantly larger than even standard SD cards; the difference between CF and micro SD is quite dramatic. 32GB CF cards are common, 64GB are also available but not common. Expect to pay between $200 and $300 for a “brand name” 64GB CF Card; by contrast a “brand name” 64GB Class 10 SD card shouldn’t cost much more than $100 and we’ve seen them for as low as $40. But compare these to the latest Lexar 256GB C10 (600x speed) SDs which sell for close to $1000! Another card which was (briefly!) popular was the SmartMedia Card. As far as we can tell, the maximum size this card was ever made in was 128MB (yes, megabytes) and even in their day, were expensive. Similarly the MiniCard went the way of the dodo, despite being promoted as “the standard” back in the mid 90s. Its main claim to fame was that it used the PCMCIA (later PC) bus, though this did not lead to its longevity! Some manufacturers have tried to be clever by bringing out their own proprietary flash memory cards to lock others out of their systems. Companies such as Sony with their Memory Stick and Memory Stick Pro, and the Fuji/Olympus XD card, are two such examples. Once again, proprietary cards were usually more expensive (often significantly so) than their SD counterparts and the XD card, for example, was never available with more than 2GB capacity. While physically smaller than SD cards, XD cards are nevertheless larger than mini or micro SD. Newer models of Fuji/Olympus cameras support both XD and SD or, lately, SD only. Similar comments can be made for Sony’s Memory Stick and Memory Stick Pro – their latest cameras support both their stick and SD cards. And Sony has also released their own SD cards. However, Sony still supports the Memory Stick format, which is currently available up to 64GB and has a maximum theoretical size of 2TB (Memory Stick Pro). A 64GB model usually sells for around $100. This is by no means an exhaustive list of all types of flash memory cards. Wikipedia, for example, lists 25 different card types, although several of these have sunk without trace and others may not be available in this country. SD cards – in all their iterations – remain a pretty safe bet . . . at least until something newer and better comes along! July 2013  45 Maximum Power (W) (light blue: optional for SDXC cards) 0.5 1.0 1.5 2.0 2.5 0 All SD Cards default speed mode (3.3V) high speed mode (3.3V) 3 UHS-I (UHS50) SD Cards single data rate/12 (1.8V) single data rate/25 (1.8V) single data rate/50 (1.8V) double data rate/50 (1.8V) UHS-I (UHS104) SD Cards single data rate/104 (1.8V) UHS-II SD Cards full duplex/156 (1.8V) (optional) half duplex/312 (1.8V) 0 25 50 75 100 125 150 175 200 225 250 275 300 Transfer Speed (MB/s) Frequency (MHz) Fig.1: peak read/write speeds for SD cards in various modes. Each type of card should support the modes listed above it, ie, UHS104 cards also support the modes for UHS50 and regular SD cards. Transfer speed is shown in red (bottom scale) and clock frequency in blue (bottom scale) while maximum power consumption is in cyan (top scale). But there are a couple of problems with reformatting SD cards. Problem number one is that for some unknown reason, most versions of Windows refuse to format a volume larger than 32GB with the FAT32 file system – even though they will happily read and write such a volume. This can be solved by the use of a third-party formatting utility such as “guiformat”, which is a graphical version of “fat32format” (www.ridgecrop. demon.co.uk/guiformat.htm). The other problem is that reformatting an SD card with a different file system (or even different options) can seriously impact its performance. That’s because, for efficient writing of large files, the card controller needs to know which flash blocks are free and which are used. That’s so when writ- Actual size comparison between the original SD card, (top, 32 x 24mm), a MiniSD, (centre, 21.5 x 20mm) and a MicroSD, (bottom, 11 x 15mm). Card capacity has no bearing on dimensions. Only the standard SD card features a write/ erase lock (left side). 46  Silicon Chip ing a partial block, it knows whether or not it has to preserve the rest of the block, which takes extra time. Since all SDXC cards are designed for use with exFAT, when reformatted with FAT32 writing may be dramatically slower. Also, the “wear levelling” algorithm may not work as well, leading to a shortened life. We’ll explain that later. Protected area So what makes Secure Digital cards “secure” exactly? It’s the protected area, which we believe is hardly ever used any more. This allows data to be stored in an encrypted format and is supposed to be used to restrict access to copyright content on an SD card. The stated capacity of an SD card includes this protected area, which is why you can never quite fit as much on an SD card as you think you should. As SD card capacities have increased (and, we suspect, manufacturers have realised how few applications there are for this protected area), the proportion of the flash memory available for general storage has increased. For example, a 4GB Toshiba SDHC card has a 32MB protected area (0.8%) while their 8GB card has a 48MB protected area (0.6%). High-speed interfaces The UHS-I and UHS-II high-speed interfaces were introduced along with the new SDXC card format but support for them is optional. SDHC cards may optionally support UHS modes as well. The main difference between them is that UHS-I is physically compatible with the older SD card interface and offers somewhat higher speed operation while UHS-II introduces additional contacts on the card and so requires a new type of socket but offers higher speeds again. Before UHS-I, the fastest speed SD card interface available was “high speed” mode, giving a burst speed up to 25MB/s (see Fig.1). UHS-I introduces several new modes, all operating with 1.8V signalling. It is well known that lower voltage signalling allows higher transmission speeds, due to slew rate limitations such as parasitic capacitance and so on. So UHS-I doubles the maximum speed, to 50MB/s. This can be achieved either with a doubling of the clock, up to 100MHz, or else by sticking with the same 50MHz clock rate as before but transferring four bits of data on both the rising and falling edge of the clock signal, ie, double data rate (DDR). This is a common technique and has been in common use for PC RAM for over ten years now. In either case, the UHS-I card is allowed to draw up to 1.44W while active or nearly 500mA at 3.3V, twice what a regular high-speed SD card is allowed to draw (ie, 0.72W) and four times the maximum that a regular SD card normally draws in low-speed mode (0.36W). While signalling in the UHS-I modes occurs at 1.8V, the card still runs off 3.3V. It must step down this voltage internally and this provides one of While SD cards have dramatically increased in capacity over the years, they’ve shrunk in size – first to mini, as seen above, and more recently to micro (or Transflash). This has enabled backwards compatibility using adaptor as seen at right (in this case for MiniSD) Mini or Micro SD cards slide inside the adaptor and so can be used in devices with full-size SD card sockets. siliconchip.com.au Demonstrating just how little space is actually used inside the SD card, this 32GB Transcend model also houses a complete WiFi transceiver, which allows you to send your photos direct to you computer without the card ever leaving your camera. We reviewed the original “Eye-Fi” Connect X2 SD card back in the October 2010 issue – it was only a 4GB card and the storage (ie, SD) side has since failed with constant use. the limitations for UHS-I performance and is why UHS-II was devised at the same time. Even faster cards Faster UHS-I cards can optionally support UHS104 mode. In this mode, the card can draw even more power, up to 2.88W or nearly 1A. Maximum transfer rate is increased again, to 104MB/s by a further increase in the clock rate to a maximum of 208MHz. UHS104 mode does not support DDR. To operate correctly with such a high clock frequency, the SD card host must first interrogate the card for some “tuning” information which tells it about the timings for this specific card, possibly including calibration values programmed into the card at the factory to account for process variations and other factors. The host must then adjust its signal timing to match for reliable transfers. Despite all these new modes, UHS-I cards (and indeed UHS-II cards) generally remain backwards-compatible with older host devices. That’s because most of these new features must be activated by the host, once it has determined that the card supports them. When first powered up, these cards initially operate in the standard, lowspeed mode and the specification requires them to support all the older modes including the regular highspeed mode and so on. So to get the advantages of the new high speed modes, both the card and host device must support them. And of course, the flash in the card has to be fast enough, otherwise faster signalling doesn’t get you anything much. In fact, a UHS-I card is not necessarily any faster than a Class 10 siliconchip.com.au How much can you store on an SD Card? 2 GB 4 GB 8 GB 16 GB 32 GB 20m 30m 45m 40m 60m 60m 80m 120m 180m 160m 240m 360m 320m 480m 720m 770 1,540 3,080 6,160 12,320 Movies (minutes) (Hi-def movie recording MPEG-4; H.264) Fine mode (13Mbps/CBR) Normal mode (9Mbps/VBR) Economy mode (6Mbps/VBR) Photos (number) (10 Megapixels, 3648x2736, Fine mode) Music (hours and minutes) (ACC, MP3 HQ mode, 128Kbps) 34h 7m 68h 14m 136h 27m 272h 54m 545h 48m Typical capacities of various size SD cards for movies, photos and music. Actual capacities may vary, depending on file size and compression used. SD card or even a Class 6 card. Many newer devices such as digital cameras support UHS-I cards and there are quite a few such cards now available, some claiming transfer speeds of up to 90MB/s in ideal conditions. While not part of the official SD specifications, because UHS-I/Class 10 are so vague as to the actual performance of the card, some manufacturers still specify the peak speed in order to differentiate their products from slower competitors which may be in the same class. Yet more speed UHS-II adds eight new pads to the SD card: three grounds, a dedicated 1.8V supply and two pairs of differential signalling lines. Differential signalling is another common technique for increasing transfer speeds and is used by USB, Ethernet, PCI Express, HyperTransport and many other communication technologies. The two signalling “lanes” can be used either to send and receive data simultaneously (full duplex) or The number inside the “C” symbol (ringed in red here) shows the speed of the card – in this case, it’s a Class 10 which is suitable for use in video cameras and similar devices requiring a high speed data transfer. If there is no symbol shown (as in the card on the opposite page) no claim is made to its class (speed) and therefore it can be assumed to be the lowest speed. Such cards are cheap but they are really only suitable for non-demanding applications such as data logging. configured to operate in the same direction for faster reading or writing (half duplex). UHS-2 is similar to the commonly used LVDS (low voltage differential signalling) protocol but with an even lower voltage swing. The signal lines are operated as transmission lines to allow such a high speed and by sending one bit at a time, edge alignment of multiple signals due to different path lengths is no longer an issue. In UHS-II mode, the normal SD card power supply contact remains at 3.3V and a differential clock signal is applied to pads 7 and 8, which were previously used for data transmission. This clock operates at a fraction of the data transmission frequency, generally 25-50MHz, while the data signals can be up to 1.5Gbps. Obviously UHS-II operation is quite different from UHS-I but the cards will be backwards compatible. We aren’t aware of any UHS-II cards on the market just yet, nor any devices which can take advantage of them. Wear levelling Flash memory does not have an infinite life – there is a limit to how many times a block of flash can be written to before it becomes unreliable, ranging from as few as 100 up to millions of times. So most flash memory storage devices use some kind of “wear levelling”, which “spreads the load” of data storage to areas of the device which might otherwise remain unused. Consider an SD card used in a digital camera, where a few photos are taken each time the camera is used and those files are then moved off onto a computer. New files are normally placed at the beginning of the card. July 2013  47 What causes memory card failure? Memory card failure happens more often than we would like. We are referring to both data corruption and a complete loss of function (and thus data). The most obvious cause would be physical damage; SD cards are small enough that they can easily be dropped, stepped on, bent, split open and so on. There’s only one way to avoid that and that’s to handle with care! Incidentally, the SD card standard calls for them to be able to handle just a 3m drop. We’ve also heard that physical wear can be an issue, ie, if you insert and remove an SD card often enough, the contacts can wear out, both on the card and in the host device. You’d have to be doing an awful lot of insertions and removals to end up in that situation though. Ignoring physical damage, you have two classes of failure. The first is where the memory card itself works fine but files inexplicably vanish or in the worst case, the card isn’t even recognised as valid by the computer. This can happen if the card has been removed from a device while it is being written to, due to a bug in a device you have plugged it into or when it’s on the verge of failure from the flash memory reaching its end-of-life. If the card is still recognised but files are missing or otherwise corrupt, you can try using one of the various pieces of software which attempt to recover files from damaged cards. There are many free ones available, some of which works quite well and others which... don’t. The simplest type of recovery you can attempt is to simply check the device for file system errors and recover any “lost” files. This can often be done simply by running a “scandisk” tool on it, which is generally built into your operating system. So if data is simply stored in a block based on its storage address, that area of flash will be constantly written to while the rest may be left largely untouched. Even though there’s plenty of working memory remaining, if these first blocks are used again and again the card will quickly become useless. The primarily solution is to rearrange where data is stored in the flash memory and keep track of what is stored where using a mapping table which says where data was written to versus where it is actually stored. This way, the controller can perform subsequent writes to different flash blocks even if they are at the same storage address. So writes can be spread out evenly among the flash blocks and thus you get the maximum possible lifespan. In other words, this technique evens out how quickly the flash blocks wear out, hence “wear levelling”. But for this to work, the controller must know which blocks are free; it can only cycle through writing to unoccupied blocks of flash. So if the 48  Silicon Chip In Windows, this is accessed by right-clicking on the drive letter, going to the Properties dialog and then the Tools tab and clicking the “Check now” button. If you’re lucky, the missing files will be placed in the root directory or in a folder created for them. Their file names may be scrambled but hopefully the contents are OK. You could also try a program like CardRecovery/CardRescue or one of the other programs available on the ’net for this type of job. Some are free while others may have a trial version that will at least let you check that you can recover some files before forking out for the full version. Sometimes, the SD card controller or flash memory chip can fail entirely. The result is usually that the card is no longer detected as valid in any device. Windows Disk Management may not listed or if it is listed, shown it as “No Media” or containing no valid partitions. If there’s important data on it, your only choice then is to go to a recovery professional (look up “data recovery” in the Yellow Pages). This won’t be cheap but they should have specialised gear and thus are likely to be able to get some or all of your data back. If there isn’t any critical data on it, you’re better off binning and buying a new (and probably bigger and faster) card. Besides manufacturing faults, the most likely reason for the total electrical failure of a memory card is either a static discharge to its contacts or voltage spike from something you plugged it into. If you have more than one card fail, you may may have a faulty piece of gear which is damaging them; possibly the last thing you used that card in. card is nearly full or if a file system is used that the controller doesn’t understand then wear levelling is no longer effective. A related strategy used to extend flash life is to have more flash blocks than necessary for the stated capacity of the device (say 1% extra). Some blocks of flash in use may wear out much sooner than others and when that happens, these can simply be marked as bad and skipped over. As long as there are enough spare blocks left, there’s still enough space to store the full data capacity. It’s possible for the controller to determine when a block is going to Something you’d hope to never see: the inside of a typical SD card. The large “hynix” chip at the bottom is the actual flash memory (in this case 16Gbit); the smaller “blob” above it would be the controller. wear out when reading it based on how close the stored voltages are to the thresholds which determine whether a given bit is read as a zero or a one. If this voltage (which changes with use) is too close to the threshold then the block can no longer be considered reliable and can be disabled. Further details The SD card standard is rather complex; the simplified version runs to 186 pages and this covers only the electrical characteristics of the cards themselves. The host controller specification is separate, as is the description of the protected area and the various extensions to the standard such as SDIO (for WiFi and Bluetooth adaptors in the SD card format). Hopefully we’ve covered the more salient points here and given readers the knowledge required to work out which card to buy for a given application. For more information, refer to the SD Card Association website – and specifically the downloads page, at www.sdcard.org/downloads/pls/ SC siliconchip.com.au