Starting with PSP homebrew


Host system: Debian GNU/Linux sid/testing x86
PSP: PSP Slim with a hacked 3.90M33-2 firmware

Required tools and libs

Prepare a place for the PSP development stuff:

mkdir -p $HOME/lib/pspdev

Make it available for your current session:

echo -e "export PSPDEV=~/lib/pspdev\nexport PATH=\$PATH:\$PSPDEV/bin" >> $HOME/.bashrc
bash

Get and install the toolchain:

svn co svn://svn.ps2dev.org/psp/trunk/psptoolchain
cd psptoolchain
./toolchain.sh

It’ll probably ask for some develpment packages, just look for them in apt, install them and run the last step again.

Get and install psp libraries

svn co svn://svn.ps2dev.org/psp/trunk/psplibraries
cd psplibraries
./libraries.sh

Ok, requirements installed

Hello world

main.cpp

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

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

#define printf pspDebugScreenPrintf 

/* 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 &gt;= 0) {
        sceKernelStartThread(thid, 0, 0);
    }

    return thid;
}

int main() {
    pspDebugScreenInit();
    SetupCallbacks();
    printf("Hello World");
    sceKernelSleepThread();
    return 0;
}

Makefile

TARGET = hello
OBJS = main.o

CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Hello World

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

Ok, now compile it

saladino@Zack:~/projects/pspstuff$ make
psp-g++ -I. -I/home/saladino/lib/pspdev/psp/sdk/include -O2 -G0 -Wall -I. -I/home/saladino/lib/pspdev/psp/sdk/include -O2 -G0 -Wall -fno-exceptions -fno-rtti -D_PSP_FW_VERSION=150   -c -o main.o main.cpp
psp-gcc -I. -I/home/saladino/lib/pspdev/psp/sdk/include -O2 -G0 -Wall -D_PSP_FW_VERSION=150  -L. -L/home/saladino/lib/pspdev/psp/sdk/lib   main.o  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o hello.elf
psp-fixup-imports hello.elf
mksfo 'Hello World' PARAM.SFO
psp-strip hello.elf -o hello_strip.elf
pack-pbp EBOOT.PBP PARAM.SFO NULL  \
		NULL NULL NULL  \
		NULL  hello_strip.elf NULL
[0]        408 bytes | PARAM.SFO
[1]          0 bytes | NULL
[2]          0 bytes | NULL
[3]          0 bytes | NULL
[4]          0 bytes | NULL
[5]          0 bytes | NULL
[6]      77508 bytes | hello_strip.elf
[7]          0 bytes | NULL
rm -f hello_strip.elf

That’s all, now copy it to the corresponding folder in your memory stick, in my case this was psp/game380/helloworld/EBOOT.PBP

3 Responses to Starting with PSP homebrew

  1. Steven Meyer says:

    Great tutorial, but wordpress seems to have stripped the tags in main.c’s includes … maybe have it as a download?

    Also Ubuntu has slightly different directions!

  2. blogging and site-building…

    […]Starting with PSP homebrew « Arkaitzj’s Blog[…]…

  3. Hey! Someone in my Facebook group shared this site with us so I came
    to look it over. I’m definitely enjoying the information. I’m
    book-marking and will be tweeting this to my followers! Wonderful blog and wonderful style and design.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: