Blog

Extracting Data from Wii Fit Plus Savegame Files

January 27, 2010

One neat feature about Nintendo's Wii Fit and Wii Fit Plus is that it tracks your BMI (body mass index) and weight daily. You can view your progress of weight loss in a nice graph on your TV. I have been interested in extracting this data so that I can have it available elsewhere besides on the TV with the Wii on. Through some internet research and some examination of the Wii Fit Plus savegame files I have been able to access this data and get it on my computer.

Save Game to SD card

The first step is to create the savegame file from the Wii console. This can be done by going to the Wii Menu and saving the game data for Wii Fit Plus onto an SD card. This is a feature provided by the Wii in order to save a backup of your game data. Once that has been saved, you can insert the SD card into your card on your computer and access the file. But, it is an encrypted binary file, so we'll need to unpack and decrypt the filedata.

Install Segher's Wii.git

To extract the data files, you'll need to use Segher's Wii.git tools for Linux. Segher's Wii.git is a bunch of programs for Wii homebrew. The tool we'll need is called tachtig which will decode and unpack the savegame file for us. On Windows you can use FE100, but I have no experience with this tool.

On Linux, the easiest way to get the tool is to download the source code for Segher's Wii.git and compile it. On Ubuntu, all I had to do is the following:

1. Install git-core (if you don't already have it) - this is to get the code from the git repository.

$ sudo apt-get install git-core

2. Install openssl and libssl-dev - these two packages are required to compile the code, and you may not have them installed yet.

$ sudo apt-get install openssl libssl-dev

3. Grab the code from the repository

$ git clone git://git.infradead.org/users/segher/wii.git

This will create a folder called wii with the source code for the utilities.

4. Compile it

$ cd wii
$ make

This will compile the code and you will then have the executable 'tachtig', which is what we'll need to unpack and decrypt the Wii Fit savegame file.

To make it easier, you can copy the tachtig file to a location in your $PATH. (sudo cp tachtig /usr/local/bin)

The tachtig tool relies on some files that need to be created and added to a dotfile in your user's home directory. Create a directory called .wii in your home directory. You will need to add the following three files: sd-key, sd-iv and md5-blanker. The contents of each file should be 16 bytes in size and contain the respective keys found on this page. SD key (ab01b9d8e1622b08afbad84dbfc2a55d), SD IV (216712e6aa1f689f95c5a22324dc6a98) and the MD5 blanker (0e65378199be4517ab06ec22451a5793). You have to convert those hex strings into binary equivalent. I think I did this using xxd.

Unpack and Decode the Data

Okay, for Wii Fit Plus, the savegame file is stored on the SD card in the following location: private/wii/title/RFPE/data.bin

Grab that file off the SD card and copy it to your hard drive. Run tachtig on it to extract the file.

$ tachtig data.bin

You should get output similar to the following:

NG id: 028ab4e3
3 files
file: size=0003c000 perm=35 attr=00 type=01 name=FitPlus2.dat
file: size=00094000 perm=35 attr=00 type=01 name=FitPlus1.dat
file: size=00094000 perm=3f attr=00 type=01 name=FitPlus0.dat
ok: 1

It will create a directory named something like 0001000452465045, and put into it 6 files: 3 header files: ###banner###.ppm, ###icon###.ppm, ###title###, and 3 files with our Wii Fit data: FitPlus0.dat, FitPlus1.dat, FitPlus2.dat. FitPlus0.dat and FitPlus1.dat are both identical files with a size of 592K.

Parse and Interpret the Data

The next part is the fun part. If you examine the file with a hex editor you will be able to find the data you will want at the following locations:

File FitPlus0.dat
-----------------
Byte Offset | Length | Description
-----------------------------------
0x0 | 8 | RPHE0000 (header)
0x8 | 22 | Name of Mii
0x1E | 1 | Unknown
0x1F | 1 | Height (in cm)
0x20 | 4 | Date of birth (stored in BCD: e.g. 1980 0228)
0x24 | | Unknown
0x95 | | Dates with data (rowlen=10)
0x35CF | | Start of some other section (unknown)
0x38A1 | | Body Test measurement data section (rowlen=21)
+0 | 4 | Date (in bitfield format)
+4 | 2 | Weight (in kg * 10)
+6 | 2 | BMI (* 100)
+8 | 2 | Balance percent (* 10)
+10 | 2 | simple value 4 ??
+12 | 1 | extended 1 ??
+13 | 1 | extended 2 ??
+14 | 1 | extended 3 ??
+15 | 1 | extended 4 ??
+16 | 2 | extended 5 ??
+18 | 1 | extended 6 ??
+19 | 1 | extended 7 ??
0x9288 | 1 | Last byte of profile

From this table you should be able to see where to get the data from the file. Basically, the important stuff is at offset 0x38A1. This section consists of data rows each with a length of 21 bytes. Each row represents the data gathered when you take the Body Test daily in the game.

Here is the first row in my FitPlus0.dat file for example (at 0x38A1):

7D874C29 030B 0964 01F9 010F 01AC 2A 02 04 0015 00 00

The first 4 bytes is the datetime stored in a bitfield format. I got the format from this thread on stackoverflow: http://stackoverflow.com/questions/719129/datetime-hex-format. It is a basic bitfield representation of a date. This particular one (7D874C29) is 2008-08-09 16:41.

The next two bytes (030B) is the weight in kilograms * 10 stored as a 2 byte integer (big-endian). This value is 779, so that means 77.9 kg.

The next two bytes (0964) is the bmi * 100. So this value is 2404, or 24.04 bmi.

The next two bytes (01F9) is the balance percentage (when measuring your balance during the test). This value is 505. Divide by 10 to get the value 50.5%. I am not sure if this represents the percent of your body leaning to the left or the right.

The rest of the data I am not sure about, but I do know that the last nine bytes are only when you do the long test. (Half way throught the body test in the game it asks you if you want to end or continue). I know this because the numbers are always 0, except for the last byte.

This data is for the first profile in your game. If you have multiple Mii profiles on Wii Fit, the rest of the data will be in the same format, starting with the second profile at byte position 0x9289.

I was able to create a web page with a graph of my weight data, pulled from the Wii Fit Plus savegame.

Note, if you already have the savegame file saved on the SD card, trying to save it again will fail, since it says the file is already saved on the SD card. So, for example if you have some more Body Test data that you want to save, you will have to first delete the data.bin file from the SD card and then save it again from the Wii Menu.

Also note: I looked at a Wii Fit savegame file and it appeared to have the same format as Wii Fit Plus, so if you don't have Wii Fit Plus, I am sure you will be able to find your way around the file with no problem.