Page 1 of 1

program hangs at hddCheckPresent

Posted: Wed Jun 30, 2004 8:33 am
by 606u
Hi,

I'm just trying to feel comfortable with PS2 SDK and I'm trying to run the following simple code:

Code: Select all

int
main (void)
{
  t_hddInfo hdd_info;

  SifInitRpc (0);

  printf ("Checking for supported HDD...");
  if (hddCheckPresent () == -1)
    {
      printf (" no supported HDD found.\n");
      return (0);
    }
  else
    printf (" found.\n");

  printf ("Checking whether HDD is formatted...");
  if (hddCheckFormatted () == -1)
    {
      printf (" HDD is not formatted.\n");
      return (0);
    }
  else
    printf (" found.\n");

  printf ("Getting HDD information...");
  hddGetInfo (&hdd_info);
  printf (" ok.\n"
          "Total size: %d MB, free space: %d MB, max partition size: %d MB\n",
          hdd_info.hddSize, hdd_info.hddFree, hdd_info.hddMaxPartitionSize);

  return (0);
}
Code compiles, but when executed hangs on hddCheckPresent () line. I'm guessing that, because "Checking for supported HDD..." message is printed, but nothing else. I suppose I'm missing some really important part here (like resource/library initialization or something). Can you guide me where to read?

Thanks in advance.

My setup: WinXP + CYGWIN, ee-gcc 3.2.2, PS2SDK 1.0a binary

Posted: Sat Jul 03, 2004 9:42 pm
by TyRaNiD
Erm yah you haven't loaded any hdd irx modules up :) Look at the libhdd example for how you do this and what you need to load.

Posted: Sat Jul 10, 2004 9:35 am
by 606u
I beat it :) thanks.

I took ps2menu source code and use the same method to load the modules.

Posted: Mon Jul 12, 2004 10:38 am
by ginkei
That's odd... I'm having the same problem.. I also used the ps2menu method of loading the irx's, but my project still hangs at hddCheckPresent().
These are the IRX's I load, and the order in which I load them:
poweroff.irx
iomanX.irx
fileXio.irx
ps2dev9.irx
ps2atad.irx
ps2hdd.irx
ps2fs.irx

Did I leave out anything important?
I'm using the PS2SDK version of libhdd.
On a related note, hddPreparePoweroff() seems to be missing from PS2SDK's libhdd... has it been moved to a different lib?

Thanks for your help!

Posted: Mon Jul 12, 2004 11:58 am
by blackdroid
it is for some reason in libpoweroff and in that archive only poweroff.o is, I think its like that by a freak accident since the move.

Posted: Mon Jul 12, 2004 12:27 pm
by ginkei
Thanks, that helps a lot.
But now I have a new problem :)
I am loading irx's from ee memory, so I had to use the sbv_patches.
Now, my program freezes immediately after loading ps2hdd.irx.
The hard drive spins up, and the hard drive light comes on and stays on, but my program does not proceed to load ps2fs.irx or anything else.
Any ideas?

Thanks again!

Posted: Mon Jul 12, 2004 7:13 pm
by 606u
Look at the code I've linked in this thread.

Posted: Tue Jul 13, 2004 1:55 am
by clement
I have tried running the libhdd example from CD-R (I have modified the irx paths) but I am also having the same problem as ginkei: The hard drive spins up, and the hard drive light comes on and stays on, but the program does not proceed to load ps2fs.irx or anything else.

Code: Select all

void loadModules()
{
	static char hddarg[] = "-o" "\0" "4" "\0" "-n" "\0" "20";
	static char pfsarg[] = "-m" "\0" "4" "\0" "-o" "\0" "10" "\0" "-n" "\0" "40" /*"\0" "-debug"*/;

	scr_printf("cdrom0:\\POWEROFF.IRX;1\n");
	SifLoadModule("cdrom0:\\POWEROFF.IRX;1", 0, NULL);
	scr_printf("cdrom0:\\IOMANX.IRX;1\n");
	SifLoadModule("cdrom0:\\IOMANX.IRX;1", 0, NULL);
	scr_printf("cdrom0:\\FILEXIO.IRX;1\n");
	SifLoadModule("cdrom0:\\FILEXIO.IRX;1", 0, NULL);

	scr_printf("cdrom0:\\PS2DEV9.IRX;1\n");
	SifLoadModule("cdrom0:\\PS2DEV9.IRX;1", 0, NULL);
	scr_printf("cdrom0:\\PS2ATAD.IRX;1\n");
	SifLoadModule("cdrom0:\\PS2ATAD.IRX;1", 0, NULL);
	scr_printf("cdrom0:\\PS2HDD.IRX;1\n");
	SifLoadModule("cdrom0:\\PS2HDD.IRX;1", sizeof(hddarg), hddarg);
	scr_printf("cdrom0:\\PS2FS.IRX;1\n");
	SifLoadModule("cdrom0:\\PS2FS.IRX;1", sizeof(pfsarg), pfsarg);
}
When I boot from the CD, it displays only the following lines:
cdrom0:\POWEROFF.IRX;1
cdrom0:\IOMANX.IRX;1
cdrom0:\FILEXIO.IRX;1
cdrom0:\PS2DEV9.IRX;1
cdrom0:\PS2ATAD.IRX;1
cdrom0:\PS2HDD.IRX;1

Posted: Tue Jul 13, 2004 2:51 am
by 606u
Try to embed IRX files in the ELF (as does ps2menu). Check the link above - HDD does work with that code (via NapLink or via PS2Link; TCP/IP doesn't work).

Posted: Tue Jul 13, 2004 12:38 pm
by clement
606u wrote:Try to embed IRX files in the ELF (as does ps2menu). Check the link above - HDD does work with that code (via NapLink or via PS2Link; TCP/IP doesn't work).
You mean it doesn't work when everything is on a CD-R?
I am not using any form of network transfer to run this, the elf and irx is on the CD-R itself.

Posted: Tue Jul 13, 2004 1:41 pm
by ginkei
Actually, I've already got the irx's embedded in my elf. I haven't seen anything in the posted code that is remarkably different from what I'm doing either... I wonder if this could be compiler related? Unless there's something I just keep missing that's supposed to be done before loading ps2hdd.irx.
Any more ideas? If not, I guess I'll just keep playing around until I get it.

Also - in that posted code, it looks like the blocks that actually load ps2hdd.irx are enclosed in an "#ifdef 0/#endif" block. Unless I've got my true/false values backwards, doesn't that mean your code is not loading ps2hdd.irx?

Posted: Tue Jul 13, 2004 6:54 pm
by blackdroid
yeah #if 0 is false, so if its still in the code fileio, ps2atad, ps2hdd irx's wont be loaded.

Posted: Mon Jul 19, 2004 8:00 am
by ginkei
Ok.. I've been trying to debug a little bit. It seems the ps2 freezes up in the initialization of ps2hdd, specifically when ps2hdd.irx calles atadInit(). Is this a bios call? I couldn't find it in the sdk source via grep...

UPDATE: I realized atadInit is just another name for an export from ps2atad.irx. I've been tracing execution (via printfs... :) ) and the culprit seems to be the call to ata_device_set_transfer_mode(i,0x40,4); in ps2atad. I'm gonna keep playing around and see what I find out. The hdd I am using is not very old, so I cant imagine it wouldn't support udma4. Moreover, other hdd apps work with it! Just not ones I compile myself.
Hmmm.... testing continues...

UPDATE AGAIN: this is very strange. the line "ata_hwport->r_command=command" inside ata_io_start is where execution halts. Is this some kind of memory mapped io port that's mapped to a static struct or something? I cant think of any other reason for this assignment to lock up the system.

Posted: Mon Jul 19, 2004 10:09 am
by clement
ginkei wrote:Ok.. I've been trying to debug a little bit. It seems the ps2 freezes up in the initialization of ps2hdd, specifically when ps2hdd.irx calles atadInit(). Is this a bios call? I couldn't find it in the sdk source via grep...

UPDATE: I realized atadInit is just another name for an export from ps2atad.irx. I've been tracing execution (via printfs... :) ) and the culprit seems to be the call to ata_device_set_transfer_mode(i,0x40,4); in ps2atad. I'm gonna keep playing around and see what I find out. The hdd I am using is not very old, so I cant imagine it wouldn't support udma4. Moreover, other hdd apps work with it! Just not ones I compile myself.
Hmmm.... testing continues...
Maybe you should changing the last parameter to some lower speed (like UDMA 2) and see if it works:
ata_device_set_transfer_mode(i, 0x40, 2);

Posted: Mon Jul 19, 2004 10:32 am
by ginkei
Tried that - no such luck, even setting UDMA2 locks up the ps2 at the "ata_hwport->r_command=command" line. I even tried skiping the mode setting altogether, but then the system locks up in the ata_io_finish() call from ata_device_smart_enable().
The drive is an IBM Deskstar 120GXP, so it definitely supports both UDMA4 and SMART. (Even checked the spec sheet.)

Posted: Mon Jul 19, 2004 11:11 am
by J.F.
You say that other programs for the HDD work - have you tried the IRX you use with them with your program? Maybe you're having trouble making the IRX. You want to narrow down if the problem is the IRX or how you use the IRX.

Posted: Mon Jul 19, 2004 11:57 am
by ginkei
Well, the apps I've tried that worked all seem to have the irx's linked into the elf. For example, pgen. Interestingly enough, the pre-built irx's and the example that comes with libhdd all fail to work in exactly the same way...
Just for the heck of it, I'm going to try a different host on the ps2.

Posted: Mon Jul 19, 2004 12:19 pm
by ginkei
OK! Now I feel stupid :)
The problem was pukklink all along.
I just tried ps2link, and my problems have vanished.
Billions of printfs in hdd.c and atad.c, and for what? :)
Oh well, maybe now I can actually do something useful. I was thinking of doing some kind of mem card<->HDD<->usb drive savegame copier.