3.71M33-4 and Flash0 access refused...

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

Moderators: cheriff, TyRaNiD

Post Reply
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

3.71M33-4 and Flash0 access refused...

Post by Red_Squirrel »

Hi, I'm an Italian developer (so sorry for my bad english :P).
I have a problem with a my PSP program. I can't access to Flash0 to write or delete files...
For example:

Code: Select all

#include <pspkernel.h>
#include <pspiofilemgr.h>
PSP_MODULE_INFO&#40;"TEST", 0, 1, 1&#41;;

int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
pspDebugScreenPrintf&#40;"Result"&#41;;

sceIoUnassign&#40;"flash0&#58;"&#41;; 
sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;",  IOASSIGN_RDWR, NULL, 0&#41;;

int ok = sceIoRemove&#40;"flash0&#58;/dog.txt"&#41;;
if &#40;ok<0&#41; pspDebugScreenPrintf&#40;"FAILURE"&#41;;
else pspDebugScreenPrintf&#40;"SUCCESS"&#41;;


return 0;
&#125;
Even this simple code does not work! O.O
I tried the same code with the Flash1 and it works good... but with Flash0 it does not work in any way...

Do anyone know why?! Please help me :(


P.s.: File "dog.txt" exists, because I created it on Flash0 before running program ;)
I'm on CF 3.71M33-4.
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

It will work if you do it like this,

Code: Select all

PSP_MODULE_INFO&#40;"MyAppName", 0x800, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

hibbyware wrote:It will work if you do it like this,

Code: Select all

PSP_MODULE_INFO&#40;"MyAppName", 0x800, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;
Thank you :)
But if I use that code, program works only if I insert it in PSP/GAME150...
I wanted to make it compatible with PSP Slim too.

Is there an alternative way, please? :(
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

Well that's how I've been doing it and it works on Fat / Slim,

I have been putting it in GAME on the Fat PSP,
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

hibbyware wrote:Well that's how I've been doing it and it works on Fat / Slim,

I have been putting it in GAME on the Fat PSP,
If I put the eboot in GAME (on my PSP Fat) I obtain the error: 80020148...
It works only in GAME150 (I'm using 3.71 Kernel from recovery).

This is my Makefile:

Code: Select all

TARGET = hello
OBJS = main.o

INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41;

LIBDIR =
LDFLAGS = 
LIBS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
It's wrong?
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Add BUILD_PRX = 1 to the makefile.

VSH elf's are rejected in 3.XX kernel.
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

This is my makefile,

I'm also using the 371SDK that came with 371m33-1

Code: Select all

TARGET = flasher4V1
OBJS = main.o cfg.o

INCDIR = ../include
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41; -c

LIBDIR = ../lib
LDFLAGS = 
LIBS = -lpspkubridge

PSP_FW_VERSION = 371

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = flasher4V1

BUILD_PRX = 1

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
Red_Squirrel
Posts: 11
Joined: Wed Oct 03, 2007 5:17 pm

Post by Red_Squirrel »

Sorry, but it still does not work.
If I insert the eboot in GAME150 program works very good.
But in GAME and GAME371 PSP gives me the error "Impossible to..... (80020148)"

My main.c is:

Code: Select all

#include <pspkernel.h>
#include <pspiofilemgr.h>
PSP_MODULE_INFO&#40;"TEST", 0x800, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;

int main&#40;&#41; &#123;
pspDebugScreenInit&#40;&#41;;
pspDebugScreenPrintf&#40;"Result"&#41;;

sceIoUnassign&#40;"flash0&#58;"&#41;; 
sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;",  IOASSIGN_RDWR, NULL, 0&#41;;

int ok = sceIoRemove&#40;"flash0&#58;/cane.txt"&#41;;
if &#40;ok<0&#41; pspDebugScreenPrintf&#40;"FAILURE"&#41;;
else pspDebugScreenPrintf&#40;"SUCCESS"&#41;;


return 0;
&#125;
And Makefile used is:

Code: Select all

TARGET = flasher4V1
OBJS = main.o

INCDIR = ../include
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41; -c

LIBDIR = ../lib
LDFLAGS =
LIBS = -lpspkubridge

PSP_FW_VERSION = 371

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = flasher4V1

BUILD_PRX = 1

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
It works only in GAME150.
My PSP is set on Kernel 3.71 from Recovery... :([/code]
hibbyware
Posts: 78
Joined: Wed Mar 28, 2007 10:29 am

Post by hibbyware »

This is a quick example of flashing a "test.txt" to "flash0:/vsh/resource"

It uses the 371SDK that came with 371m33-1

Works on 371m33 Slim/Fat,

Also works on 380m33 Fat but not yet tested on Slim but should work,

main.c

Code: Select all

#include <pspsdk.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <kubridge.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>

PSP_MODULE_INFO&#40;"MyAppName", 0x800, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_VSH&#41;;

#define printf    pspDebugScreenPrintf

int status;

int exist = 0;
char write_buffer&#91;128*1024&#93;;





	void check&#40;const char* zFile&#41; &#123;
		
		
		int fd3;
		
		fd3 = sceIoOpen&#40;zFile, PSP_O_RDONLY, 0&#41;;
		
		if&#40;fd3 < 0&#41; &#123;
			
			exist = 0;
			
		&#125;else&#123;
			
			exist = 1;
			
		&#125;
		
		sceIoClose&#40;fd3&#41;;
		
		
	&#125; 





	int write_file&#40;const char *readpath, const char *writepath&#41; &#123;
		
		
		check&#40;readpath&#41;;
		
		if&#40;exist == 1&#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;
			
			return 1;
			
		&#125;else&#123;
			
			return 0;
			
		&#125;
		
		
	&#125;





	void Reassign&#40;&#41; &#123;
		
		
		sceIoUnassign&#40;"flash0&#58;"&#41;;
		
		sceIoAssign&#40;"flash0&#58;", "lflash0&#58;0,0", "flashfat0&#58;", IOASSIGN_RDWR, NULL, 0&#41;;
		
		
	&#125;





	int main&#40;void&#41; &#123;
		
		
		pspDebugScreenInit&#40;&#41;;
		
		pspDebugScreenClear&#40;&#41;;
		
		Reassign&#40;&#41;;
		
		status = write_file&#40;"./test.txt","flash0&#58;/vsh/resource/test.txt"&#41;;
		
		if &#40;status == 0&#41; &#123;
			
			printf&#40;"Source File Does Not Exist...\n"&#41;;
			
		&#125;
		
		if &#40;status == 1&#41; &#123;
			
			printf&#40;"Flash Complete...\n"&#41;;
			
		&#125;
		
		printf&#40;"Exiting...\n"&#41;;
		
		sceKernelDelayThread&#40;1000000&#41;;
		
		sceKernelExitGame&#40;&#41;;
		
		
		
		
		return 0;
		
	&#125;


makefile

Code: Select all

TARGET = FlasherExample
OBJS = main.o

INCDIR = ../include
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41; -c

LIBDIR = ../lib
LDFLAGS = 
LIBS = -lpspkubridge

PSP_FW_VERSION = 371

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = FlasherExample

BUILD_PRX = 1

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak

-edit-

I did not need all those headers but too lazy to remove them,
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

Use this:
PSP_MODULE_INFO("Flasher", 0x1000, 1, 0);
PSP_MAIN_THREAD_ATTR(0);

You can run under kernel mode on 3.80 m33-4 (I tested it on 3.80 m33-4)

Tested on:
fat psp
3.80 m33-4
no 1.50 kernel add on
GAME folder
3.80 Homebrew Game folder on recovery.

AND
slim psp
3.71 m33-4
GAME folder
3.71 Homebrew Game folder on recovery
Post Reply