forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with sceLflashFatfmtStartFatfmt

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 7:37 am    Post subject: Problem with sceLflashFatfmtStartFatfmt Reply with quote

Hey,

First of all, note that I'm trying to run this application from a DDCv4 stick using the ELF menu. Also, I already tried to search, and I can't seem to make up from that why it isn't working.
I need to format flash0, flash1 and flash2.
I did my best to write it as clean as possible with loops and stuff :) I reversed the modules to load from DDC.
Code:
int sceLflashFatfmtStartFatfmt(int args_number,void* argv);

#define N_Modules 3
char* Modules [N_Modules] = { "ms0:/kd/nand_updater.prx", "ms0:/kd/lfatfs_updater.prx",  "ms0:/kd/lflash_fatfmt_updater.prx" };

int main(){

   char buf1[20];

   /* Loading modules */
   for(i = 0; i < N_Modules; i++){
      printf("Loading %s...", Modules[i]);
     
      mod = pspSdkLoadStartModule(Modules[i], PSP_MEMORY_PARTITION_KERNEL);     
      if (mod < 0)
         ErrorExit(5, 1, "\nError 0x%08X loading/starting %s.", mod, Modules[i]);
     
      printf(" done\n");
   }

   /* Unassigning Flashes */
   printf("Unassigning flashes...");
   
   for(i = 0; i < 2; i++){
      sprintf(buf1, "flash%i:", i);
      if (sceIoUnassign(buf1) < 0)
         ErrorExit(5, 1, "\nError: Can't unassign flash%i.", i);
   }
   
   printf(" done\n");

   /* Formatting flashes */
   char *argv[2];
   argv[0] = "fatfmt";
   
   for(i = 0; i < 3; i++){
      printf("Formatting flash%i...", i);
     
      sprintf(buf1, "lflash0:0,%i", i);
      argv[1] = buf1;
   
      if (sceLflashFatfmtStartFatfmt(2, argv) < 0)
         ErrorExit(5, 1, "\nError whilst formatting flash%i.", i);
      printf(" done\n");
   }
}

My stubs file:
Code:
      .set noreorder

#include "pspstub.s"

   STUB_START "LflashFatfmt",0x40090000,0x00010005
   STUB_FUNC 0xB7A424A4,sceLflashFatfmtStartFatfmt
   STUB_END

Now, my problem is, that it simply freezes when it starts to format. I've been spending like 3 hours on this little bug now, and it's driving me crazy.
Is there a special trick needed because I'm loading it from the DDC stick or is there something wrong with my code?

Thanks,
JumpR :)


Last edited by JumpR on Thu Mar 13, 2008 4:12 pm; edited 2 times in total
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Mar 13, 2008 7:46 am    Post subject: Reply with quote

Does it shutdown itself? (the psp)
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 7:47 am    Post subject: Reply with quote

Pirata Nervo wrote:
Does it shutdown itself? (the psp)

Yes. Well, it hangs at "Formatting flash0..." for a few seconds, then it shuts itself down.
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Mar 13, 2008 8:29 am    Post subject: Reply with quote

Are you running on usermode?
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 8:33 am    Post subject: Reply with quote

Pirata Nervo wrote:
Are you running on usermode?

Nope.
Code:
PSP_MODULE_INFO("Test", 0x1000, 1, 0);
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Mar 13, 2008 9:01 am    Post subject: Reply with quote

That might be the problem. Change it to 0.
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 9:03 am    Post subject: Reply with quote

Pirata Nervo wrote:
That might be the problem. Change it to 0.

That doesn't make sense.. How can I format the flashes, write files and other stuff in user mode? DDC is also kernel mode...
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Mar 13, 2008 9:12 am    Post subject: Reply with quote

Huh? That code can't even compile.
You reference buf1 before you declare it; you're missing a semicolon when you do declare it; etc.
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 9:17 am    Post subject: Reply with quote

jimparis wrote:
Huh? That code can't even compile.
You reference buf1 before you declare it; you're missing a semicolon when you do declare it; etc.

I'm sorry, it was caused by the fact that this is only a snippet of the whole code, fixed ;) In the original code it was correct, so that wasn't the reason.
Back to top
View user's profile Send private message
jimparis



Joined: 10 Jun 2005
Posts: 1179
Location: Boston

PostPosted: Thu Mar 13, 2008 9:48 am    Post subject: Reply with quote

You never fill "argv[0]" before calling sceLflashFatfmtStartFatfmt. (And if you answer is again just "Oh, but it's there in the real code".. then well, if you can't be bothered to post the proper code, then we can't be bothered to look at it).
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Thu Mar 13, 2008 4:13 pm    Post subject: Reply with quote

jimparis wrote:
You never fill "argv[0]" before calling sceLflashFatfmtStartFatfmt. (And if you answer is again just "Oh, but it's there in the real code".. then well, if you can't be bothered to post the proper code, then we can't be bothered to look at it).

Wait, that might be the problem :) I removed it accidently during my 3 hours of trying.. everything. However, I recompiled with the line (argv[0] = "fatfmt";), and it still doesn't work :(

I'm sorry that I won't post the full code, it's a little over 400 lines and I don't want to post it fully here, this snippet is a direct copy, however, the declaration of buf1[20]; was at the top of the code in the full code, so I forgot to move it before posting it here, sorry about that.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Thu Mar 13, 2008 6:19 pm    Post subject: Reply with quote

Try to unassign before loading the modules.
Back to top
View user's profile Send private message
Pirata Nervo



Joined: 09 Oct 2007
Posts: 409

PostPosted: Thu Mar 13, 2008 7:28 pm    Post subject: Reply with quote

@JumpR, create a kernel prx where you can load the function from (mode 0x1006) and then use usermode in your main application.
_________________

Upgrade your PSP
Back to top
View user's profile Send private message
JumpR



Joined: 10 Feb 2008
Posts: 25

PostPosted: Fri Mar 14, 2008 12:29 am    Post subject: Reply with quote

moonlight wrote:
Try to unassign before loading the modules.

Not working :( Do I need a little trick because I'm trying to format from the DDC memstick? Like disabling flashemu?

Pirata Nervo wrote:
@JumpR, create a kernel prx where you can load the function from (mode 0x1006) and then use usermode in your main application.

Why... As I said, I'm running this from my DDC stick, using the 1.50 kernel, and in 1.50 you can load in kernel mode perfectly fine, even the original DDC resurrection.elf is kernel mode.

It gets worse, I reversed a patch from DDC:
Code:
      if((!bSlim) && (!strcmp(Modules[i], "ms0:/kd/nand_updater.prx"))){
         sceKernelDelayThread(4*1000*1000);
         u32 *mod = (u32 *)sceKernelFindModuleByName("sceNAND_Updater_Driver");
         u32 text_addr = *(mod+27);
         _sh(0xac60, text_addr+0xE4E);
         sceKernelDcacheWritebackAll();
         sceKernelIcacheClearAll();
      }

However, it can't find sceNAND_Updater_Driver, atleast, that's what I think, as it crashes at that line. It's executed right after loading ms0:/kd/nand_updater.prx ;)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group