DLDI

Dynamically Linked Device Interface for libfat

DLDI is the Dynamically Linked Disc Interface for Game Boy Advance and Nintendo DS. It works as a part of libfat to allow homebrew programs to read and write files on the memory card inserted into one of the system's slots. It has also been implemented for GBA_NDS_FAT and DSLinux.

How to use

By default, homebrew that utilizes the DLDI framework will probably work on a specific device (the one the author uses) but can be patched to work with any device listed in the devices section.

Some devices will patch the homebrew for you automatically when it is loaded. Just try the ROM to see if it works with your device. If it does, then great! If not, you will need to patch the file before transfering it to your device. In this case, after downloading the DLDI-enabled homebrew, you need to patch the .nds or .ds.gba depending on what device you are using.

First you need to download the DLDI driver patch for your device. So go to the devices section, find your device and download the .dldi file.

Next you need to obtain a patcher that can run on your computer's operating system. Go to the tools list and download your prefered tool and follow the given instructions.

Once you have patched the .nds or .gba file, you can copy it to your memory card and run it from your DS.

If you have multiple devices, it may be a good idea to rename the patched files something like this:

DLDIWiki

DLDIWiki has been closed down and all information moved to this page. An old copy of DLDIWiki can be found on the Internet Archive.

DLDI Device patches

DeviceDownloadSourceAuthorRead/WriteTested?ManufacturerLast ModifiedNotes
Default (No device)DLDISRCChishm-/--Chishm2007-01-12
AceKard+DLDI---AceKardR/WYesAceKard2007-01-31
CycloDS Mini/MicroDLDI---Team CyclopsR/WNoCycloDS2007-06-25
Datel Games 'n' MusicDLDI v1SRCChishmR/WYesDatel2007-07-04Slower but more compatible
DLDI v2SRCChishmR/WYes2007-07-05Faster but requires an SDHC card, see this gbadev forum thread
DSLink (microSD Card)DLDI v1SRCRudolph (ported by Lick)R/WFailedDSLink2006-12-26
Moonshell DLDI/a>---MoonLightR/?Yes2006-12-30Moonshell version
DLDI v3SRCDiddlR/WYes2007-03-02This version does not work in DSLINUX because of an swiDelay() call. There is a bug that makes writes unpredictable.
DLDI v4SRCAmadeusR/WYes2007-05-20Fixes the bugs present in version 3
DS-XDLDISRCDS-Xtreme TeamR/WYesDS-X2007-02-12The DS-Xtreme does a form of auto-patching [2]
Ewin2 (SD Card)DLDISRCMoonlightR/WYesEwin flash2006-12-29
EZ Flash 4 (SD Card)DLDISRCRudolph (Original by EZ Team (aladdin))R/WYesEZ Flash2006-12-27
EZ Flash 5DLDISRCCory1942, ps2aichR/WYesEZ Flash2008-09-10Can be used for Wireless MultiBoot, etc.
SDHC DLDISRCCory1942, ps2aichR/WYes2008-09-10Can only be used when booting up via EZ-V+ [1]. For usage in EZ-V+, copy both EZ5 drivers into the moonshl folder.
G6 Flash (version 0.19)DLDISRCvirusebR/WYesG6 Flash2007-04-12
G6 RealDLDI---G6 TeamR/WNoG6 Flash2007-07-12Also known as G6DS. This device supports automatic patching [2].
M3 Adapter (Compact Flash)DLDISRCChishmR/WFailM3 Adapter2007-05-05Fails read alignment test. The built-in M3CF driver works fine so this DLDI may not be needed [2].
M3 Adapter (SD Card)DLDISRCChishmR/WYesM3 Adapter2006-12-25
AltSRCagentqR/WYes2007-01-20
Max Media Dock (Compact Flash)DLDISRCChishmR/WYesCode Junkies2007-01-07
GBA Movie Player (Compact Flash)DLDISRCChishmR/WYesMovie Advance2006-12-25
GBA Movie Player (SD Card)DLDISRCps2aich (Original by Movie Advance)R/WNoMovie Advance2007-08-09Driver only works when the patched application is booted via the GBAMP SD itself [1]
NEO Flash MK2 & MK3 (SD Card)DLDISRCNEO Flash TeamR/WYesNEO Flash2006-12-25
NEO Flash MK5 (NAND Flash)DLDISRCNEO Flash TeamR/-NoNEO Flash2007-02-07
NEO2 (SD Card)DLDISRCNEO Flash TeamR/WYesNEO Flash2006-12-28
DLDISRCNEO Flash Team & ChishmR/WYes2006-12-28Faster reads than version 1
Ninja DS (SD Card)DLDISRCNinjaMod teamR/WYesNinjaDS2006-12-25
Ninjapass X9DLDISRCCJ BellR/WYesNinjapass2007-10-23
R4(DS) - Revolution for DS
M3 Simply compatible
DLDI v1SRCR4DSR/WYesR4 (R4DS) - Revolution for DS2006-12-25Does not support ARM7. This device supports automatic patching [2].
DLDI v2SRCR4DS, modified by ChishmR/WYes2007-12-27Supports ARM7
SuperCard (Compact Flash)DLDISRCChishmR/WYesSuperCard2006-12-26
SuperCard DS (One)DLDI v0SRCSuperCard Team (ported by Lick)R/?YesSuperCard2006-12-25To use these files with the auto dldi patching feature: download the dldi, rename to dldi.bin and place it into the "scshell" folder of your microSD replacing the existing file.
DLDI v1SRCclunyR/WYes2007-05-01
DLDI v2---BarniR/WYes2007-09-14
SuperCard DS (One) SDHCDLDI v0SRCSuperCard TeamR/?FailedSuperCard2007-08-09To use these files with the auto dldi patching feature: download the dldi, rename to dldi.bin and place it into the "scshell" folder of your microSD replacing the existing file.
DLDI v1SRCclunyR/WYes2007-12-07
SuperCard (SD Card)DLDISRCChishmR/WYesSuperCard2006-12-25
Alt---MoonLightR/WYes2007-02-14Based on code from MoonShell. Works on newer Supercards that may fail with other DLDIs. Must be booted from Supercard firmware. [1]
SuperCard Lite (SD Card)DLDISRCbrisssouR/WYesSuperCard2007-01-19
SuperCard Rumble (SD Card)DLDI---BarniR/WYesSuperCard2007-08-28May work for other SuperCard devices that use SD cards

Additional Notes

[1] DLDIs that require the patched application to be run from the device menu may not work after ejecting and reinserting the card while the GBA or DS is still powered on. This means they may not run programs that back up data saved in the EEPROM, flash, or SRAM on GBA Game Paks. Additionally, these drivers may not work when started by other methods, for example Wireless MultiBoot (WMB) or Card Swap.

[2] The device firmware automatically patches loaded applications. This driver is provided for cases when automatic patching does not work, for example when booted via Wireless MultiBoot (WMB), or applications that boot other applications (like a homebrew menu). If you want to force the use of a DLDI patch then disable auto-patching of the application by using DLDI No-AutoPatch.

Patching tools

Executable TypeDownloadLast ModifiedVersionCreatorMore Information
SourceGitHub2007-08-021.24Chishm, WinterMute, SmileyDude
Win32 CLIDownload2007-02-051.23Chishmdlditool CLI instructions
Win32 GUIDownload2007-01-131.23Adam Hodson (bob_fossil) / MaximDetailed instructions
Simplified Chinese Download2007-01-131.22Translation by yeyezai
Win32 Right ClickDLDIrcSetup.exe (Web page)2007-10-170.93PsychoWoodDetailed information
Linux i686 CLIDownload2007-08-021.24WinterMutedlditool CLI instructions
Linux x86_64 CLIDownload2007-08-021.24WinterMutedlditool CLI instructions
Linux GUIdeb package or source2008-04-131.0Lucas van Dijk (Sh4wn)Detailed information
Linux GUI (alternative)Download2007-07-151.0s0l1dsnak3123Linux GUI (alternative) instructions
Nautilus scriptDownload (Direct)2007-04-241.0Richard Quirk (Quirky)Nautilus Script
MacOS X CLIDownload2007-08-021.24WinterMutedlditool CLI instructions
MacOS X DLDI DropLocal copy or Web page2007-01-301.23Jan KamplingRead Jan's blog (Internet Archive copy)
No auto-patch CLIDownload2007-08-12PsychoWoodNo auto-patch instructions
No auto-patch GUIGUI2007-08-12NphinityNo auto-patch instructions

dlditool command line instructions

Extract the patch and patcher to the same directory as the ROM file. Open a command prompt in that directory. Type in:

dlditool <name_of_patch> <rom_file>
Where <name_of_patch> is the name of the patch file (e.g. "mpcf.dldi") and <rom_file> is the name of the ROM (eg "libfat_tests.nds").

You should see something similar to this:

C:\rom_dir\>dlditool mpcf.dldi libfat_tests.nds
Dynamically Linked Disk Interface patch tool by Michael Chisholm (Chishm)

Old driver:          Default (No interface)
New driver:          GBA Movie Player (Compact Flash)

Position in file:    0x000062C0
Position in memory:  0x02000000
Patch base address:  0xBF800000
Relocation offset:   0x428060C0

Patched successfully

Once you have patched the ROM, copy it to your flash cart and run it.

No auto-patch

The No-AutoPatch tool stops a DS application being patched with a new DLDI. Use this if you have already patched a DLDI into an application and don't want a device firmware to repatch it. The tool works by overwriting the DLDI header in the application so that auto-patchers can't find where to overwrite the DLDI section.

For the CLI version run dldinoap <rom_file> to disable auto-patching of <rom_file>. Run it again to re-enable auto-patching.

For the GUI version run DLDI No-Patch.exe, point it at the ROM file, then hit start. Run DLDI Yes-Patch.exe to re-enable auto-patching.

Linux GUI (alternative)

This is an alternative GUI for Linux users, written in realBASIC by s0l1dsnak3123.

Download the program, the right DLDI for your card, and of course the file you want patched. Unzip the program and run it.

Click on the first browse button and find the command line version of the DLDI patcher (dlditool) then double click on it. Click on the second browse button and find the location of the .DLDI file then double click on this also. Click on the last browse button and find the location of the file you want to patch. Finally click on Patch.

A Finished! message box should come up. Now you're done! All that is left to do is copy the patched file to your card and enjoy.

Nautilus Script

This is a script to enable DLDI patching in the Nautilus file manager.

Requires: Nautilus, dlditool CLI (put it in path), and zenity (try: sudo apt-get install zenity)

To install: Copy PatchDLDI to $HOME/.gnome2/nautilus-scripts. Place your dldi files in $HOME/data.

To use: Right click an NDS file and select scripts > PatchDLDI. Choose the patch type.

For Developers

Using DLDI in an application or game

The DLDI IO_INTERFACE is included as part of libfat. It will be included when you use libfat within your project.

If you are still using gba_nds_fat, you can use a backported IO_INTERFACE. Copy it to your gba_nds_fat source directory and add io_dldi as the first driver in the initialization list.

You may wish to add a patching step to your makefile, following the dlditool instructions.

Writing a DLDI driver

  1. A DLDI template is installed as part of DevkitARM. Get it using the DevkitPro Updater.
  2. Install the NDS examples as part of DevkitARM.
  3. Copy the dldi directory from <path_to_devkitPro>/examples/nds/templates/.
  4. Rename the dldi folder to the four character code for the driver.
  5. Replace the functions inside source/iointerface.c with ones specific to the device.
  6. Open source/dldi_header.s for editing:
    1. Change the text "Name of driver goes here" to an appropriate description for the device.
    2. Change the text "XXXX" to the four character code for the driver.
    3. In the IO_INTERFACE data section, make sure that either FEATURE_SLOT_GBA or FEATURE_SLOT_NDS is specified, depending on which slot the device goes into.
  7. Compile by running make in the top level directory of the driver.
  8. If you get an error containing the text "overlaps previous sections", the driver is too big to fit in the available space. Since only 32KiB are allocated for DLDI patches, you will need to reduce the size of the driver. Try reducing the size of global arrays or let some card initialisation be done by the device firmware.
  9. Test it out by following the testing instructions.
  10. If it works, distribute it. Feel free to send me an email (address is on the front page) with the interface to add to this page. Please include test results.

Testing a DLDI driver

Some of the interfaces listed above have not been tested, or may appear to not work for you. If you wish to test an interface, download the DLDI Tester. Extract the contents to the root directory of the card you'll be testing, then patch it for the correct card, following the instructions above. Make sure you backup everything on the card, I accept no responsibilty if anything goes wrong. Follow the onscreen prompts and observe the outcome. Feel free to email me with results for a card that hasn't been tested already, or results contrary to those in the above table.

Acknowledgements

The following people either directly or indirectly helped to create the DLDI interface: