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 

Problem loading a kmode app in 3.XX

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



Joined: 24 Jul 2007
Posts: 37

PostPosted: Mon Oct 15, 2007 12:17 am    Post subject: Problem loading a kmode app in 3.XX Reply with quote

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:
#include <pspkernel.h>
#include <pspmodulemgr_kernel.h>

PSP_MODULE_INFO("KMode", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);

int unload_mod(char module[])
{
    u32 k1;
   
    k1 = pspSdkSetK1(0);
   
    SceModule *mod;
   
    while((mod = sceKernelFindModuleByName(module)))
    {
               sceKernelStopModule(mod->modid, 0, NULL, NULL, NULL);
               sceKernelUnloadModule(mod->modid);
    }
    pspSdkSetK1(k1);
    return 1;
}

int module_start(SceSize args, void *argp)
{
   return 0;
}

int module_stop()
{
   return 0;
}


kmodeplugin.prx makefile
Code:
TARGET = kmodeplugin
OBJS = main.o

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

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


kmodeplugin.prx exports
Code:
# Define the exports for the prx
PSP_BEGIN_EXPORTS

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

PSP_EXPORT_START(KMode, 0, 0x4001)
PSP_EXPORT_FUNC(unload_mod)
PSP_EXPORT_END

PSP_END_EXPORTS


main code
Code:

...
int unload_mod(char module[]);

PSP_MODULE_INFO("Project4", 0x800, 0, 1);
PSP_HEAP_SIZE_KB(12000);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
...

int __main()
{   
    int check = 0;
    check = unload_mod(module);
    ...
}


main makefile
Code:
   
TARGET = project4
BUILD_PRX = 1

PSP_FW_VERSION = 371

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

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

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!


Last edited by Aura on Tue Oct 23, 2007 4:20 am; edited 1 time in total
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Oct 15, 2007 3:17 am    Post subject: Reply with quote

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:
   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:
all:
   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:
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.
Back to top
View user's profile Send private message AIM Address
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Mon Oct 15, 2007 5:08 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Oct 15, 2007 7:53 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Mon Oct 15, 2007 8:02 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Mon Oct 15, 2007 9:51 am    Post subject: Reply with quote

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".
Back to top
View user's profile Send private message AIM Address
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Tue Oct 16, 2007 5:13 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
J.F.



Joined: 22 Feb 2004
Posts: 2906

PostPosted: Tue Oct 16, 2007 5:37 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message AIM Address
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Tue Oct 16, 2007 6:32 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
mypspdev



Joined: 11 Jul 2007
Posts: 178

PostPosted: Tue Oct 16, 2007 6:58 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Thu Oct 18, 2007 8:06 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
Back to top
View user's profile Send private message
Aura



Joined: 24 Jul 2007
Posts: 37

PostPosted: Tue Oct 23, 2007 4:24 am    Post subject: Reply with quote

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

_________________
Live. Love. Be. Believe.

Free downgrading/unbricking service list!
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