[SOLVED] How to launch .ELF files in 3.90 M33-3

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

Moderators: cheriff, TyRaNiD

Post Reply
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

[SOLVED] How to launch .ELF files in 3.90 M33-3

Post by vista200 »

Hi there!

I'm having a problem with loading ELF files. When I launch my program under 1.50 with TimeMachine, it works. If I try to run it from 3.90 M33-3 with 1.50-Kernel, sceKernelLoadExec returns -2147352247. I'm using the elf_template copied to test.elf in the root of the Memory Stick. Here's the source code:

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>

PSP_MODULE_INFO&#40;"ELF", 0, 1, 1&#41;;

#define printf pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41; &#123;
sceKernelExitGame&#40;&#41;;
return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41; &#123;
int cbid;

cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
sceKernelRegisterExitCallback&#40;cbid&#41;;

sceKernelSleepThreadCB&#40;&#41;;

return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41; &#123;
int thid = 0;

thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
if&#40;thid >= 0&#41; &#123;
sceKernelStartThread&#40;thid, 0, 0&#41;;
&#125;

return thid;
&#125;

int startELF&#40;char *path&#41; &#123;
	struct SceKernelLoadExecVSHParam param;
	memset&#40;&param, 0, sizeof&#40;param&#41;&#41;;
	if &#40;!param.key&#41;
	param.key = "game";
	param.size = sizeof&#40;param&#41;;
	param.args = strlen&#40;path&#41;+1;
	param.argp = path;
	int elf = sceKernelLoadExec&#40;path, NULL&#41;;
	return elf; 
&#125;

int main&#40;&#41; &#123;
	pspDebugScreenInit&#40;&#41;;
	SetupCallbacks&#40;&#41;;
	printf&#40;"Loading...\n"&#41;;
	printf&#40;"%i", startELF&#40;"ms0&#58;/test.elf"&#41;&#41;;
	sceKernelSleepThread&#40;&#41;;
return 0;
&#125;

Code: Select all

TARGET = elf
OBJS = main.o

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

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = ELF
PSP_FW_VERSION = 150

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build.mak
I've tried already a lot of things, such as starting my program in user and kernel mode. Also I've used functions like sctrlKernelLoadExecVSHMs2, but they error out with different errors.

Thanks in advantage,
vista200
Last edited by vista200 on Wed Apr 09, 2008 3:26 am, edited 1 time in total.
jas0nuk
Posts: 137
Joined: Thu Apr 27, 2006 8:00 am

Post by jas0nuk »

-2147352247
= 0x80020149
= SCE_KERNEL_ERROR_ILLEGAL_PERM_CALL

Are you sure it's running in the 1.50 kernel?
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

Yes, thats it!

Post by vista200 »

Thanks!

Copying my EBOOT to GAME150 folder works. When I launch it then, the ELF loads correctly.

Again, thanks for your help!
vista200
phobox
Posts: 127
Joined: Mon Mar 24, 2008 6:22 pm

Post by phobox »

Code: Select all

int startELF&#40;char *path&#41; &#123; 
   struct SceKernelLoadExecVSHParam param; 
   memset&#40;&param, 0, sizeof&#40;param&#41;&#41;; 
   if &#40;!param.key&#41; 
   param.key = "game"; 
   param.size = sizeof&#40;param&#41;; 
   param.args = strlen&#40;path&#41;+1; 
   param.argp = path; 
   int elf = sceKernelLoadExec&#40;path, NULL&#41;; 
   return elf; 
&#125; 
Why are you using SceKernelLoadExecVSHParam if you don't really use it? you pass NULL to sceKernelLoadExec....
Ciao! from Italy
vista200
Posts: 13
Joined: Wed Mar 19, 2008 7:55 am

This was just a test

Post by vista200 »

Hi there!

This was just to see whether this would work. But as stated above, there was another mistake.

Greets from germany!
vista200
Post Reply