mediumgauge
Developer
Lead me to the source code, by pasting link, and I will try to implement flashing feature in kernel3.
Hey again, just saw something in regards to writing to flash0 on lan.st if you're interested. Only one thing though, not sure if it's for 3.XX/4.XX or for 1.50. Any how take a look at this:
http://lan.st/showpost.php?p=12084&postcount=2 the original thread was here:
http://lan.st/showthread.php?t=1804
mediumgauge, I've find a solution for the write permission in the Slims ( I've used it in Xplora ), you have to set the flag at 0x800 and build an external kernel mode prx and import the assign function!
supporting to write flash0 on kernel3 is not easy, I tried a lot but not succeed.
calculating folder size, I will bind the feature in the next (4.5) release.
#include <pspkernel.h>
#include <pspthreadman.h>
int __psp_free_heap(void);
PSP_MODULE_INFO("Password", 0x800, 3, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH);
PSP_HEAP_SIZE_KB(2048);
int main_thread(SceSize args, void *argp)
{
Config cfg;
int result;
result = sceIoUnassign("flash0:");
if(result < 0)
{
printf("\nError in unassign flash0.");
}
else
{
result = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
if(result < 0)
{
printf("\nError in assigning flash0 for write.");
}
else
{
SceUID fp;
fp = sceIoOpen("flash0:/buttons.ini", PSP_O_WRONLY|PSP_O_TRUNC|PSP_O_CREAT, 0777);
if(fp < 0)
{
printf("\nError writing flash0:/buttons.ini.");
}
else
{
sceIoWrite(fp, &cfg, sizeof(cfg));
sceIoClose(fp);
printf("\nPassword written successfully.");
}
}
}
}
int module_start(SceSize args, void *argp)
{
SceUID th;
th = sceKernelCreateThread("main_thread", main_thread, 0x11, 0x1000, 0, NULL);
if (th >= 0)
{
sceKernelStartThread(th, args, argp);
}
return 0;
}
int module_stop(SceSize args, void *argp)
{
__psp_free_heap();
return 0;
}
TARGET = flash0
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = exports.exp
#USE_KERNEL_LIBC=1
#USE_KERNEL_LIBS=1
PSP_FW_VERSION = 390
PSP_LARGE_MEMORY = 0
LIBDIR =
LIBS =
LDFLAGS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak
I've been hoping to see flash0 write support in 3.XX Kernel for a long time.
I don't know what problems you're facing but this is how I am writing the config file in Lockdown v3.
Here is the code I'm using.
The only thing you have to do is reassign flash0 in write mode like this.
This can only be done inside a VSH mode module (0x800 mode).
My whole program is VSH mode so I am performing the reassign and file writing in the same place.
But if Filer has to run in kernel mode, then all you have to do is just create another VSH mode PRX which contains the code just to reassign flash0. Once you load and start that PRX, you can write to flash0 from the main Filer code.
Code:#include <pspkernel.h> #include <pspthreadman.h> int __psp_free_heap(void); PSP_MODULE_INFO("Password", 0x800, 3, 0); PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH); PSP_HEAP_SIZE_KB(2048); int main_thread(SceSize args, void *argp) { Config cfg; int result; result = sceIoUnassign("flash0:"); if(result < 0) { printf("\nError in unassign flash0."); } else { result = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0); if(result < 0) { printf("\nError in assigning flash0 for write."); } else { SceUID fp; fp = sceIoOpen("flash0:/buttons.ini", PSP_O_WRONLY|PSP_O_TRUNC|PSP_O_CREAT, 0777); if(fp < 0) { printf("\nError writing flash0:/buttons.ini."); } else { sceIoWrite(fp, &cfg, sizeof(cfg)); sceIoClose(fp); printf("\nPassword written successfully."); } } } } int module_start(SceSize args, void *argp) { SceUID th; th = sceKernelCreateThread("main_thread", main_thread, 0x11, 0x1000, 0, NULL); if (th >= 0) { sceKernelStartThread(th, args, argp); } return 0; } int module_stop(SceSize args, void *argp) { __psp_free_heap(); return 0; }
The makefile for the VSH module does not need the kernel LIBC and kernel LIBS.
Code:TARGET = flash0 OBJS = main.o INCDIR = CFLAGS = -O2 -G0 -Wall CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) BUILD_PRX = 1 PRX_EXPORTS = exports.exp #USE_KERNEL_LIBC=1 #USE_KERNEL_LIBS=1 PSP_FW_VERSION = 390 PSP_LARGE_MEMORY = 0 LIBDIR = LIBS = LDFLAGS = PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build_prx.mak
Hoping to flash0 writing in v5.6 8)
#include <pspkernel.h>
#include <stdio.h>
PSP_MODULE_INFO("F0MOUNT", 0x800, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH);
int main(void)
{
sceKernelSleepThread();
return 0;
}
int f0mount(int mode)
{
int result;
FILE *fp;
fp = fopen("ms0:/log.txt", "a");
fprintf(fp, "writing start!\n");
fclose(fp);
result = sceIoUnassign("flash0:");
fp = fopen("ms0:/log.txt", "a");
fprintf(fp, "result2:%x\n", result);
fclose(fp);
result = sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", mode ? IOASSIGN_RDWR : IOASSIGN_RDONLY, NULL, 0);
fp = fopen("ms0:/log.txt", "a");
fprintf(fp, "result3:%x\n", result);
fclose(fp);
return 0;
}
writing start!
result2:8001000d
result3:80020326
I don't know what "8001000d" mean, but "80020326" means "SCE_KERNEL_ERROR_ALIAS_USED", probably it means "this alias is already used since you failed to unassign flash0".
Any idea to solve this?
BUILD_PRX = 1
PRX_EXPORTS = exports.exp
....
....
....
[B]include $(PSPSDK)/lib/build_prx.mak[/B]
I found the reason of few memory - shamefully easy reason.
Adding one line "PSP_HEAP_SIZE_KB(1024*20); //20MB" in source code, it works.
Torch, thank you a lot. I can release flash0-accessable kernel3 Filer in next time.
Torch, thank you for details.
I don't want to separate Filer.
I succeeded to compile & run Filer, by upgrading PSPSDK, but there is a problem that in "BUILD_PRX" mode malloc() returns NULL only allocating 100kbytes (100,812bytes).
Filer cannot run in such few space. I have to solve it to make kernel3 to access flash0.
Do not use BUILD_PRX for EBOOT. Thats only for creating standalone PRX to be loaded by other applications.
But in your sample flash0.zip, There is a line in Makefile:
>BUILD_PRX = 1