compiler error or freeze on pspSdkLoadStartModule

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

compiler error or freeze on pspSdkLoadStartModule

Post by jean »

While writing a VSH module dealing with other PRXs (PSP_MODULE_INFO("piKeyOpenKeyboard", 0x1000, 1, 1);), i found the error

Code: Select all

C:/pspsdk/psp/sdk/lib\libpspsdk.a(loadmodule.o): In function `pspSdkLoadStartMod
uleWithArgs':
: undefined reference to `snprintf'
collect2: ld returned 1 exit status
make: *** [piKeyChatPad.elf] Error 1
After a little digging, i found a post where J.F. was saying not to use USE_KERNEL_LIB* unless strictly necessary, so i tried setting

Code: Select all

USE_KERNEL_LIBS = 0
USE_KERNEL_LIBC = 0
in my makefile: compiled fine, freezed on pspSdkLoadStartModule 's line (found by logfile, log calls removed for sake of readability)

Code: Select all

int main_thread(SceSize args, void *argp) 
{
	int ch;
	
	sceKernelDelayThread(1000000);

	// get current directory
	char modName[256];
	getcwd(modName,240);
	strcat(modName,"/sioDriver.prx");
	// load siodriver
	SceUID mod = pspSdkLoadStartModule(modName, PSP_MEMORY_PARTITION_KERNEL);   // here execution stops, PSP freezes
	
    	if &#40;mod < 0&#41;
	&#123;
		sceKernelDelayThread&#40;3000000&#41;;
		sceKernelExitGame&#40;&#41;;
	&#125;
	.
	.
	.
&#125;
Issue is present in two different sourcecodes of mine, involving both kernel and user mode PRXs.

Some hints? Someone who already faced the problem? Seems like that pointed here http://forums.ps2dev.org/viewtopic.php?t=10467
jube
Posts: 115
Joined: Tue Oct 23, 2007 2:26 am

Post by jube »

"USE_KERNEL_LIBS = 0
USE_KERNEL_LIBC = 0"

not a good idea, from trial and error with pikey as soon as you do that everything starts to go wrong !!! I am having to code my own graphics handling routine that will work with

USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1

for exactly that same reason, and i know nothing about graphics handling on the psp!! Simply because with

USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1

no pre-made graphics routines will link.

Have no idea why, and no time to learn why properly, when have time will go back to books for a reason.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Ok, i had the suspect, too...then let me focus on the first part of the post:
how to solve the "undefined reference to `snprintf'"? I already checked and library containing that function IS linked properly..
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

back to

Code: Select all

USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1
i replaced

Code: Select all

SceUID mod = pspSdkLoadStartModule&#40;"ms0&#58;/.../mymodule.prx", PSP_MEMORY_PARTITION_USER&#41;;
with

Code: Select all

SceKernelLMOption option;
SceUID mpid = PSP_MEMORY_PARTITION_USER;
memset&#40;&option, 0, sizeof&#40;option&#41;&#41;;
option.size = sizeof&#40;option&#41;;
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;

SceUID mod = sceKernelLoadModule&#40;"ms0&#58;/.../mymodule.prx", 0, &option&#41;; 
mod = sceKernelStartModule&#40;mod, 0, NULL, 0, &option&#41;; 
as adviced here (http://forums.ps2dev.org/viewtopic.php? ... c85cacbc6e)... now i get a blurry

Code: Select all

SCE_KERNEL_ERROR_ERROR = 0x80020001
from sceKernelStartModule: WHY??.
What does really sceKernelStartModule do? Does it simply call "module_start" of supplied module or it is needed to run even if i only want my functions loaded (to hook api ones) and nothing more??
Very confused...
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Try this:

For kernel plugins leave the
USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1

Install the M33SDK and include kubridge.h
Then use kuKernelLoadModule for loading.
Start it with the sceKKernelStartModule.

Don't load into user memory but load into kernel memory. Just give NULL for *options it will load into kernel memory automatically.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Oh, very thanks, torch...i will surely try your solution. Only thing to hilight is i sometime need user mode to patch user mode functions...oh, and setting null into options appear resulting in "illegal" error from the load module function...anyway i will invesigate in the direction you pointed....thanks again!

jean
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

jean wrote:Oh, very thanks, torch...i will surely try your solution. Only thing to hilight is i sometime need user mode to patch user mode functions...oh, and setting null into options appear resulting in "illegal" error from the load module function...anyway i will invesigate in the direction you pointed....thanks again!

jean
If you want to load into user memory then you shouldn't pass NULL. You'll have to create an Option structure specifying user memory.

mod = kuKernelLoadModule("flash0:/module.prx", 0, NULL);
Post Reply