libupnp 1.6.6 PSP port available here

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

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Rex_VF5
Posts: 44
Joined: Wed Dec 26, 2007 6:24 am

libupnp 1.6.6 PSP port available here

Post by Rex_VF5 »

OK boys and girls (if any here). As my first project on PSP and an attempt to do some C/C++ coding I decided non-the-less to do UPNP client (I aim for PS3 look-and-feel - i.e. integrated into XMB creating a virtual drive holding all the UPnP servers & available media). The base for this is to be provided by Portable SDK for UPnP Devices (libupnp 1.6.6) With a pthread PSP port it only took few hours to replace some stuff not available on PSP (more time was spent to learn about setting up toolchain, configure scripts, etc). I added conditional compilation everywhere so it should be possible to build for other platforms from the modified sources (haven't tested it though). Here's what to do:
  • 0) Get pthread-emb, cd platform/psp; make; sudo make install Do not forget to copy pthread.h and sched.h to your `psp-config --psp-prefix`/include directory
    1) Apply the provided diff to the libupnp-1.6.6 source
    2) ./configure.psp.sh --disable-samples --enable-debug
    3) sudo make install
    4) cd upnp/test; make
The last step should produce runnable test_init stuff.prx, EBOOT.PBP and PARAM.SFO which should start and stop basic stuff and show some info about it like this:

Code: Select all

UPNP_VERSION_STRING = "1.6.6"
UPNP_VERSION_MAJOR  = 1
UPNP_VERSION_MINOR  = 6
UPNP_VERSION_PATCH  = 6
UPNP_VERSION        = 10606

UPNP_HAVE_DEBUG         = yes
UPNP_HAVE_CLIENT        = yes
UPNP_HAVE_DEVICE        = yes
UPNP_HAVE_WEBSERVER     = yes
UPNP_HAVE_TOOLS         = yes

Initializing UPnP ...
UPnP Initialized OK ip=192.168.1.3, port=49152
I included a netdialog sample into it to connect to AP at the beginning. However it crashes in pthread-emb in thread creation in harmless(?) assignment of result to a variable - see my post in pthread-emb thread Also I found later that pthread-psp-test hangs on Semaphore test #4 (maybe unrelated to the this thing).

Any help getting this up and running is warmly welcomed. I am really stuck. There is high probability I screwed up something as I am new to PSP development and haven't coded in C/C++ in years (I do Java). I believe many could benefit from having this library working...

libupnp-1.6.6.PSP.diff.zip
Last edited by Rex_VF5 on Tue Nov 11, 2008 4:21 pm, edited 2 times in total.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Nice! But put the diff file in a zipped file linked in the post. Diff files shouldn't be put in code blocks as the whitespace gets screwed up and people can't use it. Zipping also gives you a method of testing the integrity of the download. Diff files should only be put in code blocks when you're using it to demonstrate a point or something similar.
User avatar
Rex_VF5
Posts: 44
Joined: Wed Dec 26, 2007 6:24 am

Post by Rex_VF5 »

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

Post by J.F. »

Great! Almost perfect... now use a download service like MediaFire or SendSpace and it'll be perfect. :)

That Megashares site seems to be a huge spam generator. It's even worse than MegaUpload. :D
User avatar
Rex_VF5
Posts: 44
Joined: Wed Dec 26, 2007 6:24 am

Post by Rex_VF5 »

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

Post by J.F. »

Perfect! Sorry to be so anal about the whole thing. :)

It's great to see someone (relatively) new whose first few posts are about a library they got compiling on the PSP rather than the more typical "please help a noob" post.
User avatar
Wally
Posts: 663
Joined: Mon Sep 26, 2005 11:25 am

Post by Wally »

J.F. wrote:Perfect! Sorry to be so anal about the whole thing. :)

It's great to see someone (relatively) new whose first few posts are about a library they got compiling on the PSP rather than the more typical "please help a noob" post.

ahahaha you get the drift.

Wally
User avatar
Rex_VF5
Posts: 44
Joined: Wed Dec 26, 2007 6:24 am

Post by Rex_VF5 »

J.F. wrote:Perfect! Sorry to be so anal about the whole thing. :)

It's great to see someone (relatively) new whose first few posts are about a library they got compiling on the PSP rather than the more typical "please help a noob" post.
No problem - if there's some stuff that people are used why break it? This way more people will be willing to participate I hope. I am new to this - I created an account here some time ago to be able to talk about PS3 (didn't do much of that really). Then I bought PlayTV for PS3 and then PSP as a companion to it. I found PSP really nice thingy with broad possibilities so I decided to try to do some stuff.

Well my first posts were like "please help me" - see pthread-emb thread. Now I really need some help getting this up and running. It starts but then it crashes. I really do not have a clue why this should be. Is it problem with libupnp trying to do something pthread-emb is not ready for? I do not think so - it crashes at the end of the method trying to assign temporary variable to result being returned so I guess it would crash earlier on. Is it compiler generating incorrect stuff? Not probable but possible. Maybe I have done something wrong - incorrect switches to compiler, libraries, kernel/user stuff? Quite probable. However I am unable to pinpoint this based on the behavior...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Rex_VF5 wrote:
J.F. wrote:Perfect! Sorry to be so anal about the whole thing. :)

It's great to see someone (relatively) new whose first few posts are about a library they got compiling on the PSP rather than the more typical "please help a noob" post.
No problem - if there's some stuff that people are used why break it? This way more people will be willing to participate I hope. I am new to this - I created an account here some time ago to be able to talk about PS3 (didn't do much of that really). Then I bought PlayTV for PS3 and then PSP as a companion to it. I found PSP really nice thingy with broad possibilities so I decided to try to do some stuff.

Well my first posts were like "please help me" - see pthread-emb thread. Now I really need some help getting this up and running. It starts but then it crashes. I really do not have a clue why this should be. Is it problem with libupnp trying to do something pthread-emb is not ready for? I do not think so - it crashes at the end of the method trying to assign temporary variable to result being returned so I guess it would crash earlier on. Is it compiler generating incorrect stuff? Not probable but possible. Maybe I have done something wrong - incorrect switches to compiler, libraries, kernel/user stuff? Quite probable. However I am unable to pinpoint this based on the behavior...
Hmm... one thing to remember about PSP threading - it's cooperative, not preemptive. Other threads don't run unless you call system functions that yield time to the other threads. In networking code where you have a separate thread handling the networking, you'll often see something like "sceKernelDelayThread(100);" inserted in the main code right before looking for some network data. The delay allows higher priority threads to run, which then does the any pending actions. If nothing is pending, you are only out 100 microseconds.

Another thing to watch for is when passing data back in local vars, if you expect the data to be persistent, it needs to be a static local var.

If you post some of the code you're using, people might be able to help sopt the problem. One common problem on 3/4/5.xx based homebrew is that when it's set as a prx, people forget to set the heap size and their app runs out of memory. A common header in the main.c is like this:

Code: Select all

PSP_MODULE_INFO("lol", 0, 1, 2);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-256);
The negative heap size means allocate ALL memory except for the amount of KB specified. So -256 means all memory except for 256 KB.

A common makefile for 3/4/5.xx homebrew looks like this:

Code: Select all

TARGET = gfxtest
OBJS = main.o splash.o graphics.o framebuffer.o pspDveManager.o

CFLAGS = -O2 -G0 -Wall
CFLAGS += -DFULLSCREEN
#CFLAGS += -DINTERLACED
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LIBS = -lgif -lpng -lz -lpspgu -lm
LDFLAGS =

BUILD_PRX = 1
PSP_FW_VERSION = 401
PSP_LARGE_MEMORY = 1

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Img Mem Test

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
The main things to note are "BUILD_PRX = 1" - that's what makes this a 3/4/5.xx homebrew. The "PSP_LARGE_MEMORY = 1" is how you get the extra memory in the Slim. Use that plus the negative heap size to make the heap as large as it can on both the Phat and the Slim.
User avatar
Rex_VF5
Posts: 44
Joined: Wed Dec 26, 2007 6:24 am

Post by Rex_VF5 »

J.F. wrote:Hmm... one thing to remember about PSP threading - it's cooperative, not preemptive. Other threads don't run unless you call system functions that yield time to the other threads. In networking code where you have a separate thread handling the networking, you'll often see something like "sceKernelDelayThread(100);" inserted in the main code right before looking for some network data. The delay allows higher priority threads to run, which then does the any pending actions. If nothing is pending, you are only out 100 microseconds.
I have seen this mentioned somewhere. If you read the other thread pointed by me the whole thing crashes on assigning result to a pthread_t * on return. The thread being created is not yet started (AFAICT). I will check this more as it is called from thread pool creation.
J.F. wrote:Another thing to watch for is when passing data back in local vars, if you expect the data to be persistent, it needs to be a static local var.
Can you clarify this more please? What do you mean by "passing back in local vars"?
J.F. wrote:If you post some of the code you're using, people might be able to help sopt the problem. One common problem on 3/4/5.xx based homebrew is that when it's set as a prx, people forget to set the heap size and their app runs out of memory. A common header in the main.c is like this:
I already did! The upnp/test contains modified test_init and appropriate Makefile that will build the test application that at least for me shows the behavior. Please have a look at that.
J.F. wrote:

Code: Select all

PSP_MODULE_INFO("lol", 0, 1, 2);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
PSP_HEAP_SIZE_KB(-256);
The negative heap size means allocate ALL memory except for the amount of KB specified. So -256 means all memory except for 256 KB.
Well I have

Code: Select all

PSP_MODULE_INFO("upnpcmd", 0, 1, 0);
PSP_HEAP_SIZE_KB(2048);
in the test_init sample. I'll try to change it according to what you describe.
J.F. wrote:A common makefile for 3/4/5.xx homebrew looks like this:

Code: Select all

TARGET = gfxtest
OBJS = main.o splash.o graphics.o framebuffer.o pspDveManager.o

CFLAGS = -O2 -G0 -Wall
CFLAGS += -DFULLSCREEN
#CFLAGS += -DINTERLACED
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

LIBDIR =
LIBS = -lgif -lpng -lz -lpspgu -lm
LDFLAGS =

BUILD_PRX = 1
PSP_FW_VERSION = 401
PSP_LARGE_MEMORY = 1

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Img Mem Test

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
The main things to note are "BUILD_PRX = 1" - that's what makes this a 3/4/5.xx homebrew. The "PSP_LARGE_MEMORY = 1" is how you get the extra memory in the Slim. Use that plus the negative heap size to make the heap as large as it can on both the Phat and the Slim.
BUILD_PRX is there in the Makefile. PSP_LARGE_MEMORY is not - I can try that but I doubt it will fix the exception it throws.
Post Reply