Attempting to run my first program: 0x80020148

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

Moderators: cheriff, TyRaNiD

Post Reply
G43L
Posts: 8
Joined: Sat Nov 07, 2009 8:03 pm

Attempting to run my first program: 0x80020148

Post by G43L »

Hi,

I use devKitPSP release 11 to compile the following program:

Code: Select all

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

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

/* 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 main&#40;int argc, char **argv&#41;
&#123;
    pspDebugScreenInit&#40;&#41;;
    SetupCallbacks&#40;&#41;;

    while &#40;1&#41;
    &#123;
        pspDebugScreenPrintf&#40;"Hello PSP!"&#41;;
        sceDisplayWaitVblankStart&#40;&#41;;
    &#125;

    sceKernelSleepThread&#40;&#41;;

    return 0;
&#125;

//  EOF
Then I use make_eboot.bat to create EBOOT.PBP:

Code: Select all

"C&#58;\devkitPSP\bin\mksfo.exe" Hello title.sfo
"C&#58;\devkitPSP\bin\psp-fixup-imports.exe" hello.elf
"C&#58;\devkitPSP\bin\psp-strip.exe" hello.elf -o stripped.elf
"C&#58;\devkitPSP\bin\pack-pbp.exe" EBOOT.PBP title.sfo NULL NULL NULL NULL NULL stripped.elf NULL
del title.sfo
del stripped.elf
When I try to load the program with PSPLink 3.0 oe on CFW 5.50 GEN-D2 on a PSP 1000 I obtain this:

Code: Select all

host0&#58;/> EBOOT.PBP
Failed to Load/Start module 'host0&#58;/EBOOT.PBP' Error&#58; 0x80020148
host0&#58;/>

Code: Select all

host0&#58;/src/> d ./EBOOT.PBP
PSPLink USB GDBServer &#40;c&#41; 2k7 TyRaNiD
host0&#58;/src/> Invalid ELF magic
What can I do?

Thanks in advance,
G43L
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

With psplink you start a .prx not an EBOOT.PBP .
A prx file is like a exe file on windows. the EBOOT.PBP is just a container with some additional info.

in your makefile you must have the line:

BUILD_PRX=1

so the compiler will create a prx.

PS.
you are using a old toolchain.
download minpspw and remove devkitPRO to get a more up to date one.
http://minpspw.sourceforge.net/

Code: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
G43L
Posts: 8
Joined: Sat Nov 07, 2009 8:03 pm

Post by G43L »

Hi,

I've uninstalled devkitPSP and installed minpspw v0.9.5

With the following in the Makefile:

Code: Select all

BUILD_PRX=1
...
PSPSDK = $&#40;shell psp-config --pspsdk-path&#41;
include $&#40;PSPSDK&#41;/lib/build_prx.mak
I obtain the warning message:

Code: Select all

warning||cannot find entry symbol module_start; defaulting to 0000000000000000|
and undefined references errors...


Thanks for any help,
G43L
G43L
Posts: 8
Joined: Sat Nov 07, 2009 8:03 pm

[SOLVED] !!!

Post by G43L »

Hi,

I've solved all my problems...

Image


Here is the Makefile I use

Code: Select all

TARGET = hello
OBJS = hello.o snprintf.o

PSP_ONLY = 1

# Define to build this as a prx &#40;instead of a static elf&#41;
BUILD_PRX = 1
# Define the name of our custom exports &#40;minus the .exp extension&#41;
PRX_EXPORTS = exports.exp

USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1

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

LIBDIR =

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

LIBS += -lpspge_driver -lpspgu
I'm also using http://www.ijs.si/software/snprintf/ as implementation of vsnprintf. I have just modified lines 535 to 541 of snprintf.c:

Code: Select all

#if defined&#40;NEED_SNPRINTF_ONLY&#41;
int portable_snprintf&#40;char *str, size_t str_m, const char *fmt, /*args*/ ...&#41; &#123;
#elif defined&#40;PSP_ONLY&#41;
int vsnprintf&#40;char *str, size_t str_m, const char *fmt, va_list ap&#41; &#123;
#else
int portable_vsnprintf&#40;char *str, size_t str_m, const char *fmt, va_list ap&#41; &#123;
#endif
Now I can start to modify QHACK for the PSP :~)

G43L
jojojoris
Posts: 255
Joined: Sun Mar 30, 2008 4:06 am

Post by jojojoris »

use include $(PSPSDK)/lib/build.mak instead of build_prx.mak

I don't exactly know the difference but it does some things to ensure that it will start properly.

in your main.c (or something) cou have to use
PSP_MODULE_INFO
PSP_MAIN_THREAD_ATTR
PSP_HEAP_SIZE_KB

Code: Select all

int main&#40;&#41;&#123;
     SetupCallbacks&#40;&#41;;
     makeNiceGame&#40;&#41;;
     sceKernelExitGame&#40;&#41;;
&#125;
G43L
Posts: 8
Joined: Sat Nov 07, 2009 8:03 pm

Post by G43L »

jojojoris wrote:use include $(PSPSDK)/lib/build.mak instead of build_prx.mak

I don't exactly know the difference but it does some things to ensure that it will start properly.

in your main.c (or something) cou have to use
PSP_MODULE_INFO
PSP_MAIN_THREAD_ATTR
PSP_HEAP_SIZE_KB
I've done all the changes and it is perfectly working. Thank you very much for the advises!

QHACK for the PSP:

Image

G43L
Post Reply