copy file to Flash0

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

copy file to Flash0

Post by PSPfreak! »

i was searching around and all i could find was to copy files, may i be pointed in the right direction on how to copy a file from the memorystick to flash because these havent worked for me. when it flashes stuff like .bmp's it doesnt flash :(

Code: Select all

int fileCopy(char* inSrc, char* inDest) {
     SceUID tempSrc = sceIoOpen(inSrc, PSP_O_RDONLY, 0777);
     if(!tempSrc)
          return -1;
     SceUID tempDest = sceIoOpen(inDest, PSP_O_WRONLY | PSP_O_CREAT, 0777);
     if(!tempDest) {
          sceIoClose(tempSrc);
          return -2;
     }

     char tempData[1024];
     int tempRead = sceIoRead(tempSrc, tempData, 1024);
     int tempWritten;

     while(tempRead > 0) {
          tempWritten = sceIoWrite(tempDest, tempData, tempRead);
          if(tempWritten != tempRead) {
               sceIoClose(tempDest);
               sceIoClose(tempSrc);
               sceIoRemove(inDest);
               return -3;
          }
          tempRead = sceIoRead(tempSrc, tempData, 1024);

     }

     sceIoClose(tempDest);
     sceIoClose(tempSrc);

     return 1;
}

Code: Select all

void CopyExecute(const char* zFileSrc , const char* zFileDest) 
{
	check(zFileSrc);

	if (exist == 1)
	{
		int fd1,fd2,len;
 
		fd1 = sceIoOpen(zFileSrc, PSP_O_RDONLY, 0);
		fd2 = sceIoOpen(zFileDest,PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
       
		if&#40;fd1 < 0&#41;
       	&#123;
         	doBlit&#40;"Error &#58; some files are missing."&#41;;
		&#125;
		else
		&#123;
			while&#40;1&#41; 
			&#123;
      				len = sceIoRead&#40;fd1, buf, BUFSIZE&#41;;
      				if &#40;len == 0&#41; break;
      				sceIoWrite&#40;fd2,buf,len&#41;;
   			&#125;
		&#125;
		sceIoClose&#40;fd1&#41;;
		sceIoClose&#40;fd2&#41;;
	&#125;
	else
	&#123;
		printf&#40;"Source file does not exist."&#41;;
	&#125;
&#125;
thanks
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

If you'r codiing on 3.71 kernel see here (no solution yet) => http://forums.ps2dev.org/viewtopic.php? ... ee9fb45f26
.::Albandu51::.
Posts: 12
Joined: Thu Oct 04, 2007 12:33 am

Post by .::Albandu51::. »

Yes its good that someone would find a solution and shows.

Trad by Google xD
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

sorry, but im actually using the 1.50 kernel (i think)
Pyridoxine
Posts: 2
Joined: Sat Jul 28, 2007 6:11 am

Post by Pyridoxine »

Here you go... This is Flashmod it's like the second Flasher to come out... It's open source and the Write Function for it should still work...

http://www.nobis-development.com/flashmod.php
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

This doesn't sole the 3.71 fw problem :/
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

Cpasjuste wrote:This doesn't sole the 3.71 fw problem :/
yea but i really was looking for a 1.50 kernel app, so thanks Pyridoxine, i'll see if it will work
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

woohooooo it works thanks mate, umm... would you happen to know anything about were the 1.50 version is in flash becuase i would like to change it with letters in it. every time i try to decrypt something it comes up corrupt and when i try to hex-edit it, i cant find 1.50. grrrr

e.g. i want to change to something like this, just not these letters 1.50 AB, 1.50 CD

im useless ahaha
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

anybody!!!!! sorry for posting under this though. if i dont get any replies until tomorrow i'll put under a different thread, so sorry anywayz
Pyridoxine
Posts: 2
Joined: Sat Jul 28, 2007 6:11 am

Post by Pyridoxine »

You want to change your version number I'm guessing... That should be in...

flash0:\vsh\etc\version.txt

For 1.50 atleast... Later on they started to encrypt there Version number in:

flash0:\kn\vshctrl.prx
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

Pyridoxine wrote:You want to change your version number I'm guessing... That should be in...

flash0:\vsh\etc\version.txt

For 1.50 atleast... Later on they started to encrypt there Version number in:

flash0:\kn\vshctrl.prx
thx mate i'll give it a try now
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

Pyridoxine wrote:You want to change your version number I'm guessing... That should be in...

flash0:\vsh\etc\version.txt

For 1.50 atleast... Later on they started to encrypt there Version number in:

flash0:\kn\vshctrl.prx
ok it works.........but GRRRR when i try to flash the files they dont write/copy, i tried the codes i had before and this one

Code: Select all

void write_file&#40;const char *readpath, const char *writepath&#41;
&#123;
	int fdin;
	int fdout;

	fdin = sceIoOpen&#40;readpath, PSP_O_RDONLY, 0777&#41;;
	if&#40;fdin >= 0&#41;
	&#123;
		int bytesRead = 1;
		fdout = sceIoOpen&#40;writepath, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777&#41;;
		bytesRead = sceIoRead&#40;fdin, write_buffer, sizeof&#40;write_buffer&#41;&#41;;
		while&#40;&#40;bytesRead > 0&#41; && &#40;fdout >= 0&#41;&#41;
		&#123;
			sceIoWrite&#40;fdout, write_buffer, bytesRead&#41;;
			bytesRead = sceIoRead&#40;fdin, write_buffer, sizeof&#40;write_buffer&#41;&#41;;
		&#125;

		if&#40;fdout >= 0&#41;
		&#123;
			sceIoClose&#40;fdout&#41;;
		&#125;

		if&#40;fdin >= 0&#41;
		&#123;
			sceIoClose&#40;fdin&#41;;
		&#125;
	&#125;
&#125;
this works in the same app and flashes correctly, but doesnt flash after it finished with the other stuff.

any idea's

edit: btw im copying from ms0 to flash0 again
becus25
Posts: 2
Joined: Fri Aug 24, 2007 12:05 am

Post by becus25 »

On 3.7x the SceMode isn't 0777.
It is 511 or 0511 . I have reversed a small part of kernel addon but now I don't remember the value of SceMode.
Try with 511 or 0511.
Mashphealh
Posts: 18
Joined: Wed Nov 28, 2007 4:18 am

Post by Mashphealh »

becus25 wrote:On 3.7x the SceMode isn't 0777.
It is 511 or 0511 . I have reversed a small part of kernel addon but now I don't remember the value of SceMode.
Try with 511 or 0511.
And if you want run the app on vsh mode put the eboot on /psp/game/update . If you don't put it on them, the app should run on user mode. Try first run the app from UPDATE folder using vsh mode, if it works try then on user mode.

-=Double post=-
On 3.7x you can perfectly do dumps of files using the SceMode 0777 but with this mode won't work write files on the flash {folders (kd, module, etc..)}.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

Hum very cool for me (for a 3.71 file manager that is in my next homebrew). I was unable to write to flash0 with all (lot of) the test i have tried. I will try this tomorow.
Cpasjuste
Posts: 214
Joined: Sun May 29, 2005 8:28 am

Post by Cpasjuste »

even with the scemode set to 0511, i'm still unable to write to flash0 in my usermode homebrew (flash0 reassigned rw in kernel mode) while it's possible in the background via psplink :x
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

becus25 wrote:On 3.7x the SceMode isn't 0777.
It is 511 or 0511 . I have reversed a small part of kernel addon but now I don't remember the value of SceMode.
Try with 511 or 0511.
im actually using the 1.50 kernel btw if that changes anything lolz
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

Mashphealh wrote:
becus25 wrote: -=Double post=-
On 3.7x you can perfectly do dumps of files using the SceMode 0777 but with this mode won't work write files on the flash {folders (kd, module, etc..)}.
i had a look in Dark_AleX's / moonlight's 1.50 poc src and he had 0777 useing it to write stuff, and it works??
brin_vg
Posts: 17
Joined: Wed Oct 03, 2007 5:43 pm
Location: A pineapple, under the sea
Contact:

Post by brin_vg »

PSPfreak! wrote:
Mashphealh wrote:
becus25 wrote: -=Double post=-
On 3.7x you can perfectly do dumps of files using the SceMode 0777 but with this mode won't work write files on the flash {folders (kd, module, etc..)}.
i had a look in Dark_AleX's / moonlight's 1.50 poc src and he had 0777 useing it to write stuff, and it works??
That's for 1.50 kernel. 3.7X kernel the sceMode's different.
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

brin_vg wrote:i had a look in Dark_AleX's / moonlight's 1.50 poc src and he had 0777 useing it to write stuff, and it works??
That's for 1.50 kernel. 3.7X kernel the sceMode's different.[/quote]

im using the 1.50 kernel & the codes from the src, but they write only prx's & .bmp's...........i think the problem is with flashing the .dat & .txt
User avatar
PSPfreak!
Posts: 34
Joined: Wed Nov 14, 2007 10:57 pm

Post by PSPfreak! »

anybody know how to copy .dat & .txt to flash0 ????
Post Reply