Virtual SD Card Guide

From Dolphin Emulator Wiki
Revision as of 18:04, 16 July 2022 by Mbc07 (talk | contribs) (Using Dolphin's Built-in SD Card Generation)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Dolphin can store data to a virtual SD card named sd.raw. By default, it will be created with the size of 128 MB.

The virtual SD card has important use for homebrew apps on Dolphin. Project M and Mario Kart Wii custom tracks are two good examples, as some homebrew apps can only work using files stored on the SD card of the real hardware for which they were designed.

Creating a Virtual SD Card

It is recommend to create one with size at least 1 GB for large homebrew apps, for example, Project M, and no more than 2 GB for best compatibility as there are compatibility issues with some homebrew apps trying to run under an SDHC card on the real hardware.

As of 5.0-16891, Dolphin can also automatically generate SD cards if you set a specific folder, and it will automatically determine the size during this process. This bypasses the need for third party programs.

Using Dolphin's Built-in SD Card Generation

The built-in generation is handled in the Options => Configuration => Wii menu along with the other SD card options. It will look something like this with the user having to manually configure the paths.

The options do as follows:

  • Insert SD Card: Tells the emulated Wii that an SD card is inserted.
  • Allow Writes to SD Card: Allows the emulated Wii to make changes to the SD Card. This should only be unchecked if you are using the SD card for Netplay/TASing or other experiments outside of normal use.
  • Automatically Sync with Folder: This means that Dolphin will generate the SD card based on your configured folder on *every* Wii game start, and then resync the folder *after* emulation. Warning: May be extremely slow with large Virtual SD Cards.
  • Convert Folder to File Now: Will use the configured SD Sync Folder to generate an SD card in the configured SD Card Path. Warning: Will overwrite any existing SD Card.
  • Convert File to Folder Now: Will extract the configured SD Card to generate a folder based on the SD Sync Folder path. Warning: Will delete all files previously in the SD Sync Folder!

Dolphin can still only use the SD Card file during emulation, but these options make it much easier to generate an SD card without the use of Third Party tools.

Generating SD Cards with Third Party Tools

If you're using older builds or simply prefer to use a Third Party tool for some reason, there are options for most operating systems.

Command Line and Executable Files

Download Virtual SD Card Maker, unzip it, and open the appropriate folder for your system (Linux / OS X / Windows). The tool is run with a command like:

mksdcard 2048M sd.raw
  1. Open the Command Prompt or Terminal then (Note: Vista fails to support drag and drop, and will require manual input.):
  2. Drag and drop mksdcard file into the command window for the full directory pointing to mkscard.
  3. Type 2048M for 2 GB, or if desired, an alternate size like 512M (512 MB), 1024M (1 GB), etc.
  4. Drag and drop an existing sd.raw file into the command window, or use a different directory/filename to create a new one.
  5. Assuming a default Global User Directory the virtual SD card should be placed at:
Linux: ~/.dolphin-emu/Wii/sd.raw OR ~/.local/share/dolphin-emu/Wii/sd.raw
OS X: ~/Library/Application\ Support/Dolphin/Wii/sd.raw
Windows: "%userprofile%\Documents\Dolphin Emulator\Wii\sd.raw" (quotation marks are necessary when copying it to Command Prompt)

Alternatively, a non-Mediafire download link can be found by visiting https://developer.android.com/studio/#command-tools and downloading the OS-specific zip there (mksdcard is part of the Android SDK)

Manual macOS Command Line Creation

This example creates a 2048 megabyte (2 GB) SD card formatted as FAT32:

hdiutil create -megabytes 2048 -fs MS-DOS -layout NONE -o ~/Library/"Application Support"/Dolphin/Wii/sd.raw
mv ~/Library/"Application Support"/Dolphin/Wii/sd.raw.dmg ~/Library/"Application Support"/Dolphin/Wii/sd.raw

Manual Linux Command Line Creation

If the above tool does not work, one can manually create a FAT32 partition image in Linux provided dosfstools is installed. First, pull up a terminal, and then chdir into the Wii folder, which under certain configurations may be located at ~/.local/share/dolphin-emu/Wii instead.

cd ~/.dolphin-emu/Wii

Then, we must create our raw disk image. This example create a 2048 megabyte (2 GB) SD card, but one can replace the 2048 with an alternate number of megabytes.

dd if=/dev/zero bs=1M count=2048 of=sd.raw

Finally, we format our image to FAT32.

mkfs.fat -F 32 sd.raw

Editing a Virtual SD Card

With Dolphin's built-in tools available in 5.0-16891 or newer, you can simply Convert File to Folder Now and then change whatever you want directly in your operating system by opening that folder. When you are done, simply Convert Folder to File Now to generate a new SD card. Alternatively, you can use Automatically sync with Folder on emulation start and end to do this process automatically, but it will cause longer startup/closing time on Wii games.

If you are stuck on older builds or simply wish to use other methods, there are ways to do this on most other operating systems.

Linux

The virtual SD card can be edited by mounting it to a virtual disk. Create a directory as a mountpoint:

sudo mkdir /media/sdcard

Mount sd.raw to the created directory:

sudo mount -o defaults,umask=000 ~/.local/share/dolphin-emu/Wii/sd.raw /media/sdcard

When you are done, unmount the virtual SD card:

sudo umount /media/sdcard

macOS

In Terminal window, type the following to mount the virtual SD card:

hdiutil attach -imagekey diskimage-class=CRawDiskImage ~/Library/Application\ Support/Dolphin/Wii/sd.raw

The virtual SD card can then be ejected through Finder when done being edited.

If you get an error (hdiutil: attach failed - no mountable file systems), you can use these commands instead:

hdiutil mount $(hdiutil attach -nomount -imagekey diskimage-class=CRawDiskImage ~/Library/Application\ Support/Dolphin/Wii/sd.raw)

Windows

The Windows users must use a third party software that can mount the virtual SD card. Speaking of which... ImDisk Virtual Disk Driver

WinImage is unreliable, because oddly enough, it will cause desync and few other unforeseeable problems. ImDisk will be fine.

Quick guide for mounting and editing the virtual SD card with the ImDisk Virtual Disk Driver:

  1. Right-click on sd.raw file then click "Mount as ImDisk Virtual Disk" from the context menu.
  2. Check box Removable media then hit "OK". The predefined drive letter and everything else will do just fine.
    • The virtual SD card will now appear as "Removable Disk" in which the native Explorer window can read and write in there.
  3. When done editing the virtual SD card, simply unmount it by right-click on the "Removable Disk" then click "Unmount ImDisk Virtual Disk" from the context menu.
    • The virtual SD card must be dismounted before using with Dolphin.

Usage

With Homebrew App

The external files used for the homebrew app must be stored within sd.raw and the homebrew app itself (boot.elf or boot.dol) must exist outside of it for Dolphin to load. Project M, for example, will load from SD root \projectm\ and Dolphin will need to launch Project M through \apps\projectm\boot.elf, NOT in the virtual SD card. For convenience's sake, it is ideal to have same copies paralleled between inside and outside of the virtual SD card.

Though, it is possible to start homebrew app from virtual SD card through homebrew exploits for Wii.

The Wii game launcher app will only work if a particular Wii game is set as the default ISO. Within the Dolphin game list, open context menu (right-click) on any Wii game and click Set as default ISO. Do this before loading a homebrew app with Dolphin.

For Netplay

In 5.0-16891 or newer, Dolphin can generate deterministic SD Cards for netplay! If you have "Automatically sync with Folder on emulation start and end" enabled on all computers, and the folders have the same exact files in them (file creation dates do not matter, as they will be scrubbed during the process), the generated SD card will be identical. Note that this does not sync any files - the folders on all computers must be identical.

If using an older build or not dealing with copyrighted content, we highly recommend just generating an SD card on one computer, and then copying that SD card to all other computers to ensure that things are the same. However, if that virtual SD card was used offline or online with write block disabled, the MD5 checksum will change ("Date Accessed" of the files are what's different in virtual SD card), but will not cause immediate syncs. If you are using a Wii game launcher app for various mods, users on all ends must have the same copies of homebrew app and the game in their game list first, then set the game as default ISO, as mentioned in previous section.

Handling Virtual SD Cards on Android

Currently there is not a good way to do this. Dolphin will generate a default SD Card that is 128 MB, but the Android GUI cannot currently change the directory, or automatically convert a folder into a SD card. The best way to do this is to use the instructions for a Desktop build of Dolphin to generate a SD card, and if you have an Android Device that allows you to access per-app directories from "File Transfer" when connected to a desktop, accessing "\Android\data\org.dolphinemu.dolphinemu\files\Wii" and then overwrite the "sd.raw" that is was generated there.

If done successfully, Dolphin on Android will now have your newly generated SD card with whatever data you put on it.