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("MyAppName", 0x800, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_VSH);
#define printf pspDebugScreenPrintf
int status;
int exist = 0;
char write_buffer[128*1024];
void check(const char* zFile) {
int fd3;
fd3 = sceIoOpen(zFile, PSP_O_RDONLY, 0);
if(fd3 < 0) {
exist = 0;
}else{
exist = 1;
}
sceIoClose(fd3);
}
int write_file(const char *readpath, const char *writepath) {
check(readpath);
if(exist == 1) {
int fdin;
int fdout;
fdin = sceIoOpen(readpath, PSP_O_RDONLY, 0777);
if(fdin >= 0) {
int bytesRead = 1;
fdout = sceIoOpen(writepath, PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
bytesRead = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
while((bytesRead > 0) && (fdout >= 0)) {
sceIoWrite(fdout, write_buffer, bytesRead);
bytesRead = sceIoRead(fdin, write_buffer, sizeof(write_buffer));
}
if(fdout >= 0) {
sceIoClose(fdout);
}
if(fdin >= 0) {
sceIoClose(fdin);
}
}
return 1;
}else{
return 0;
}
}
void Reassign() {
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
}
int main(void) {
pspDebugScreenInit();
pspDebugScreenClear();
Reassign();
status = write_file("./test.txt","flash0:/vsh/resource/test.txt");
if (status == 0) {
printf("Source File Does Not Exist...\n");
}
if (status == 1) {
printf("Flash Complete...\n");
}
printf("Exiting...\n");
sceKernelDelayThread(1000000);
sceKernelExitGame();
return 0;
}
makefile
Code: Select all
TARGET = FlasherExample
OBJS = main.o
INCDIR = ../include
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -c
LIBDIR = ../lib
LDFLAGS =
LIBS = -lpspkubridge
PSP_FW_VERSION = 371
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = FlasherExample
BUILD_PRX = 1
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
-edit-
I did not need all those headers but too lazy to remove them,