Problem loading a kmode app in 3.XX

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Problem loading a kmode app in 3.XX

Post by Aura »

First off, I want to apologise to anyone who thinks I should have added this to one of the current threads for loading 3.XX, but I decided to make my own instead of dragging up an old thread.

I'm having a problem loading a 3.XX .prx file, whenever I try and load it I get the 0x8002013C error, which is the library cannot be found, but I can assure you its definatly there. I'm not actually sure of the problem, and I've looked through some of the 3.XX examples, but I've found nothing thats helpful.

kmodeplugin.prx code

Code: Select all

#include <pspkernel.h>
#include <pspmodulemgr_kernel.h>

PSP_MODULE_INFO&#40;"KMode", 0x1006, 1, 1&#41;; 
PSP_MAIN_THREAD_ATTR&#40;0&#41;;

int unload_mod&#40;char module&#91;&#93;&#41;
&#123;
    u32 k1;
    
    k1 = pspSdkSetK1&#40;0&#41;;
    
    SceModule *mod;
    
    while&#40;&#40;mod = sceKernelFindModuleByName&#40;module&#41;&#41;&#41;
    &#123;
               sceKernelStopModule&#40;mod->modid, 0, NULL, NULL, NULL&#41;;
               sceKernelUnloadModule&#40;mod->modid&#41;;
    &#125;
    pspSdkSetK1&#40;k1&#41;;
    return 1;
&#125;

int module_start&#40;SceSize args, void *argp&#41; 
&#123; 
   return 0; 
&#125; 

int module_stop&#40;&#41; 
&#123; 
   return 0; 
&#125;
kmodeplugin.prx makefile

Code: Select all

TARGET = kmodeplugin
OBJS = main.o 

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

BUILD_PRX = 1 
PSP_FW_VERSION = 371
PRX_EXPORTS = kmode.exp 

USE_KERNEL_LIBC=1 
USE_KERNEL_LIBS=1 

LIBDIR = 
LDFLAGS = -mno-crt0 -nostartfiles 
LIBS = -lpspmodulemgr_kernel2


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

Code: Select all

# Define the exports for the prx 
PSP_BEGIN_EXPORTS 

# These four lines are mandatory &#40;although you can add other functions like module_stop&#41; 
# syslib is a psynonym for the single mandatory export. 
PSP_EXPORT_START&#40;syslib, 0, 0x8000&#41; 
PSP_EXPORT_FUNC_HASH&#40;module_start&#41; 
PSP_EXPORT_VAR_HASH&#40;module_info&#41; 
PSP_EXPORT_END 

PSP_EXPORT_START&#40;KMode, 0, 0x4001&#41; 
PSP_EXPORT_FUNC&#40;unload_mod&#41;
PSP_EXPORT_END 

PSP_END_EXPORTS
main code

Code: Select all

...
int unload_mod&#40;char module&#91;&#93;&#41;;

PSP_MODULE_INFO&#40;"Project4", 0x800, 0, 1&#41;;
PSP_HEAP_SIZE_KB&#40;12000&#41;;
PSP_MAIN_THREAD_ATTR&#40;PSP_THREAD_ATTR_USER&#41;;
...

int __main&#40;&#41;
&#123;   
    int check = 0;
    check = unload_mod&#40;module&#41;;
    ...
&#125;
main makefile

Code: Select all

	
TARGET = project4
BUILD_PRX = 1

PSP_FW_VERSION = 371

OBJS = ./KMode.o\
       ../source/main.o \
       ...
       

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

USE_KERNEL_LIBS = 0
USE_KERNEL_LIBC = 0


INCDIR =
LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lmad -lpspaudiolib -lpspaudio -lpspsystemctrl_user -lpspumd\
       -lpsppower -lbetalock -lpspwlan -lpspmodulemgr_kernel2 -lpsppower -lpspusb\
       -lpspusbstor -lpspdebug -lcprintf -lpspsystemctrl_user -lpspsystemctrl_kernel\
       -lpspumd_kernel -lpspmodulemgr_user2
       #-lpspkubridge
       
LDFLAGS += -mno-crt0

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



When the app boots up, it prints the error, and then loads the fatalerror function and I have no idea why, can anyone see anything immediately incorrect that may help?

Thanks.
-Aura
Last edited by Aura on Tue Oct 23, 2007 4:20 am, edited 1 time in total.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Well, one thing is you have 0x800 as the module info attrs in the main app, but there are only two values defined for apps:

Code: Select all

	PSP_MODULE_USER   = 0,
	PSP_MODULE_KERNEL = 0x1000,
For 3.xx/Slim programs, you should be using PSP_MODULE_USER. Most folks just use 0 or 0x1000 instead of the symbols. The 0x1006 is fine for the kernel prx.

Also, get rid of

Code: Select all

all&#58;
   mksfo 'Project 4' PARAM.SFO
   pack-pbp EBOOT.PBP PARAM.SFO NULL NULL NULL NULL NULL project4.prx NULL
 
It isn't necessary. Instead you use the extra targets:

Code: Select all

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Title goes here
PSP_EBOOT_ICON="icon0.png"
PSP_EBOOT_UNKPNG="pic0.png"
PSP_EBOOT_PIC1="pic1.png"
PSP_EBOOT_SND0="snd0.at3"
Just comment out the PSP_EBOOT thingys you don't use. Many folks only supply the icon0.png.
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

Ok, I've now changed it to user mode, and removed the EBOOT stuff (I didn't actually need any of it anyway, as its meant to be a .prx), but I'm still having the same problem as before, the module appears to load into memory, but doesn't start.

Also, I've been told that you can't unload modules in user, I was wondering if that was true, and if there was another way around it that didn't involve loading a kmode app?

Thanks.
-Aura
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

The only times I've gotten 8002013C is when it REALLY can't find the lib. Both times this happened, the path wasn't right, or the cwd wasn't set. At a guess, I'd say host: isn't assign when you run this. You could test this by changing it to something like ms0: and putting the prx there and see if it gets further.
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

I had that thought also, so I placed it in the root of the memstick and called it with ms0:/kmodeplugin.prx but to no avail, I mean you can see its there plain as day, and its being loaded into memory, because when I used "ml" on PSPLink I find the module loaded, but it appears to just not be starting correctly.

-Aura
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Another thing about the makefile is you specify the firmware as "2.50". Firmwares aren't specified with a decimal place. If you check, you'll find things like "150", "303", and most new stuff uses "371". Maybe that's conflicting with your trying to use pspkubridge. Since you ARE trying to use kubridge, you really should make that "371".
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

Ok, I changed that, same old problem, but I remembered an odd problem I was having previously with the main app not loading due to a single function, so I decided to remove all the functions leaving just the module_start and module_stop, and it now loads, so does this mean my problem is infact the way I've done each function, or not?

Thanks for being patient with me!

-Aura
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Aura wrote:Ok, I changed that, same old problem, but I remembered an odd problem I was having previously with the main app not loading due to a single function, so I decided to remove all the functions leaving just the module_start and module_stop, and it now loads, so does this mean my problem is infact the way I've done each function, or not?

Thanks for being patient with me!

-Aura
It's likely the libs being included based on dependencies from the code. For example, some of the libs are user mode and some are kernel. Like psppower vs psppower_driver. If I were to guess, I'd say you're using a user lib instead of a kernel lib. Kernel prx's cannot call user libs in 3.xx.
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

Well what do you know, it worked, I changed a couple of the libraries and it now loads, I'm now getting the 0x8002013A error, which is the library not yet linked error, I was just wondering what I need to do in order to link it.

-Aura
mypspdev
Posts: 178
Joined: Wed Jul 11, 2007 10:30 pm

Post by mypspdev »

I do not know if I understood your problem, and I'm not an expert at all.
I had a suggestion by someone when I experienced problems with libraries and their order in the makefile list: using --start-group
--end-group to group libraries and independently resolve linker issues.
It worked, but I do not know if you are having similar problems.
I tried to answer.
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

I'm not sure, I think you are thinking of it as a linker error when compiling, the error actually occurs in the app itself (it compiles fine). It only happens when I try and load a function from the kmodeplugin...

I've declared the function in the main app, I've compiled with the stub file, and I've loaded and started the plugin, am I overlooking anything?

-Aura
User avatar
Aura
Posts: 37
Joined: Tue Jul 24, 2007 4:30 am

Post by Aura »

Ok, I'm still having my error when trying to run the function from the plugin, I've edited the first post to show the ammended source codes, makefiles and exports, so it may be more helpful for you to help.

When I run the program, it loads the module and starts it fine, but bugs out when trying to run the unload_mod(); function, and gives me the error 0x8002013A.

I've found nothing helpful for this, except to say that I get the exact same error when I don't load the module, so I'm wondering if its still having issues loading it and starting it, or accessing it in memory?

-Aura
Post Reply