 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Tue Sep 25, 2007 7:14 am Post subject: pspdev/sdk "sio" sample from 1.50 kernel to 3.xx k |
|
|
Hi!
Because the debug/sio sample is only working under 1.50 kernel and crashing under 3.xx kernel, I'd like to modify it for compatibility.
Here is source:
| Code: | /*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Basic sample to demonstrate the remote port sio.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("REMOTE", 0x1000, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(0);
int main(void)
{
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
/* Initialise SIO and install a kprintf handler */
pspDebugSioInit();
pspDebugSioInstallKprintf();
/* Install a stdout handler */
pspDebugInstallStdoutHandler(pspDebugSioPutData);
Kprintf("Hi from %s!\n", "Kprintf");
printf("Also hi from stdio\r\n");
pspDebugScreenPrintf("Press X to exit, tap away on your terminal to echo\n");
sceDisplayWaitVblankStart();
while(1)
{
SceCtrlData pad;
int ch;
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
ch = pspDebugSioGetchar();
if(ch >= 0)
{
pspDebugScreenPrintf("Received %d\n", ch);
if(ch == '\r')
{
pspDebugSioPutchar('\r');
pspDebugSioPutchar('\n');
}
else
{
pspDebugSioPutchar(ch);
}
}
sceDisplayWaitVblankStart();
}
sceKernelExitGame();
return 0;
}
|
Here is Makefile:
| Code: | TARGET = sio
OBJS = main.o
USE_PSPSDK_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = SIO Test
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
LIBS += -lpsphprm_driver
|
I'm assuming the following steps at least for porting:
- add callback setup as usual
- add to makefile PSP_FW_VERSION = 371
What else, please?
It's still not properly working, crashing under 3.xx kernel.
Is something wrong from libpspdebug ?
Or something not compatible for
pspDebugSioInit();
pspDebugSioInstallKprintf();
? Thanks in advance for your help |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Tue Sep 25, 2007 7:43 am Post subject: |
|
|
| Code: | PSP_MODULE_INFO("REMOTE", 0x1000, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(0); |
Makes it a kernel mode app. You need to change it to user. Of course, then you'll need to move the kernel mode stuff into an external prx to access it. Find everything that HAS to be in kernel mode and put it into a separate prx, then load/start that prx from the user app. Like I tend to recommend, check the nanddumper example in the 3xxHEN SDK. It very clearly shows how to make, load, and call kernel functions from a user app with the prx. That means the main task is figuring out what should be moved to the prx. |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Wed Sep 26, 2007 4:46 am Post subject: |
|
|
Thanks very much, J.F, I'll try to do it and post solution or intermediate steps, if any, apologizing since now for eventual new help being asked.
Same porting need from 1.50 to 3.xx I have for
pspsdk/net/Wlanscan a wireless lan sniffer
and
pspsdk/net/simple a Client/Server
but these the samples are already .prx.
Thanks for now. |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Wed Sep 26, 2007 6:00 am Post subject: |
|
|
ok I've compiled sio as a prx:
| Code: | /*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Basic sample to demonstrate the remote port sio.
*
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
*
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("REMOTE", 0x1000, 1, 1);
/* Define the main thread's attribute value (optional) */
//PSP_MAIN_THREAD_ATTR(0);
int main(void)
{
pspDebugScreenInit();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
/* Initialise SIO and install a kprintf handler */
pspDebugSioInit();
pspDebugSioInstallKprintf();
/* Install a stdout handler */
pspDebugInstallStdoutHandler(pspDebugSioPutData);
Kprintf("Hi from %s!\n", "Kprintf");
printf("Also hi from stdio\r\n");
pspDebugScreenPrintf("Press X to exit, tap away on your terminal to echo\n");
sceDisplayWaitVblankStart();
while(1)
{
SceCtrlData pad;
int ch;
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
ch = pspDebugSioGetchar();
if(ch >= 0)
{
pspDebugScreenPrintf("Received %d\n", ch);
if(ch == '\r')
{
pspDebugSioPutchar('\r');
pspDebugSioPutchar('\n');
}
else
{
pspDebugSioPutchar(ch);
}
}
sceDisplayWaitVblankStart();
}
// sceKernelExitGame();
sceKernelSleepThread();
return 0;
}
/* Exported function returns the address of module_info */
void* getModuleInfo(void)
{
return (void *) &module_info;
}
|
Makefile :
| Code: | TARGET = sio
OBJS = main.o
# Define to build this as a prx (instead of a static elf)
BUILD_PRX=1
# Define the name of our custom exports (minus the .exp extension)
# PRX_EXPORTS=exports.exp
USE_PSPSDK_LIBC = 1
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
LIBS += -lpsphprm_driver |
[/code]
A compiled a prx loader:
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("sio_prx", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
u8 block[32*32*528];
int ReadBlock(u32 page, u8 *buffer);
#define printf pspDebugScreenPrintf
int main()
{
pspDebugScreenInit();
SceUID mod = pspSdkLoadStartModule("sio.prx", PSP_MEMORY_PARTITION_KERNEL);
if (mod < 0)
{
printf("Error 0x%08X loading/starting sio.prx.\n", mod);
}
else
{
}
sceKernelDelayThread(5*1000*1000);
sceKernelExitGame();
return 0;
} |
Or another way, with callbacks:
| Code: |
/*
* PSP Software Development Kit - http://www.pspdev.org
* -----------------------------------------------------------------------
* Licensed under the BSD license, see LICENSE in PSPSDK root for details.
*
* main.c - Basic harness for loading prxes (for proving a point)
*
* Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
* Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
* Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
*
* $Id: main.c 1095 2005-09-27 21:02:16Z jim $
*/
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <string.h>
PSP_MODULE_INFO("PRXLOADER", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
/* Define printf, just to make typing easier */
#define printf pspDebugScreenPrintf
/* Exit callback */
int exit_callback(int arg1, int arg2, void *arg)
{
sceKernelExitGame();
return 0;
}
/* Callback thread */
void CallbackThread(void *arg)
{
int cbid;
cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
sceKernelRegisterExitCallback(cbid);
sceKernelSleepThreadCB();
}
/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void)
{
int thid = 0;
thid = sceKernelCreateThread("update_thread", (void*) CallbackThread, 0x11, 0xFA0, 0xa0000000, 0);
if(thid >= 0)
{
sceKernelStartThread(thid, 0, 0);
}
return thid;
}
SceUID load_module(const char *path, int flags, int type)
{
SceKernelLMOption option;
SceUID mpid;
/* If the type is 0, then load the module in the kernel partition, otherwise load it
in the user partition. */
if (type == 0) {
mpid = 1;
} else {
mpid = 2;
}
memset(&option, 0, sizeof(option));
option.size = sizeof(option);
option.mpidtext = mpid;
option.mpiddata = mpid;
option.position = 0;
option.access = 1;
return sceKernelLoadModule(path, flags, type > 0 ? &option : NULL);
}
/* Imported function */
void *getModuleInfo(void);
int main(void)
{
SceUID modid;
SceModule *mod;
int i;
int ret;
int fd;
pspDebugScreenInit();
SetupCallbacks();
/* Start mymodule.prx and dump its information */
printf("\nStart my module\n");
modid = load_module("./sio.prx", 0, 0);
printf("Module ID %08X\n", modid);
mod = sceKernelFindModuleByUID(modid);
printf("mod %p\n", mod);
/* Let's bug out */
sceKernelExitDeleteThread(0);
return 0;
} |
PRX Loader Makefile:
| Code: | TARGET = Myprxloader
OBJS = main.o
INCDIR =
CFLAGS = -G0 -Wall -fno-exceptions
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
LIBS=
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Myprxloader
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
But the PRX Loader, both of them, do run and work properly only if under GAME150, not GAME3xx.
I'd like to run sio under 3.xx.
Please where am I wrong?
Thanks |
|
| Back to top |
|
 |
coldbit
Joined: 26 Sep 2007 Posts: 1
|
Posted: Wed Sep 26, 2007 6:38 am Post subject: |
|
|
You have to use:
(see kubridge.h in the SDK of 3.71 M33 release)
rather than:
| Code: | | sceKernelLoadModule |
|
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Wed Sep 26, 2007 7:00 am Post subject: |
|
|
| coldbit wrote: | You have to use:
(see kubridge.h in the SDK of 3.71 M33 release)
rather than:
| Code: | | sceKernelLoadModule |
|
It doesn't work ...
To use remote controller/SIO I need Flat PSP with at present 3.52M-33.
I do try it on S&L with 3.71M-33, even if nothing to do with SIO/Remote controller: it does'n load sio.prx on S&L as well as on Flat .
Prx Loader only works under 1.50, which I do want to avoid.
Thanks. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 26, 2007 10:00 am Post subject: |
|
|
Okay, let's review the high points of the nanddumper example app...
First, let's start with the external prx. This is no more than a library to be loaded and called by the main app. ALL kernel code must go into these for 3.xx. Here's the main.c file for the nanddumper.prx:
main.c
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <pspnand_driver.h>
#include <string.h>
PSP_MODULE_INFO("NandDumper", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
int nandLocked = 0;
void LockNand()
{
if (!nandLocked)
sceNandLock(0);
nandLocked = 1;
}
void UnlockNand()
{
if (nandLocked)
sceNandUnlock();
nandLocked = 0;
}
int ReadBlock(u32 page, u8 *buffer)
{
u32 i, j;
u32 k1;
k1 = pspSdkSetK1(0);
LockNand();
if (sceNandIsBadBlock(page))
{
memset(buffer, 0xFF, 528);
UnlockNand();
pspSdkSetK1(k1);
return -1;
}
for (i = 0; i < 32; i++)
{
for (j = 0; j < 4; j++)
{
sceNandReadPagesRawAll(page, buffer, NULL, 1);
sceNandReadExtraOnly(page, buffer+512, 1);
}
page++;
buffer += 528;
}
UnlockNand();
pspSdkSetK1(k1);
return 0;
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
|
Notice its header:
| Code: | PSP_MODULE_INFO("NandDumper", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0); |
This shows this is a kernel mode prx. Notice how it has module_start() and module_stop(), both needed for external libs. Notice how it has a number of functions and no main() entry point. Notice the use of pspSdkSetK1(). Setting K1 to 0 around functions prevents the kernel from faulting when accessing areas like user-mode memory.
Its makefile appears this way:
makefile
| Code: | TARGET = nanddumper
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = nanddumper.exp
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspnand_driver2
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
Notice how it uses no-crt0 and nostartfiles... that's because this is a plain lib, not an app. It doesn't need either of those. Notice the use of the kernel libs. Notice that there is a file called "nanddumper.exp" - that is where you declare which functions are seen externally when this prx is loaded.
Here's what that file looks like:
nanddumper.exp
| 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(NandDumper, 0, 0x4001)
PSP_EXPORT_FUNC(ReadBlock)
PSP_EXPORT_END
PSP_END_EXPORTS
|
The lines must always be like that except for the PSP_EXPORT_FUNC() lines. That is where you set the exported functions from this lib. Oh, the NandDumper in the start line should match the NandDumper in the PSP_MODULE_INFO in main.c. Change both identically to make a different name. This file is also used to generate the .S file that you use in the main app to access these functions. To make the .S file, from a shell set to the directory with these files, run
| Code: | | psp-build-exports -s nanddumper.exp |
Copy that .S file to the same directory as the source for the main app, along with the .prx file you get when you run make.
That is all you do for the prx part. The above gives you a kernel-mode lib that does all the stuff you need via exported functions. Now let's move on to the main app.
main.c
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("NandDumperMain", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
u8 block[32*32*528];
int ReadBlock(u32 page, u8 *buffer);
#define printf pspDebugScreenPrintf
int main()
{
pspDebugScreenInit();
SceUID mod = pspSdkLoadStartModule("nanddumper.prx", PSP_MEMORY_PARTITION_KERNEL);
if (mod < 0)
{
printf("Error 0x%08X loading/starting naddumper.prx.\n", mod);
}
else
{
SceUID fd = sceIoOpen("ms0:/nanddump.flash", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
printf("Dumping...\n");
int i, j;
for (i = 0; i < (2048*32); )
{
u8 *p = block;
memset(block, 0xff, sizeof(block));
for (j = 0; j < 32; j++)
{
if (ReadBlock(i, p) < 0)
{
printf("bad block at page %d block %d\n", i, i/32);
}
i += 32;
p += (528*32);
}
sceIoWrite(fd, block, sizeof(block));
}
sceIoClose(fd);
printf("Done. Exiting in 5 seconds\n");
}
sceKernelDelayThread(5*1000*1000);
sceKernelExitGame();
return 0;
}
|
Notice the header.
| Code: | PSP_MODULE_INFO("NandDumperMain", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
|
This is a user-mode app. That is what you need for HEN and 3.xx on the slim. You may also need to set the heap size if you need to allocate lots of memory in the app. That would be done by putting a line after the above two lines that looks like this:
| Code: | | PSP_HEAP_SIZE_KB(2500); |
That sets the size of the heap in kBytes. So that line sets it to about 2.5 MB. Notice that the app also has declarations for all the functions that will be imported, as so:
| Code: | | int ReadBlock(u32 page, u8 *buffer); |
Note how the prx is loaded:
| Code: | | SceUID mod = pspSdkLoadStartModule("nanddumper.prx", PSP_MEMORY_PARTITION_KERNEL); |
Notice in that line how it's loaded into the kernel partition since it's a kernel mode lib. Also notice that you simply call the functions as normal. The .S file function entries will take care of switching back and forth between user and kernel mode.
DON'T FORGET!! All created threads must be USER threads. Set the attr arg in the createthread function to PSP_THREAD_ATTR_USER!
Now look at the makefile:
makefile
| Code: | release: all
mksfo 'NandDumper' PARAM.SFO
pack-pbp EBOOT.PBP PARAM.SFO NULL NULL NULL NULL NULL nanddumpermain.prx NULL
TARGET = nanddumpermain
OBJS = main.o NandDumper.o
INCDIR =
CFLAGS = -O2 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
LIBDIR =
LIBS =
LDFLAGS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
That's an "old-style" makefile as seen from it's use of mksfo and pack-pbp. You can instead use the newer makefile style as such:
makefile
| Code: | TARGET = nanddumpermain
OBJS = main.o NandDumper.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
LIBDIR =
LIBS =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = NandDumper
PSP_EBOOT_ICON="icon0.png"
PSP_EBOOT_PIC1="pic1.png"
PSP_EBOOT_SND0="snd0.at3"
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
Note how the new style doesn't directly use mksfo or pack-pbp, but uses EXTRA_TARGETS and PSP_EBOOT_XXXX instead. It's equivalent, but easier to specify without goofing up the arguments to mksfo or pack-pbp. All those PSP_EBOOT_XXXX lines are optional.
Note that the makefile has "BUILD_PRX = 1". That seems to be the key for getting it to run as a 3xx app. notice how the .S file is included in the object list.
Doing all this gives you the two files you want: nanddumper.prx (the external prx library) and EBOOT.PBP (the main app). Copy those to a folder in PSP/GAME/ and you're all set.
I hope this brief review has given you some insight into how you make a user-mode app which call a kernel mode external library. |
|
| Back to top |
|
 |
sakya
Joined: 28 Apr 2006 Posts: 190
|
Posted: Wed Sep 26, 2007 7:45 pm Post subject: |
|
|
Hi! :)
Many thanks J.F. for the explanation...I was just looking at the nanddumper sample, but I'm experiencing problems.
Can you please help me?
I'm just trying to make a prx with the functions to set and get the display brightness (just to test some kernel functions).
I think I followed all your advices but the app still gives me "Library not found" error.
Here's my code:
Main.c
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <pspctrl.h>
#include <string.h>
PSP_MODULE_INFO("Test_CF352", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(2500);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Functions imported from prx:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int getBrightness(void);
void setBrightness(int brightness);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Globals:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Main:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main(){
SceUID modid;
SceModule *mod;
int ret;
int fd;
pspDebugScreenInit();
pspDebugScreenPrintf("Eboot test\n");
pspDebugScreenPrintf("Press X to quit\n");
modid = pspSdkLoadStartModule("myLib.prx", PSP_MEMORY_PARTITION_KERNEL);
if (modid < 0){
pspDebugScreenPrintf("Error 0x%08X loading/starting test352.prx.\n", modid);
sceKernelDelayThread(5*1000*1000);
return -1;
}
pspDebugScreenPrintf("Module ID %08X\n", modid);
mod = sceKernelFindModuleByUID(modid);
pspDebugScreenPrintf("mod %p\n", mod);
ret = sceKernelStartModule(modid, 0, NULL, &fd, NULL);
pspDebugScreenPrintf("Brightness level %i\n", getBrightness());
SceCtrlData pad;
while(1){
sceCtrlReadBufferPositive(&pad, 1);
if (pad.Buttons & PSP_CTRL_CROSS){
break;
}
}
sceKernelExitGame();
return 0;
}
|
Makefile:
| Code: | TARGET = Test_CF352
OBJS = main.o myLib.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
LIBDIR =
LIBS =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test_CF352
#PSP_EBOOT_ICON="icon0.png"
#PSP_EBOOT_PIC1="pic1.png"
#PSP_EBOOT_SND0="snd0.at3"
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
And there's my prx source code.
Main.c
| Code: | #include <pspsdk.h>
#include <pspkernel.h>
#include <pspdisplay_kernel.h>
PSP_MODULE_INFO("myLib", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
int getBrightness(){
int currentBrightness = 0;
u32 k1;
k1 = pspSdkSetK1(0);
sceDisplayGetBrightness(¤tBrightness, 0);
pspSdkSetK1(k1);
return currentBrightness;
}
void setBrightness(int brightness){
u32 k1;
k1 = pspSdkSetK1(0);
sceDisplaySetBrightness(brightness, 0);
pspSdkSetK1(k1);
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
|
Makefile:
| Code: | TARGET = mylib
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = mylib.exp
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspdisplay_driver
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
and mylib.exp
| 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
# Export our function
PSP_EXPORT_START(myLib, 0, 0x4001)
PSP_EXPORT_FUNC(getBrightness)
PSP_EXPORT_FUNC(setBrightness)
PSP_EXPORT_END
PSP_END_EXPORTS
|
I really cannot understand what's wrong.
I'm on CF 3.52 update 4 and I put the resulting eboot and prx in PSP/GAME352
Ciaooo
Sakya |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 26, 2007 8:03 pm Post subject: |
|
|
Look at the example again - this part is TOTALLY unnecessary.
| Code: | mod = sceKernelFindModuleByUID(modid);
pspDebugScreenPrintf("mod %p\n", mod);
ret = sceKernelStartModule(modid, 0, NULL, &fd, NULL);
|
The pspSdkLoadStartModule() already did all that. Just pspSdkLoadStartModule() then start using the the functions. |
|
| Back to top |
|
 |
sakya
Joined: 28 Apr 2006 Posts: 190
|
Posted: Wed Sep 26, 2007 8:07 pm Post subject: |
|
|
Hi! :)
| J.F. wrote: | Look at the example again - this part is TOTALLY unnecessary.
| Code: | mod = sceKernelFindModuleByUID(modid);
pspDebugScreenPrintf("mod %p\n", mod);
ret = sceKernelStartModule(modid, 0, NULL, &fd, NULL);
|
The pspSdkLoadStartModule() already did all that. Just pspSdkLoadStartModule() then start using the the functions. |
OMG, I'm very sorry for my mistake!
Just removed those lines and the app works perfectly. :)
Many thanks
Ciaooo
Sakya |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Wed Sep 26, 2007 8:57 pm Post subject: |
|
|
| sakya wrote: |
Makefile:
| Code: | TARGET = Test_CF352
OBJS = main.o myLib.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
LIBDIR =
LIBS =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test_CF352
#PSP_EBOOT_ICON="icon0.png"
#PSP_EBOOT_PIC1="pic1.png"
#PSP_EBOOT_SND0="snd0.at3"
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
|
|
Thanks to both Sakya and J.F for these lessons.
Please in the Makefile of the main program you put
OBJS = ... MyLib.o
as well as in the NandDumper.o in the example.
Does it refer to the MyLib.s and NandDumper.s generated from *.exp?
How is it *.S generated?
Does it require this command from cygwin prompt?
| Code: | | psp-build-exports -s MyLib.exp |
Here on this PC I have only pspdev not full cygwin/psptoolchain.
In case I'll try again at home.
Thanks for explanation. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 26, 2007 9:22 pm Post subject: |
|
|
| sakya wrote: | Hi! :)
| J.F. wrote: | Look at the example again - this part is TOTALLY unnecessary.
| Code: | mod = sceKernelFindModuleByUID(modid);
pspDebugScreenPrintf("mod %p\n", mod);
ret = sceKernelStartModule(modid, 0, NULL, &fd, NULL);
|
The pspSdkLoadStartModule() already did all that. Just pspSdkLoadStartModule() then start using the the functions. |
OMG, I'm very sorry for my mistake!
Just removed those lines and the app works perfectly. :)
Many thanks
Ciaooo
Sakya |
No problem... easy enough to miss. Glad to hear it's working now. That's the main thing.
| mypspdev wrote: | Thanks to both Sakya and J.F for these lessons.
Please in the Makefile of the main program you put
OBJS = ... MyLib.o
as well as in the NandDumper.o in the example.
Does it refer to the MyLib.s and NandDumper.s generated from *.exp?
How is it *.S generated?
Does it require this command from cygwin prompt?
| Code: | | psp-build-exports -s MyLib.exp |
Here on this PC I have only pspdev not full cygwin/psptoolchain.
In case I'll try again at home.
Thanks for explanation. |
| Code: | | psp-build-exports -s MyLib.exp |
makes MyLib.S. Putting MyLib.o into the objects line of the app's makefile has psp-gcc compile MyLib.S into MyLib.o, and link it with the other objects. |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Wed Sep 26, 2007 11:09 pm Post subject: |
|
|
About exports.exp and exports.S and .o:
I saw on ModulTutorialv1.pdf the following first lines in a Makefile (for supervisor):
| Code: | release: all
psp-build-exports -k supervisor_exp.exp
psp-build-exports -s -k -v supervisor_exp.exp
...... |
Does it mean in our examples that the statement for building exports.S from exports.exp
| Code: | | psp-build-exports -s exports.exp |
must be included into the makefile?
Or is it an external statement to be run at cygwin prompt?
The handbook is explaining:
"The stub file ... .S can be generated from the exp file using "psp-build-exports -s -k -v *.exp" or the PRX directly (although using the latter the liiteral name of the function is lost)."
Could anybody explain better what it means?
Thanks a lot, sorry for not having yet understood what doing. |
|
| Back to top |
|
 |
Viper8896
Joined: 26 Jan 2006 Posts: 110
|
Posted: Wed Sep 26, 2007 11:16 pm Post subject: |
|
|
| the make file way is simply to do it automatically very time you make but is more make file related rather then psp dev. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 27, 2007 12:16 am Post subject: |
|
|
| mypspdev wrote: | About exports.exp and exports.S and .o:
I saw on ModulTutorialv1.pdf the following first lines in a Makefile (for supervisor):
| Code: | release: all
psp-build-exports -k supervisor_exp.exp
psp-build-exports -s -k -v supervisor_exp.exp
...... |
Does it mean in our examples that the statement for building exports.S from exports.exp
| Code: | | psp-build-exports -s exports.exp |
must be included into the makefile?
Or is it an external statement to be run at cygwin prompt?
The handbook is explaining:
"The stub file ... .S can be generated from the exp file using "psp-build-exports -s -k -v *.exp" or the PRX directly (although using the latter the liiteral name of the function is lost)."
Could anybody explain better what it means?
Thanks a lot, sorry for not having yet understood what doing. |
You COULD put it into the makefile, but I normally don't since you really only need to run it once - unless you change the functions being exported. As long as the functions don't change, neither will the .exp or .S files, so there's no need to make them every single time.
I don't know what all the various options on psp-build-exports do, but the -s option generates the .S file kernel mode prx libs need for user mode apps to access their functions. I tried other options I'd heard were supposedly the ones to use, but the .S files were unusable. Only -s by itself generated the proper file for the use being made of it here. |
|
| Back to top |
|
 |
Smong
Joined: 04 Sep 2007 Posts: 82
|
Posted: Thu Sep 27, 2007 12:58 am Post subject: |
|
|
@J.F.
| Quote: | | Notice the use of the kernel libs | How can I tell if a lib is a kernel lib and where can I find the names of the kernel libs? Also are there kernel versions for every user version, if not should I use the user version or am I just not allowed to use it at all?
| Quote: | nanddumper.exp
| Code: | PSP_EXPORT_START(syslib, 0, 0x8000)
PSP_EXPORT_START(NandDumper, 0, 0x4001) |
| Do the 0x8000 and 0x4001 mean anything? What if I wanted to load a second prx into my app, would I use 0x8001 and 0x4002 so the numbers are different?
Is there a way to unload modules after using pspSdkLoadStartModule? Also how big is the PSP_MEMORY_PARTITION_KERNEL? This is so I can know the maximum size of the kernel prx and the maximum amount of memory I can put in PSP_HEAP_SIZE_KB().
| Quote: | | DON'T FORGET!! All created threads must be USER threads. | So you aren't allowed to create kernel mode threads inside the kernel mode prx? If you mean creating threads from the user mode program then don't they automatically start as user mode anyway?
Something you didn't mention but I found in ModuleTutorialv1.pdf, should I be using PSP_NO_CREATE_MAIN_THREAD(); in the kernel prx?
@mypspdev
| Quote: | | "The stub file ... .S can be generated from the exp file using "psp-build-exports -s -k -v *.exp" or the PRX directly (although using the latter the liiteral name of the function is lost)." | I think what "losing the literal name" means is if you do psp-build-exports -s mykernelmodule.prx you will end up with stuff like mykernelmodule_3ea42f1c instead of mykernelmoduleMyFunction so inside your user main.c you would have to do:
| Code: | #define mykernelmoduleMyFunction mykernelmodule_3ea42f1c
void mykernelmoduleMyFunction(void); | I haven't tried it myself, but I've seen other code using something like this. _________________ (+[__]%) |
|
| Back to top |
|
 |
Viper8896
Joined: 26 Jan 2006 Posts: 110
|
|
| Back to top |
|
 |
deniska
Joined: 17 Oct 2005 Posts: 71 Location: New York
|
Posted: Thu Sep 27, 2007 1:35 am Post subject: |
|
|
Just an interesting observation...
I spent a couple of hours trying to make the sio sample run under 3.xx in M33 3.51-4 but the code would always crap out @ pspDebugSioInit() even though all kernel stuff was moved to a separate prx..
Then I ran same code on the slim 3.71 (finally got the remote control thingie for the slim)... and it worked like a charm..
Interestingly enough the sio sample still runs ok under 1.5 kernel in m33 3.51-4
So, i guess, some of 3.xx porting problems may be due to faulty firmware... |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Thu Sep 27, 2007 1:53 am Post subject: |
|
|
I'm still getting errors or crashes even if with original sakya example.
debug/Sio, net/wlanscan, net/simple I tried to port to prx's are still not working.
on 3.71m-33 (on slim) it gives an error and return back to xmb.
on 3.52m-33-4 (on flat) it crashes both under game352 and game150.
something is clear from "lessons" results are not going on properly up to me. |
|
| Back to top |
|
 |
deniska
Joined: 17 Oct 2005 Posts: 71 Location: New York
|
Posted: Thu Sep 27, 2007 3:56 am Post subject: |
|
|
@mypspdev:
Below is somewhat modified code for sio sample that you should be able to run in 3.71 on slim...
main.c
| Code: |
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("SIO_TESTER", 0, 1, 1);
/* Define the main thread's attribute value (optional) */
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
int main(void)
{
int baud=1200;
pspDebugScreenInit();
pspDebugScreenPrintf("PSP GPSlim 236 test - Press X to exit\n");
pspDebugScreenPrintf("Press UP/DOWN to change baud\n");
sceDisplayWaitVblankStart();
sceCtrlSetSamplingCycle(0);
sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG);
SceUID mod = pspSdkLoadStartModule("pspremoteprx.prx", PSP_MEMORY_PARTITION_KERNEL);
if (mod < 0)
{
pspDebugScreenPrintf(" Error 0x%08X loading/starting pspremoteprx.prx.\n", mod);
sceKernelDelayThread(3*1000*1000);
sceKernelExitGame();
}
pspDebugScreenPrintf("module loaded !!!\n");
sioInit();
pspDebugScreenPrintf("INIT DONE!!!\n");
while(1)
{
SceCtrlData pad;
sceCtrlReadBufferPositive(&pad, 1);
if(pad.Buttons & PSP_CTRL_UP) {
baud*=2;
pspDebugScreenPrintf("setting baud to: %d\n", baud);
sioSetBaud(baud);
sceKernelDelayThread(500000);
}
if(pad.Buttons & PSP_CTRL_DOWN) {
baud/=2;
pspDebugScreenPrintf("setting baud to: %d\n", baud);
sioSetBaud(baud);
sceKernelDelayThread(500000);
}
if(pad.Buttons & PSP_CTRL_CROSS)
{
break;
}
int ch = sioGetchar();
if((ch >= 0) && (ch != '\r'))
{
pspDebugScreenPrintf("%c", ch);
}
}
sceKernelExitGame();
return 0;
}
|
Makefile:
| Code: |
TARGET = pspgpslim236
OBJS = main.o pspremoteprx.o
#USE_PSPSDK_LIBC = 1
BUILD_PRX=1
PSP_FW_VERSION=360
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LIBDIR =
LDFLAGS =
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = GPSlim236
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
#LIBS += -lpsphprm_driver
|
-------------------------------------------------------------------
pspremoteprx:: main.c
| Code: |
#include <pspsdk.h>
PSP_MODULE_INFO("pspremoteprx", 0x1006, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
#define PSP_UART4_FIFO 0xBE500000
#define PSP_UART4_STAT 0xBE500018
#define PSP_UART4_DIV1 0xBE500024
#define PSP_UART4_DIV2 0xBE500028
#define PSP_UART4_CTRL 0xBE50002C
#define PSP_UART_CLK 96000000
#define PSP_UART_TXFULL 0x20
#define PSP_UART_RXEMPTY 0x10
void sioInit(void)
{
sceHprmEnd();
sceSysregUartIoEnable(4);
sceSysconCtrlHRPower(1);
}
void sioSetBaud(int baud)
{
int div1, div2;
div1 = PSP_UART_CLK / baud;
div2 = div1 & 0x3F;
div1 >>= 6;
_sw(div1, PSP_UART4_DIV1);
_sw(div2, PSP_UART4_DIV2);
_sw(0x60, PSP_UART4_CTRL);
}
int sioGetchar() {
return pspDebugSioGetchar();
}
int module_start(SceSize args, void *argp)
{
return 0;
}
int module_stop()
{
return 0;
}
|
pspremoteprx.exp:
| 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(pspremoteprx, 0, 0x4001)
PSP_EXPORT_FUNC(sioInit)
PSP_EXPORT_FUNC(sioSetBaud)
PSP_EXPORT_FUNC(sioGetchar)
PSP_EXPORT_END
PSP_END_EXPORTS
|
Makefile:
| Code: |
TARGET = pspremoteprx
OBJS = main.o
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = pspremoteprx.exp
USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS = -lpspdebug -lpspsdk -lpsphprm_driver
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
all:
echo "$PSPSDK"
psp-build-exports -s pspremoteprx.exp
cp *.S ../
cp *.prx ../
clean:
rm -f $(FINAL_TARGET) $(EXTRA_CLEAN) $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) $(EXTRA_TARGETS)
rm -f *.S
|
|
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Thu Sep 27, 2007 6:27 am Post subject: |
|
|
I'd like to invite all of you for a beer and a dinner in any steakhouse around J.F. four corner area .....
Thanks to all, I'll try to reply your lessons here...
Let me tell about some stupid issues for whos is still like me on the way of a learning curve...
- Do not run "make" if you have *.S already in the directory: you'll become mad for duplicate declarations...
- Do not try to use stupid printf / pspDebugScreenPrinf because USE_KERNEL_LIBC=1
USE_KERNEL_LIBS=1
are forbidden them for some reasons ...
That's why I was stopped ... Now I've MyPRX and MyLoadPRX... and try to port Sio, Wlanscan, and Server/simple from pspdevsdk.
Thanks
[edit]
SIO on Slim:
it doesn't matter to have it under 3.71 on slim: this PSP has no more a sio connector input. Where is the sio input on the slim?
I need sio on the flat under a 3.52 application.
[edit 2]
Thanks, sio now is working on Fat 3.52.
I had to change the makefile.
Some problems with exit by CROSS. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Sep 27, 2007 11:20 am Post subject: |
|
|
USE_KERNEL_LIBC is the main culprit for certain things not working in kernel mode. It indicates using a minimal libc specifically for keeping memory usage down for kernel mode prx's. You should use the SDK libc for more extensive prx's.
Quite a bit happened while I was away from the computer today. :)
The Slim has serial as it has a remote control... which communicates with the PSP via serial. However, the pinout for the header changed because of the TV out. If you look at a recent thread, I documented the pins for the component cable. As soon as I can get a remote, I'll be doing some checking into that as well. It's possible the hardware location of the serial stuff changed in the slim. I don't think anyone has looked that closely at the slim yet. |
|
| Back to top |
|
 |
mypspdev
Joined: 11 Jul 2007 Posts: 178
|
Posted: Fri Sep 28, 2007 11:09 pm Post subject: |
|
|
@Deniska:
thanks very much for your souces on SIO prx porting to 3.xx.
I'm experiencing a crash with
with fat PSP under 3.52M33-4.
I'm not able to solve it.
Thanks for help
[/code] |
|
| Back to top |
|
 |
TyRaNiD
Joined: 18 Jan 2004 Posts: 918
|
Posted: Sat Sep 29, 2007 1:52 am Post subject: |
|
|
| Quote: | | You should use the SDK libc for more extensive prx's. | That said if you kernel prx is really extensive then it probably shouldn't be in kernel mode in the first place. |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Sat Sep 29, 2007 12:50 pm Post subject: |
|
|
| TyRaNiD wrote: | | Quote: | | You should use the SDK libc for more extensive prx's. | That said if you kernel prx is really extensive then it probably shouldn't be in kernel mode in the first place. |
:)
Yeah, there is that. Do as little as humanly possible in kernel mode... just the things that NEED to be done in kernel mode. If you can't get by on the kernel libc, you're probably trying to do too much in kernel mode. I think people got spoiled by the 1.50/1.50-based cfw... running the entire program in kernel mode. It's too easy to do something truly awful in kernel mode. There's a reason people are supposed to run in user mode and use the libraries. |
|
| Back to top |
|
 |
quadrizo
Joined: 23 Aug 2007 Posts: 21
|
Posted: Thu Nov 08, 2007 8:43 am Post subject: |
|
|
thanks J.F. for your tuto :)
| J.F. wrote: | | USE_KERNEL_LIBC is the main culprit for certain things not working in kernel mode. |
i've tried to do a basic prx which works well but when i tried to load a module
| Code: |
SceUID mod =pspSdkLoadStartModule("flash0:/kd/audiocodec.prx",PSP_MEMORY_PARTITION_KERNEL);
|
trouble during liking :
with USE_KERNEL_LIBC=1:
->snprintf indefined reference
with USE_PSPSDK_LIBC=1
->sceKernelMaxFreeMemSize indefined reference
an idea how to resolve this problem ?
Last edited by quadrizo on Thu Nov 08, 2007 10:17 am; edited 1 time in total |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Nov 08, 2007 9:10 am Post subject: |
|
|
| quadrizo wrote: | thanks J.F. for your tuto :)
| J.F. wrote: | | USE_KERNEL_LIBC is the main culprit for certain things not working in kernel mode. |
i've tried to do a basic prx which works well but when i tried to load a module
| Code: |
SceUID mod =pspSdkLoadStartModule("flash0:/kd/audiocodec.prx",PSP_MEMORY_PARTITION_KERNEL);
|
trouble during liking :
with USE_PSPSDK_LIBC=1:
->snprintf indefined reference
with USE_PSPSDK_LIBC=1
->sceKernelMaxFreeMemSize indefined reference
an idea how to resolve this problem ? |
You need to use USE_KERNEL_LIBC for a kernel mode prx. My warning above was not to tell people not to use the kernel libc, only that they may need to rewrite their code to work with it rather than the regular user-mode libc. |
|
| Back to top |
|
 |
quadrizo
Joined: 23 Aug 2007 Posts: 21
|
Posted: Thu Nov 08, 2007 10:19 am Post subject: |
|
|
| Quote: |
trouble during liking :
with USE_KERNEL_LIBC=1:
->snprintf undefined reference
with USE_PSPSDK_LIBC=1
->sceKernelMaxFreeMemSize undefined reference
|
sorry copy paste error
i've tried USE_KERNEL_LIBC=1 (snprintf undefined ...) |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Thu Nov 08, 2007 10:25 am Post subject: |
|
|
| quadrizo wrote: | | Quote: |
trouble during liking :
with USE_KERNEL_LIBC=1:
->snprintf undefined reference
with USE_PSPSDK_LIBC=1
->sceKernelMaxFreeMemSize undefined reference
|
sorry copy paste error
i've tried USE_KERNEL_LIBC=1 (snprintf undefined ...) |
First, let's get straight what's what. Is the error in the user app or the kernel prx? If it's in the kernel prx, why are you even using that there? With kernel prxs, you want to do the kernel function and return. Do nothing that isn't absolutely needed.
If it's in the user app, make sure you have the proper libs linked and in the proper order (yes, order matters). If it's in the user app, you WOULD be using one of the user libc's, either newlib or psplibc. |
|
| Back to top |
|
 |
quadrizo
Joined: 23 Aug 2007 Posts: 21
|
Posted: Thu Nov 08, 2007 10:57 am Post subject: |
|
|
ok
to be clear :
i try to load audiocodec and atrac libs and i'm not sure i could call
pspSdkLoadStartModule("flash0:/kd/audiocodec.prx",PSP_MEMORY_PARTITION_KERNEL);
in user mode right ? that's why i would make a prx to load these libs
but if an another and easier way exist ...;-)
makefile :
| Code: |
TARGET = testprx
OBJS = main.o
PSP_FW_VERSION=371
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
BUILD_PRX = 1
PRX_EXPORTS = testprx.exp
USE_PSPSDK_LIBC=1
USE_KERNEL_LIBS=1
LIBDIR =
LDFLAGS = -mno-crt0 -nostartfiles
LIBS =
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
snprintf should not be include in libc ? |
|
| Back to top |
|
 |
|
|
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
|