Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff , TyRaNiD
G43L
Posts: 8 Joined: Sat Nov 07, 2009 8:03 pm
Post
by G43L » Tue Nov 10, 2009 7:23 am
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("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: Select all
"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: Select all
host0:/> EBOOT.PBP
Failed to Load/Start module 'host0:/EBOOT.PBP' Error: 0x80020148
host0:/>
Code: Select all
host0:/src/> d ./EBOOT.PBP
PSPLink USB GDBServer (c) 2k7 TyRaNiD
host0:/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 » Tue Nov 10, 2009 8:04 am
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(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
G43L
Posts: 8 Joined: Sat Nov 07, 2009 8:03 pm
Post
by G43L » Tue Nov 10, 2009 5:38 pm
Hi,
I've uninstalled devkitPSP and installed minpspw v0.9.5
With the following in the Makefile:
Code: Select all
BUILD_PRX=1
...
PSPSDK = $(shell psp-config --pspsdk-path)
include $(PSPSDK)/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
Post
by G43L » Tue Nov 10, 2009 8:23 pm
Hi,
I've solved all my problems...
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 (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: Select all
#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
jojojoris
Posts: 255 Joined: Sun Mar 30, 2008 4:06 am
Post
by jojojoris » Tue Nov 10, 2009 11:17 pm
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(){
SetupCallbacks();
makeNiceGame();
sceKernelExitGame();
}
G43L
Posts: 8 Joined: Sat Nov 07, 2009 8:03 pm
Post
by G43L » Thu Nov 12, 2009 5:16 am
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