Contents

Block device

by Damian Yerrick

A block device is a computer data storage device that supports reading and (optionally) writing data in fixed-size blocks, sectors, or clusters. These blocks are generally 512 bytes or a multiple thereof in size. The term is often used in contrast with a '''word-addressed device''' which supports reading and writing data a word at a time, where a "word" is a much smaller block, usually 1 to 8 bytes in size.

Examples

Advantages of block devices

A block device generally requires fewer pins and can thus be placed in a smaller package than a word-addressed device. In addition, a block device interface to slower forms of memory, such as rotating media and NAND flash, is much easier to build than a word-addressed interface, and these slower forms of memory generally have a much larger capacity dollar-for-dollar than NOR flash. For example, a memory card for Game Boy Advance with 32 mebibytes of NOR flash costs about $60, but a CompactFlash memory card with 975 mebibytes of NAND flash costs $40, and a CD-RW disc that holds 700 mebibytes costs only $1.

Drawbacks of block devices

For some purposes, a block device based on a given solid-state memory is slower than a word-addressed device based on the same kind of memory because a read or write must start at the beginning of the block. Therefore, to read any part of the block, one must seek to the start of the block, read the whole block, and discard the other data if it will not be used. To write part of the block, one must seek to the start of the block, read the whole block into memory, change the data, seek to the start of the block again, and write the whole block back to the device. This is in addition to the typically longer seek times of storage technologies used on block devices. In addition, there must be at least one word-addressed nonvolatile memory in the system, even if only to copy the bootstrap code from a block device into RAM.

Simulating ROM using a block device

Because a CPU generally needs random access to individual bytes of program and data memory, a program stored on a block device needs to be copied to a word-addressed memory before it can be used. The N-Gage, GP32, and Nintendo DS systems, as well as all home computers and disc-based video game consoles, play games stored on block devices and have enough RAM to hold enough of a program in memory at once that loading rarely interrupts game play. Programs for those systems are designed to wait until the system finishes loading data before doing anything with the data, either by freezing game play briefly or by playing one part of a map while loading another.

But on a system expecting a large word-addressed read-only memory, such as a GBA, a Game Boy Color handheld video game system, or any of several other video game systems, an adapter for a block device needs to contain enough NOR flash or RAM to hold a program. Copying from a block device to RAM is quicker than copying it to NOR flash, but NOR flash generally uses less power than RAM and retains the last program copied to it even when the power is turned off.

Implementations in practice

The first device that could copy programs from a block device to RAM and then run them on a GBA was the GBACD, an ATA interface designed by Michal Lysek and Tobias Persson, two students from Halmstad University in Sweden. A program running on a microcontroller could read games from a hard drive or CD and run them. It was designed as a proof of concept, not as an all-in-one piracy solution, but the foundation was laid for Supercard, especially as CompactFlash is electrically identical to ATA.

The SuperCard and M3 adapters contain 32 MiB of RAM and a slot for a CF or SD card. They can play nearly all homebrew and pirated GBA games by copying them from the NAND memory to the faster memory and then handing control over to the GBA, though some do require patching so that savegames can be copied to the NAND memory. The EZ-Flash III and EFA II contain 32 MB of NOR flash memory used in a similar way, along with a much larger built-in NAND memory that can be rewritten but not swapped.

The GBA Movie Player, on the other hand, was not designed to run pirated GBA games. It has only a 512 KiB NOR memory that stores its firmware, which consists of code and data for menus and movie playing and reads data from CF. This lets it run only multiboot programs (which fit entirely into RAM) on the GBA, although some multiboot programs such as the built-in audio and video players and special versions of PocketNES and Goomba use an ATA driver to read and write from the CF card, swapping data in and out of RAM as needed. However, this swapping can sometimes create game play delays, especially with larger games in emulators such as PocketNES, as the original games were not designed to wait for loading.

See also

Didn't find what you wanted? Search for it:

Google
 
Web www.pineight.com

Legal

(Some Rights Reserved) Copyright 2005–2006 Damian Yerrick. The author grants permission to use this work subject to the terms of the Creative Commons Attribution License 2.5 or GNU Free Documentation License 1.2 or later without Cover Texts. This document was first published as "Block device" on PHWiki.