MegaDev9 plugin !!!

Discussion in 'PS2 Plugin Questions & Plugin Troubleshooting' started by Luigi__, Aug 14, 2008.

  1. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    Hi,

    I've written a DEV9 plugin that emulates HDD.

    DEV9 is a part of the PS2 that handles USB, HDD and Ethernet.
    In PCSX2, USB is handled by a USB plugin, HDD and Ethernet are handled by a DEV9 plugin.

    READ THE INSTRUCTIONS BELOW BEFORE POSTING!!!
    I will NOT answer any question which is already answered here. So I advise you take some
    time and read the instructions below.

    To get the plugin working:

    1- Put MegaDev9.dll in the plugins folder of PCSX2 (NOT THE ROOT FOLDER), otherwise it won't
    show up in the plugins list. The plugin doesn't require any external DLL to work. (that may change in the future, namely, WinPcap
    comes to mind when talking about ethernet support)

    2- Make sure you've a DEV9-capable PS2 BIOS. Slim PS2 BIOSes aren't compatible (Thanks to
    Suloku for this info), and BIOSes from old PS2s with PCMCIA aren't too (afaik). You must also
    have the EROM, ROM1 and ROM2 files with your BIOS. In other words, you must have a
    complete BIOS dump from your PS2. Don't complain that the plugin doesn't work if you're
    using a downloaded (illegal) BIOS. (DEV9-capable BIOSes are SCPH-3XXXX and SCPH-5XXXX).


    3- Configure the plugin. For that you must launch PCSX2, select MegaDev9 in the DEV9 plugins
    list and click on the Configure button. A GUI will show up, here's its description :
    -Enable logging : this is only for debugging purposes. The plugin will write all events
    to a file.
    -HDD file : enter the path and the name of the HDD image (see below for more info about
    HDD image). If you leave it, the image will be created in the PCSX2 root folder.
    -HDD size : select the size you want for the emulated HDD (HDD image). You can choose
    from 1 GB to 127 GBs. I recommend selecting at least 8 GBs, lower sizes could cause problems.

    4- Launch your game/program in PCSX2. The first time, the HDD image will be created in the path that you
    previously configured. This may take more or less time depending on the HDD size you've selected. Wait until
    the progress bar gets complete (100%). Then your program will ask for formatting if it's able to do this. If
    you followed the previous steps right, your program won't ask for formatting anymore, nor other
    programs will do.

    The HDD image is a file that will be used as a HDD, ie. when your program writes data in the
    HDD, the plugin will write these data in this file. Don't delete or move it without
    reconfiguring the HDD file path in the plugin, or you may cause problems.



    Troubleshooting
    Note : if your problem persists or if it's not described here, tell me. Attach a log file
    if possible.

    When I run HDLoader, I get a black screen.
    If you're using GSDX, enable "Logarithmic Z" in its options (Thanks to tich). If you're using speed hacks, disable them.

    My program always asks for formatting.
    If you've this problem, make sure you've a complete BIOS dump from a DEV9-capable PS2. The
    first models with PCMCIA aren't DEV9-capable, and the slim PS2s aren't too. Make sure the
    console doesn't tell it couldn't find rom1, rom2 or erom, these files are needed.

    My program fails writing to the HDD.
    Make sure you've enough space on your real HDD and also that the HDD image is big enough. Make
    sure the HDD image doesn't have read-only attribute.

    When I use savestates, I've problems with HDD funcs in my program.
    That's normal, savestates aren't supported yet.

    When I use the HDD command X, it doesn't work, it reports an error.
    The command you're trying to use isn't implemented, or you're passing invalid args.

    How can I copy games with HDLoader ?
    First, be sure to use at least PCSX2 0.9.6. Older versions have a CDVD timing bug which prevents HDLoader to work correctly.
    You need to insert your game DVD in your drive (or opening the ISO if you're using an ISO CDVD plugin), and open the HDLoader
    ELF file. This way, you should be able to copy your games smoothly. Pretty hacky, I know, but for the moment no CDVD plugin supports DVD hot swapping.
    Anyway, keep this in mind: YOU CAN'T BOOT THE GAMES YOU COPIED IN THE HDD !!! Because of a bug I haven't found yet.



    I need help !
    If you can find me documents about the DEV9 device, you're highly welcome !
    ATM, my only document for that ****ing device is the sources of PS2SDK. They actually helped me a lot as HDLoader uses
    the same DEV9 code as PS2SDK !

    Note:
    I designed the plugin to be as many portable as possible. The only Win32-only thing is the GUI.
    If somebody is interested in porting the plugin for Linux, he's free to do it. Isolate all the
    Win32-specific code with #ifdef / #endif tags.

    Changelog:

    Version 1.0.0
    -First version, support for HDD emulation.

    Version 1.0.1
    -Reduced the IRQ timings
    -The minimal HDD size is now 8 GBs, lower sizes seem to cause problems
    -Implemented the Idle command
    -Implemented the nIen bit in control reg (disables IRQ)
    -Fixed a bug occuring when pressing Escape then running another HDD-compliant program in PCSX2
    -Implemented the Sony-specific security control command (0x8E), the programs that want a Sony HDD should now work without a patch
    -Changed a bit the Identify device command, maybe it will fix Final Fantasy XII.

    Download the plugin and its sources in the attachments.

    Compatibility of the HDD image:
    The HDD image can be mounted with Mount Image Pro or any other image mounter. After you mounted the image, you can use it with HD Handiness (see SKSApps). WinHIIP says that HDL file settings is corrupt, I don't know why, maybe this is because I used an image of 8 GBs. Simply click OK and you'll be able to use it without corrupting your HDD image. Make sure you unmount the image before launching PCSX2, otherwise the plugin won't success to open the HDD image.

    What you must know about the Sony HDD:
    The Sony HDD is a standard HDD, but its firmware has been modified by Sony in order to support a command that standard HDDs don't support. Sending this command to the HDD is the only way to distinguish if the HDD is Sony or not, if it reports an error, then it's not a Sony HDD. This command is implemented in version 1.0.1 and later, so Sony programs will work with it. This command is "SCE security control" (0x8E).

    What is planned for next versions:
    - More intelligent HDD image format (automatic compression of zero-filled blocks + LZ77 compression) (will be incompatible with WinHiip :( )
    - Better implementation of SCE security command
    - Better IRQ handling and such
    - 48-bit support (no more 127 GBs limit, if you've a big HDD)
    - EEPROM emulation
    - The long-awaited Ethernet emulation

    Credits to :
    - Authors of PS2SDK and DEV9Linuz, without these source codes I couldn't have figured out how DEV9 works.
    - Authors of various documents explaining how PC IDE controllers work.
    - Suloku for pointing out the compatibility problems with slim PS2 BIOSes.
    - KabooZ for the infos about the Sony HDD.
    - MiKE41 for his great help (testing).
    - tich for how to fix the black screen bug with HDLoader.
    - kamilusPL for his help.
    Last edited: Aug 29, 2009
  2. NGEmu.com Advertisement

  3. Hard core Rikki

    Hard core Rikki Super Moderator Staff Member Award Winner!

    Messages:
    12,879
    Likes Received:
    300
    ONe more sticky, one.
    Nice job working that one out, btw
  4. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    Thanks.

    BTW, I think you'll agree with me, there're many stickies.
  5. rama2

    rama2 Emu author Emu Author

    Messages:
    1,467
    Likes Received:
    0
    Many thanks for this!
    However I can't get hdloader to recognize my ps2 disc, any idea on how to get games on the hdd? :p
  6. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    What version are you using ?
    Mine is 0.8c.

    Are you talking about HDD or DVD ?
    If it's DVD it's normal. The current CDVD plugins don't (or badly) support changing disc on the fly.
  7. rama2

    rama2 Emu author Emu Author

    Messages:
    1,467
    Likes Received:
    0
    Well, i tried just every possible combination of many cdvd plugins and their settings.
    Running hdloader 0.8c directly from .elf. So i dont need to change discs or smth.
    Whenever i tell hdloader to install games, the software gets the disc status, then hangs :p
  8. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    That's normal for the moment. I also tried every tricks that I found to get it copying a game, resulting in either a message saying "the disc inserted is not a valid PS2 disc" or hanging after HDLoader has read some sectors from DVD.

    EDIT : Keep in mind that HDLoader isn't the only application for this plugin. PS2Linux may also work, and I read somewhere that Final Fantasy XI needs a HDD to work (not tested, I don't have this game). And now PS2 homebrewers can test their HDD homebrews directly on PCSX2, without needing to send them to their PS2 at each test.
    Last edited: Aug 14, 2008
  9. rama2

    rama2 Emu author Emu Author

    Messages:
    1,467
    Likes Received:
    0
    Yeah, sure it has lots of other uses :p
    But i wanted hdloader especially, since i wanna try and work around a cdvd timing issue.

    So still, great work, and lets see if the PS2 Linux works :D
  10. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    If you can code, you're free to create a CDVD plugin that supports changing disc on the fly, this will be appreciated :) However, GiGaHerz is working on that with his CDVD plugin.

    If you can test PS2Linux, then go test it. I'll appreciate that.
  11. Silenus

    Silenus Pilgrim Junior Contributor

    Messages:
    8,653
    Likes Received:
    176
    Appreciate the work you are doing with your plugins NHervé.

    Thanks a lot.
  12. bositman

    bositman New Member Contributors

    Messages:
    3,630
    Likes Received:
    1
    Great job NHervé! Hope you keep working on it until it's perfect :) Added the news in the PCSX2 site
  13. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    Thanks a lot !
  14. refraction

    refraction PCSX2 Coder Contributors Award Winner!

    Messages:
    10,102
    Likes Received:
    19
    aaaaaaaaaaand stickied
  15. bositman

    bositman New Member Contributors

    Messages:
    3,630
    Likes Received:
    1
    Seems rama made some timing fixes allowing games to install now,without that hang there :) Although they crash before playing

    Possible bug: Even if i chose to make an 8GB image,i ended up with a 4.067.329kb raw file...the partition i'm doing this is NTFS before you ask
  16. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    refraction : thanks a lot !

    bositman : if rama is working on HDLoader issue, that's great. For your image size issue, that's normal, when the image is created, it's empty, ie. its size is 0 byte. If your program only writes 4 GBs of data, the image will have a size of 4 GBs. BTW, what's your program ? It can't be HDLoader, because HDLoader creates APA parititons.
  17. MiKE41

    MiKE41 Title goes where?!

    Messages:
    112
    Likes Received:
    0
    I also noticed that no matter what file I select it comes out with a 4gb file (making it on a NTFS partition too)

    Things I tried:

    Taking a raw image (made with dd) of a PS2 hard drive, feeding it to MegaDev9. Result: frozen at the HDL splash screen.

    Mounting a hard drive image (made with MegaDev9 + PCSX2) using Mount Image Pro (Computer Forensics Software Download: Download Mount Image Pro) then loading it up with WinHiip to put a game on. Result: WinHiip complained about something (I have no idea what to make of it), and was too small to format correctly. WinHiip noticed the drive as 4gb even though I selected 11gb in the MegaDev9, and the HDL menu said 11gb options.


    Note with MountImagePro: After you tell it to mount the drive, it will continue to say theres no drives mounted, however it shows up in WinHiip just fine.

    Edit: It seems that hddImage = fopen(config.hddFile, "r+b"); is whats causing the file to be limited to 4gb after a quick google (fopen 4gb - Google Search)
    Last edited by a moderator: Aug 15, 2008
  18. Luigi__

    Luigi__ Emu author Emu Author

    Messages:
    821
    Likes Received:
    6
    That's normal for the moment. The image isn't zero-filled at start. I had implemented this feature before, but I've removed it because zero-filling the image took too many time.
  19. bositman

    bositman New Member Contributors

    Messages:
    3,630
    Likes Received:
    1
    Well with his modifications,now it doesn't hang at recognizing the disc :) Check your PM for the build,I bet it will help you improve your plugin alot
    I'm using HDloader I just said my HD is NTFS not the image ;)
  20. rama2

    rama2 Emu author Emu Author

    Messages:
    1,467
    Likes Received:
    0
    In cdvdReadTimeRcnt in cdvd.c:

    //simulates spin-up time, fixes hdloader
    if (cdvd.Sector < 17) cdvdReadTime=60000;
  21. radical dreamer

    radical dreamer n00b necromancer

    Messages:
    28
    Likes Received:
    0
    Final Fantasy XI.. Well it runs now, but says of course, that PlayOnline needs to be installed before using FFXI, and PlayOnline doesn't run on the current public beta pcsx2.

    What I get with PlayOnline installer in pcsx2:
    CdRead: Reading Sector 16
    CdRead: Reading Sector 257
    SKIP level changed to: #
    SKIP level changed to: #
    SKIP level changed to: #
    SKIP level changed to: #
    SKIP level changed to: #
    etc.

    Also I couldn't get the PS2 Utility disc 1.10 to run in the emu to test that, it just crashes it.

Share This Page