error 0x80020148 when starting homebrew

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

Moderators: cheriff, TyRaNiD

Post Reply
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

error 0x80020148 when starting homebrew

Post by sauron_le_noir »

I try to port a Nintendo DS emulator to the psp it compile now without error
generating a EBOOT.BPB but when starting the emulator i've got this
0x80020148 ----> ,unsupportedPRXtype
My psp is a slim running CF4.01M33-2

here is my makefile

Code: Select all

TARGET = pspds
OBJS = armcpu.o fs-linux.o opengl_collector_3Demu.o arm_instructions.o render3D.o bios.o gl_vertex.o ROMReader.o cflash.o GPU.o saves.o cp15.o matrix.o sndsdl.o ctrlssdl.o mc.o SPU.o debug.o MMU.o thumb_instructions.o Disassembler.o NDSSystem.o wifi.o FIFO.o main.o psp_main.o

PSPBIN = $(shell psp-config --psp-prefix)/bin
SDL_CONFIG = $(PSPBIN)/sdl-config
DEFAULT_CFLAGS = $(shell $(SDL_CONFIG) --cflags)
INCDIR =
CFLAGS = -O2 -G0 -Wall $(DEFAULT_CFLAGS)
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BUILD_PRX = 1
PSP_FW_VERSION = 401
PSP_LARGE_MEMORY = 1
DS_EMULATOR_VERSION=1.0.0

LIBDIR =
LIBS +=  -lpspwlan -lpsppower -lSDL_image -lSDL -lpng -ljpeg -lpspaudio -lpspgu -lpsphprm -lz -lm -lstdc++ -lGL -lpspirkeyb -lpsppower -lpspvfpu -lpsprtc
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = DS-EMULATOR-v$(DS_EMULATOR_VERSION)
PSP_EBOOT_ICON= ds-emulator.png
PSP_EBOOT_PIC1 = ds-emulator-pic.png

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Make sure you main file has the module info/et all set for a user-mode prx, like this

Code: Select all

PSP_MODULE_INFO("MyProgram", 0, PSP_VERS, PSP_REVS);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-256);
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

it has

Code: Select all



#include <stdio.h>
#include <zlib.h>
#include "SDL.h"

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

#include <pspwlan.h>
#include <pspkernel.h>
#include <psppower.h>

#include <stdlib.h>
#include <stdio.h>



extern int SDL_main&#40;int argc, char *argv&#91;&#93;&#41;;



PSP_MODULE_INFO&#40;"PSPNDS", PSP_MODULE_USER, 1, 1&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER|PSP_THREAD_ATTR_VFPU&#41;;
PSP_HEAP_SIZE_KB&#40;-256&#41;;
;

int sdl_psp_exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
  sceKernelExitGame&#40;&#41;;
  return 0;
&#125;

int sdl_psp_callback_thread&#40;SceSize args, void *argp&#41;
&#123;
  int cbid;
  cbid = sceKernelCreateCallback&#40;"Exit Callback", 
               sdl_psp_exit_callback, NULL&#41;;
  sceKernelRegisterExitCallback&#40;cbid&#41;;

  sceKernelSleepThreadCB&#40;&#41;;
  return 0;
&#125;

int sdl_psp_setup_callbacks&#40;void&#41;
&#123;
  int thid = 0;

  sceCtrlSetSamplingCycle&#40;0&#41;;
  sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_ANALOG&#41;;

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



extern void _fini&#40;void&#41;;

#ifdef main
#undef main
#endif

void
user_thread&#40;SceSize argss, void *argp&#41;
&#123;
  char *ptr&#91;&#93; = &#123; "emul","ms0&#58;/PSP/GAME/DS/TEST.NDS",NULL &#125;;
  int args = 2;

  sdl_psp_setup_callbacks&#40;&#41;;
  
pspDebugScreenPrintf&#40;"\nBefore SDL !\n"&#41;;
  
// SDL_main&#40;args, ptr&#41;; 
&#125;

int 
main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
  int user_thid;

  pspDebugScreenInit&#40;&#41;;



  /* Functions registered with atexit&#40;&#41; are called in reverse order, so make
     sure that we register sceKernelExitGame&#40;&#41; first, so that it's called last. */
  atexit&#40;sceKernelExitGame&#41;;
  /* Make sure that _fini&#40;&#41; is called before returning to the OS. */
  atexit&#40;_fini&#41;;


  pspDebugScreenPrintf&#40;"\nLaunch main thread !\n"&#41;;

  sceKernelDelayThread&#40;1000000&#41;; 

  user_thid = sceKernelCreateThread&#40; "user_thread", 
     &#40;SceKernelThreadEntry&#41;user_thread, 0x11, 256*1024, PSP_THREAD_ATTR_USER, 0 &#41;;
  if&#40;user_thid >= 0&#41; &#123;
    sceKernelStartThread&#40;user_thid, 0, 0&#41;;
    sceKernelWaitThreadEnd&#40;user_thid, NULL&#41;;
  &#125;

  /* Delay 2.5 seconds before returning to the OS. */
  sceKernelDelayThread&#40;2500000&#41;;

  return 0;
&#125;
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

You don't need to create a user thread - you ARE a user thread. Remove that code. That code was clearly from a project that used to run in kernel mode, so I'd guess the error is due to some other kernel-mode function still in the code. One common one you saw in a lot of older apps set the general exception vector to trap crashes. That doesn't work in 3.xx/4.xx without a special kernel-mode prx. If you look at the dosbox thread, you'll find such a prx if you want exception trapping in your app.
Post Reply