//Written and developed only by Neo_The_User at the moment //DO NOT TEST NOR USE ANY OF THIS CODE //ALL UNTESTED! USE AT YOUR OWN RISK! //psp-config command not found when compiling under GCC. //Do not modify the #include order or names or the PSP will not read it. //Unknown reason why but it just works and thats all the matters at this time as far as #includes go //flash0 is what the PSP calls the Flashrom (NAND) //Makefile does not contain a specific directory. //Directory issues are in last line (of Makefile). I do not know where it is supposed to be. /lib/build.mak probably? WILD GUESS! //Save this file as main.c //In the next few weeks I will be porting this to 3.80 Firmware and up. Over 20 different variations will be released for M33 and non-M33. //I could use some help with the RDWR Functions. Where do I put them? #include #include #include #include #include #include #define printf pspDebugScreenPrintf PSP_MODULE_INFO("Version Flasher",0x1000,1,7); static char version[8]; int main_menu(int); void draw_menu(int); int file_copy(char[128],char[128]); int flash(char[8]); int isvalidtxt(char[128]); int isvaliddat(char[128]); //Exit callbacks and XMB preperation for application exit. -Neo_The_User //As seen at the bottom of this code. -Neo_The_User int exit_callback(int arg1,int arg2,void *common) { sceKernelExitGame(); return 0; } int CallbackThread(SceSize args,void *argp) { int cbid; cbid=sceKernelCreateCallback("Exit Callback",exit_callback,NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } int SetupCallbacks(void) { int thid=0; thid=sceKernelCreateThread("update_thread",CallbackThread,0x11,0xFA0,0,0); if(thid>=0) sceKernelStartThread(thid,0,0); return thid; } void draw_menu(int curopt) { int i; //Not Pandora serial. Similar to the PSP's service mode's serial -Neo_The_User u32 white=0x00FFFFFF; u32 black=0; char msgs[5][64]; pspDebugScreenClear(); sprintf(msgs[0],"1. Backup current version files"); sprintf(msgs[1],"2. Restore version from backup"); sprintf(msgs[2],"3. Flash version to 3.50"); sprintf(msgs[3],"4. Flash version to 3.52"); sprintf(msgs[4],"5. Exit Program"); //1.7 is version of the flasher. Not the firmware or anything to do with the PSP. -Neo_The_User pspDebugScreenClear(); printf("###Version Flasher 1.7 by download###\n"); // % represents varible. Do not use this application as a reliable source to detect your firmware. -Neo_The_User // % represents firmware version. Can detect firmware from 1.50 to 3.90 but will only work on 3.50 and 3.52. -Neo_The_User //Goal is to make it for non M33 3.80 and up. -Neo_The_User printf("Your current firmware version is %s\n",version); for(i=0;i<5;i++) { if(curopt-1==i) { //Default debugging screen. -Neo_The_User pspDebugScreenSetTextColor(black); pspDebugScreenSetBackColor(white); printf("%s",msgs[i]); pspDebugScreenSetTextColor(white); pspDebugScreenSetBackColor(black); printf("\n"); } else printf("%s\n",msgs[i]); } } int main_menu(int curopt) { int opt=curopt; char *buffer; int size; int f=sceIoOpen("flash0:/vsh/etc/version.txt",PSP_O_RDONLY,0777); size=sceIoLseek(f,0,SEEK_END); sceIoLseek(f,0,SEEK_SET); buffer=(char*)malloc(size+16); sceIoRead(f,buffer,size); sprintf(version,"%c.%c%c",buffer[80],buffer[82],buffer[84]); sceIoClose(f); draw_menu(opt); SceCtrlData pad; sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_DIGITAL); while(1) { //This gives the user the option to select Yes and No. -Neo_The_User //Questions will be made in further development. -Neo_The_User //PSP Gamepad button mapping. -Neo_The_User sceCtrlReadBufferPositive(&pad,1); sceKernelDelayThread(1500); //Down Direction Button. -Neo_The_User if(pad.Buttons&PSP_CTRL_DOWN) { if(opt<5) opt++; draw_menu(opt); sceKernelDelayThread(200000); } //Up Directional Button. -Neo_The_User else if(pad.Buttons&PSP_CTRL_UP) { if(opt>1) opt--; draw_menu(opt); sceKernelDelayThread(200000); } //Left and Right Directional Buttons. -Neo_The_User //Easiest part. -Neo_The_User else if(pad.Buttons&PSP_CTRL_CROSS) { return opt; } } } int file_copy(char srcf[128],char dstf[128]) { SceUID src,dst; char *buffer; int size=0; //Directory of flash0 /vsh/etc (cannot pinpoint exact location.) -Neo_The_User //Unable to access flash0 possible error code = 80020130 or 8001B002 if anything. -Neo_The_User //make flash0 writable -Neo_The_User //The command to make flash0 writeable is RDWR. -Neo_The_User //I am going to try and hit it a couple more times. Trial and error. -Neo-The_User if(sceIoUnassign("flash0:",IOASSIGN_RDWR,1)<0) { //First Attempt. If failed I made it try again. printf("Unable to access flash0\n"); return -1; } //This is second try. -Neo_The_User if(sceIoUnassign("flash0:", IOASSIGN_RDWR,0)<1 { printf("Can it access it this time?\n"); return -1; } if(sceIoAssign("flash0:","lflash0:0,0","flashfat0:",0,IOASSIGN_RDWR,0)<0) { //Third Attempt. If failed then further attempts to access flash0 will fail as well. //Don't bother running another check. -Neo_The_User printf("Unable to access flash0\n"); return -1; } //Critical IO. -Neo_The_User if((src=sceIoOpen(srcf,PSP_O_RDONLY,0777))<0) return -1; size=sceIoLseek(src,0,SEEK_END); sceIoLseek(src,0,SEEK_SET); buffer=(char*)malloc(size+16); if(sceIoRead(src,buffer,size)