Executing Gummiworms The trials and tribulations of a grumpy curmudgeonly old git

26Feb/129

Tips for preparing an SD card for the raspberry pi on windows

The Raspberry Pi will probably be available to buy in the store sometime within the next ten days and one of  the operating system sd card images is already available (debian) with another to follow in a day or so (fedora) so it's time to start thinking about making an sd card for use with the raspberry pi.

If your main machine is a linux system then you should have no problem, a standard dd will be fine but under windows not only do we not have a dd program (we do but it's not a pleasant experience and windows users are not command line junkies on the whole so use something like Win32DiskImager or equivalent) but there are a couple of gotchas that might catch the unaware out.

The main gotcha is that although your computer has a builtin sd card reader/writer and it works with your cellphone or camera sd card perfectly well it might not work for creating a bootable sd. The biggest problem builtin sd card reader/writer is the ricoh one in HP laptops although other makes of sd card hardware and laptops also have this problem. When you use a builtin reader/writer and it is goingto fail it doesn't always tell you that it's failed so the first thing you now something is wrong is that your raspberry pi (or other target device) won't boot So although you have a builtin sd card reader/writer it is a good idea to get hold of a USB SD card reader/writer and use that for making your bootable SD card. [I have no real idea why builtin reader/writers have problems making bootable sd cards but my thinking is that the controller in the builtin ones was cut down for windows machines to save a few pennies as noone thought that they'd want to write to the 0 to xxxx areas of the SD card]

The other gotcha you should be aware of is that SD cards are formatted and written to in a slightly "weird" way. An unformatted/blank SD card is actually full of 1's and when you write to it it just flips the appropriate bits to 0. An sd card can read at the bit level but only writes at a block level so you'll end up with areas that can't be used for writing any more as they need to reverse a bit back from a 1 to a 0 to perform the write and deleting/erasing the file won't actually free up all that space as it spans several blocks. So if you are going to use an SD card that you have used before you'll want to format it before using it with the raspberry pi. Don't use the windows formatter with your SD card as although it'll sort of work it won't have set all the bits to 1 instead user the panasonic sd card formatter which you can find at http://panasonic.jp/support/global/cs/sd/download/index.html [I can never remember which way around it is for when an sd card is in an unused state, whether it's all 0's or all 1's but i'm leaning towards all 1's as that is what has seemed to have stuck in my head].

 

To quickly summarize if making a bootable sd card on windows.

  1. Use a USB SD Card reader/writer
  2. Use the panasonic sd card formatter
  3. There is a windows version of dd but use Win32DiskImager or equivalent instead
Share
Comments (9) Trackbacks (1)
  1. too many 1′s and 0′s i reversed a couple but the general idea still holds

  2. Hello,
    I was planning to use 4Gb MicroSD cards in a MicroSD to SD card adapter, creating the bootable image using a MicroSD to USB adapter. Do you think it’ll work?

    • i’ve used adapters and micro/mini sd cards on other ARM devices running linux and it should be ok. sometimes you get a flakey adapter but on the whole it works fine although YMMV

  3. I’m soooo new to all this. What is a “standard dd” – data driver? digital drive?
    Sorry.

  4. You said:
    <>

    That’s rather confused and muddled up.

    Inside an SD card the flash memory will be in blocks, I think they’re often 32K bit I could well be wrong.
    The blocks start as, say, all 1s and the bytes can individually have some bits programmed to 0s. However to get even a single bit back to 1 you need to do an erase operation on the block which puts all bits in that block back to 1.

    However all that is hidden from the user and does nothing except slow things down. You don’t need to reformat or erase or anything to get the full capacity of the card.

    There can however also be interactions between the allocation block size and alignment with the blocks of flash memory which can slow SD cards (and USB pen drives) down if you reformat them in a different way from their original format. The SD formatter programmer is probably a pretty good bet as a way of ensuring you re-format SD cards in a way that ensure good performance.

    The TRIM function you hear about with SSDs is about making sure all blocks (or parts of blocks if the blocks are large) that are not being used to hold data are pre-erased ready to be used. It speeds things up by minimizing the number of on the fly erase and rewrites you need to do as more data is written to the drive.

    • i’m going from several years of empirical research (and killing many sd cards are various makes and sizes, turning them into cellphone fodder). Using an sd card (partitioning, unpartitioning, adding, erasing data….). will leave a card in a weird state and using any other method (on windows) to completely wipe/reformate an sd card other than using the sd card formatter can (and will) leave the card in an unknown state with areas potentially blocked out. While YMMV i’ve found the safest and most consistant way to prepare sd cards on windows (especially if they have been used for something else previously) is to use a usb reader/writer & use the sd card formatter.

  5. I’m not really arguing withany of that. It just seems like you didn’t completely understand what was happening.

    Certainly some very weird and confusing things happen with you take partitioned SD cards from phones and read them on a Windows PC and a proper SD formatter is pretty much the only way to get things back to a known state.

    • I’m very well aware of what is happening. I might not have been very clear in the post as I was typing it up quickly but the three important points are there. 1. use a usb reader/writer & 2. use the sd card formatter 3. sd cards are not like magnetic media so don’t use them the same way


Leave a comment