forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Attempting to run my first program: 0x80020148

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
G43L



Joined: 07 Nov 2009
Posts: 12

PostPosted: Tue Nov 10, 2009 7:23 am    Post subject: Attempting to run my first program: 0x80020148 Reply with quote

Hi,

I use devKitPSP release 11 to compile the following program:

Code:

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

PSP_MODULE_INFO("Hello", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common)
{
    sceKernelExitGame();

    return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp)
{
    int cbid;

    cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
    sceKernelRegisterExitCallback(cbid);

    sceKernelSleepThreadCB();

    return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
    int thid = 0;

    thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
    if (thid >= 0)
    {
        sceKernelStartThread(thid, 0, 0);
    }

    return thid;
}

int main(int argc, char **argv)
{
    pspDebugScreenInit();
    SetupCallbacks();

    while (1)
    {
        pspDebugScreenPrintf("Hello PSP!");
        sceDisplayWaitVblankStart();
    }

    sceKernelSleepThread();

    return 0;
}

//  EOF


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

Code:

"C:\devkitPSP\bin\mksfo.exe" Hello title.sfo
"C:\devkitPSP\bin\psp-fixup-imports.exe" hello.elf
"C:\devkitPSP\bin\psp-strip.exe" hello.elf -o stripped.elf
"C:\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:

host0:/> EBOOT.PBP
Failed to Load/Start module 'host0:/EBOOT.PBP' Error: 0x80020148
host0:/>


Code:

host0:/src/> d ./EBOOT.PBP
PSPLink USB GDBServer (c) 2k7 TyRaNiD
host0:/src/> Invalid ELF magic


What can I do?

Thanks in advance,
G43L
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Nov 10, 2009 8:04 am    Post subject: Reply with quote

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:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
G43L



Joined: 07 Nov 2009
Posts: 12

PostPosted: Tue Nov 10, 2009 5:38 pm    Post subject: Reply with quote

Hi,

I've uninstalled devkitPSP and installed minpspw v0.9.5

With the following in the Makefile:

Code:

BUILD_PRX=1
...
PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build_prx.mak


I obtain the warning message:

Code:

warning||cannot find entry symbol module_start; defaulting to 0000000000000000|


and undefined references errors...


Thanks for any help,
G43L
Back to top
View user's profile Send private message
G43L



Joined: 07 Nov 2009
Posts: 12

PostPosted: Tue Nov 10, 2009 8:23 pm    Post subject: [SOLVED] !!! Reply with quote

Hi,

I've solved all my problems...




Here is the Makefile I use

Code:

TARGET = hello
OBJS = hello.o snprintf.o

PSP_ONLY = 1

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

USE_KERNEL_LIBC = 1
USE_KERNEL_LIBS = 1

INCDIR =
CFLAGS = -DNOEXIT -DFPM_MIPS -O2 -G0 -Wall -fno-pic
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =

PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/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:

#if defined(NEED_SNPRINTF_ONLY)
int portable_snprintf(char *str, size_t str_m, const char *fmt, /*args*/ ...) {
#elif defined(PSP_ONLY)
int vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
#else
int portable_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap) {
#endif


Now I can start to modify QHACK for the PSP :~)

G43L
Back to top
View user's profile Send private message
jojojoris



Joined: 30 Mar 2008
Posts: 261

PostPosted: Tue Nov 10, 2009 11:17 pm    Post subject: Reply with quote

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:
int main(){
     SetupCallbacks();
     makeNiceGame();
     sceKernelExitGame();
}
Back to top
View user's profile Send private message
G43L



Joined: 07 Nov 2009
Posts: 12

PostPosted: Thu Nov 12, 2009 5:16 am    Post subject: Reply with quote

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:



G43L
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group