The Rio Karma is a 20GB portable digital music player that supports MP3, OGG, and FLAC playback, among others. The device can be used under Linux over ethernet using the dock; however this transport is rather slow and requires possession of the dock. This page documents efforts to produce a mass storage class driver for the Karma under Linux.
Note: the drivers available here are now in the vanilla Linux kernel.
Visit the sourceforge project
for more Karma software on Linux.
The OMFS filesystem driver is in mainline as of Linux version 2.6.27 and
the USB drivers were merged in version 2.6.16. If you have a kernel
2.6.27 or later, you don't need anything from here.
Previous OMFS releases are available here.
# modprobe usb-storage # dmesg (watch for the disk id, e.g. "sda1 sda2")
# mount -t omfs /dev/sda1 /mnt/karma0 # mount -t omfs /dev/sda2 /mnt/karma1
The Rio Karma operates as a USB mass storage device, but requires some initialization to enter mass storage mode. Traces of USB traffic from Windows reveals that the device is sent a 40 byte command packet and replies with a 512 byte response. Each request includes a command number, along with a sequence number that is used in subsequent requests and returned by the player when the command completes.
'R' 'I' 'O' 'P' 00 XX YY 00 ...
Where XX is the command number and YY is the sequence number.
F0 00 00 00 00 ...
Until an ack is received, the client sends:
'R' 'I' 'O' 'P' 80 00 YY 00 ...
...until the Karma replies:
F0 00 00 00 00 YY 00 ...
The following commands have been observed:
command (XX) | description |
---|---|
00 | ? |
01 | Enter storage mode |
02 | Leave storage mode ("press riostick to continue") |
03 | Reload firmware (from recovery mode) |
04 | ? |
05 | Display basic karma info (sample output) |
07 | Set the time. Payload contains a zero followed by a time_t (UTC) as LE32 |
08 | Display sensor information (sample output) |
0B | Reboot karma |
0C | Return to normal operation (after leave storage mode) |
0D | Display disk information (sample output) |
The filesystem consists of fixed-size blocks, with sector 0 containing the partition table. The partition table layout is the same as that of a DOS MBR but it appears earlier in the record (0x10e) and has unnecessary fields zeroed out. My table looks like this:
00 00 00 00 4d 00 00 00 02 80 00 00 00 00 02 00 00 00 00 00 4d 00 00 00 02 80 02 00 5d a9 51 02
Byte 4 (0x4d) is the FS type, bytes 8-11 are the sector offset of the partition (little-endian), and 12-15 are the size of the partition (in sectors).
Block 0 has a magic number of 0x56AB instead of the usual 0x55AA.
After much inspection with a hex editor and some serendipitous googling, I have discovered that the Karma uses the same filesystem as ReplayTV, which has been well-documented over here. The Karma uses 8k blocks.
In addition I have discovered that the FS uses hashing on the filename to locate nodes. The hash function is:
h_i = h_(i-1) xor s_i << (i mod 24)
h
is the hash, s
is the string, and the result is modulo the number of buckets. There are 201 buckets in the Rio implementation, although this likely depends on the cluster size (201 * 8 + dirent offset 0x1b8 = 2k = sys_blocksize).
Unlike the ReplayTV, the Karma has a pointer in its superblock to a free space bitmap stored on disk. This bitmap has a bit for each block -- cleared for free blocks -- for a total of around 300k for 20 gigs.
Other things we know about the filesystem, specifically with regards to the Karma: