Git Product home page Git Product logo

pspsdk's Introduction

PSP Software Development Kit

CI CI-Docker

Version 1.0+beta2 - https://github.com/pspdev/pspsdk

Introduction

The PSP Software Development Kit (PSPSDK) is a collection of Open Source tools and libraries written for Sony's Playstation Portable (PSP) gaming console. It also includes documentation and other resources developers can use to write software for the PSP.

Features

PSPSDK provides a full set of libraries for creating PSP software:

  • Stub libraries and headers for interfacing with the PSP operating system, ranging from threading libraries, file io, display driver and wifi networking.
  • Basic runtime support (crt0) for executables and libraries.
  • A libcglue library for fulfill newlib system call requirements.
  • Support code for linking with the full Standard C Library provided with the PSPDEV toolchain.
  • An implementation of the libGU graphics library. libGU provides an interface to the 2D and 3D hardware acceleration features found in the PSP's Graphic Engine.
  • An implementation of the libGUM library. libGUM provides an interface for manipulating matrices for use in 3D software.
  • A simple audio library that can be used to play back PCM audio streams.
  • Support for building static executables and PRX files (relocatable modules).

PSPSDK also includes several tools to assist in building PSP software:

  • bin2c, bin2o, and bin2s for converting binary files into C source, object files, and assembler source files, respectively.
  • mksfo and mksfoex for creating PARAM.SFO files.
  • pack-pbp and unpack-pbp for adding and removing files from EBOOT.PBP.
  • psp-config for locating PSPDEV tools and libraries.
  • psp-prxgen for converting specially made ELFs to PRX files.
  • psp-build-exports for creating export tables
  • psp-fixup-imports for fixing up import tables post-linking to remove unused functions from the executable.

Documentation for the libraries are also provided, and can be found in the doc/ directory of the PSPSDK source and binary distributions.

A library for Make (build.mak) is also included to provide an easy way to build simple programs and libraries. See any PSPSDK sample program for details on how build.mak is used.

Installation

Requirements

To use PSPSDK you must have the following software installed:

The following packages are not required to build PSPSDK, but are used to build documentation:

Installation from source

PSPSDK can be found in the Git repository located at https://github.com/pspdev/pspsdk. you can do the following command to download PSPSDK:

git clone https://github.com/pspdev/pspsdk.git

Once you've downloaded PSPSDK, run the following command from the pspsdk directory to create the configure script and support files (you must have autoconf and automake installed):

./bootstrap

PSPSDK uses the GNU autotools (autoconf and automake) for its build system. To install PSPSDK, run the following commands:

./configure
make
make doxygen-doc
make install

Note

If you haven't installed Doxygen or don't want to build the library documentation, you can skip the make doxygen-doc command.

Tip

You can use build-and-install.sh script for convenience.

Notes

  • This is a BETA release of PSPSDK. Some of the features and tools described here may not be fully implemented.

  • By default PSPSDK will install into the directory where the PSPDEV toolchain is installed. If you decide to install PSPSDK somewhere else then you must define a PSPSDK environment variable that points to your alternate directory. The psp-config build utility will look for PSPSDK in the location specified in the PSPSDK environment variable first, or use its own location to determine where PSPSDK is installed.

  • The Makefile templates provided by the sample code are designed for building a single executable or a library, but not both. If you plan on using these templates in your project to build both libraries and executables be aware that you will have to structure your project so that each library and executable are built in a seperate directory.

Bugs

If you find a bug in PSPSDK, open an issue at https://github.com/pspdev/pspsdk/issues. If possible, include any code or documentation that can be used by the PSPSDK developers to recreate the bug.

License

PSPSDK is distributed under a BSD-compatible license, with the exception of the files located in tools/PrxEncrypter. The files located in the tools/PrxEncrypter directory are subject to the terms of the GNU General Public License version 3. See the LICENSE files for more information.

Resources

Official Source Documentation

This is generated automatically from the repository master branch: https://pspdev.github.io/pspsdk/

Discord

You can find PSPDev Maintainers over at https://discord.gg/bePrj9W in the #psp-toolchain channel :)

Code of Conduct

We're all here to build software and have fun with our PSPs, and everyone deserves to be able to do that without fear of harassment.

Please follow our Code of Conduct, and we encourage you to contact the PSPDev Maintainers if you think something isn't right.

Thanks

The pspsdk developers wish to thank all the people who have contributed bug fixes, ideas and support for the project. Also big thanks to nem for kicking off PSP development with all his work, the original imports system is based on his work in the hello world demo.

pspsdk's People

Contributors

artart78 avatar beyley avatar bitlinker avatar bucanero avatar bvdaakster avatar carstene1ns avatar crow-bar avatar davidgfnet avatar dbeef avatar diamant3 avatar felix-dev avatar fjtrujy avatar iridescentrose avatar irixxxx avatar joel16 avatar korigamik avatar mills32 avatar motolegacy avatar pineapplemachine avatar pyroesp avatar rofl0r avatar ryancaicse avatar sajattack avatar samrh avatar sharkwouter avatar sokus avatar taba256 avatar wally4000 avatar wintermute avatar xyzshantaram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pspsdk's Issues

libpspdmac doesn't work

To use the SceDmacMemcpy function you need to include pspdmac.h and link to libpspdmac. When I then try to use the function, I see the following error while linking:

(.text+0xae84): undefined reference to `_Z13sceDmacMemcpyPvPKvj'

So it seems right now this function is unusable.

Busted Samples

Tracking issue for broken samples (of which there are many)
Checking the box indicates the sample has been fixed.
Please comment on this issue rather than filing a separate one for a broken sample.

  • debug/profiler

Mip Mapping sample

I spent a few days trying to make this work because there was little info about it on the internet. Also pspsdk did not have a sample code for this.

So here it is, a mip mapping sample :).

MIPMAPPING.zip

SIO sample firmware version limitation

Trying to run the SIO sample (samples -> debug -> sio). It compiles fine and runs fine in ppsspp however when running on real hardware running infinity 6.61 it fails to load with a generic game could not be started message.

I'm going to downgrade to 6.60 and try (doubt such a minor downgrade will matter).

Just wondering is this expected to run on the latest firmware versions or does it have a limitation to only run on version X? I see it hasn't been modified since 2010 so i suspect the latter.

I would add this to the general sample busted issue but not sure if it is actually busted, or just missing some documentation.

Thanks.

sceUtilityLoadNetModule, audio and thread issue

I have noticed a problem with sceUtilityLoadNetModule.

If I load PSP_NET_MODULE_COMMON and PSP_NET_MODULE_INET and then I call pspAudioInit(), I will not be able to create a thread with sceKernelCreateThread. If a thread already exists in my game, it will be stopped.
sceKernelCreateThread will always return a negative thread id.

sceUtilityLoadNetModule(PSP_NET_MODULE_COMMON);
sceUtilityLoadNetModule(PSP_NET_MODULE_INET);

pspAudioInit();
SceUID thd_id = sceKernelCreateThread("thread1", thread1, 0x38, 0x10000, 0, NULL);
if (thd_id >= 0)
{
    sceKernelStartThread(thd_id, 0, 0);
}
else
{
    pspDebugScreenPrintf("Bad thread id\n");
}

This should prints Bad thread id.

I don't have a PSP 2000/3000 to test but I have the problem on my PSP 1000 and Street. My FW version is 6.61.
I think there is an issue with sceUtilityLoadNetModule or something else about network because most of network samples do not work on my PSP 1000, see: #45 (comment)

Small compilable sample code with the issue (there is a precompiled EBOOT too): No_Thread_Issue.zip

VFPU lv.q and ulv.q

Hi, I read PSP 1000 has a problem in the VFPU, it looks like the instruction "ulv.q" is broken. Is that true?.

I could replace ulv with lv in some functions, like the "look at", which calculates the view matrix for the camera. But it seems to cause a lot of truoble and crashes in functions to translate, rotate and scale matrix (on my psp 2000 and on ppsspp emulator).

I also read lv needs aligned data to work, so I tried to add "attribute((aligned(16)))" to function parameters. This only worked with the "look at" function.

I'd really like to know more about this, and why lv crashes so much.

Thanks.

Wrong freetype path

Hello,

There is a problem, we can't load freetype because of a wrong path.
Freetype folder is located at pspdev\psp\include\freetype2\freetype
I need to move the freetype2 folder's content in the include folder to get freetype working.

`__retarget_lock_init.o, error: invalid type argument of ‘->’`

  CC       __retarget_lock_init.o
../../../src/libcglue/lock.c: In function ‘__retarget_lock_init’:
../../../src/libcglue/lock.c:31:36: error: invalid type argument of ‘->’ (have ‘_LOCK_T’ {aka ‘int’})
   31 |     sceKernelCreateLwMutex(&(*lock)->mutex, "lock API mutex", 0, 0, 0);
      |                                    ^~

What's went wrong? Maybe change compiler?
It's arch linux.

Install psp-gcc and try psp-sdk.
paru psp-sdk

also download latest version from github, and try again, same error

List of possible contributions.

I've noticed a lot more interest in the pspsdk recently, which is fantastic.

I wanted to open up a conversation about a list of required/wanted contributions. I would like to contribute more to this project but not sure where I should put my resources.

I've started on working on compiling libcurl, specifically with SSL. I know at one point libcurl was available https://github.com/jdek/jim-pspware however is quite old so I will be moving to a more recent version.

Environmental Variables

hello. I'm having an issue compiling infinity, and I think it may have something to do with environmental variables. it can't find pspstub.s. is there a specific environmental variable for this file or the include path in /usr/local/pspdev/psp/sdk/include ? thank you.

new dependency on pthread-embedded

after forcibly updating to newlib 4.4.0 in order to be able to still use this repo, i now get compile errors regarding sys/pte_generic_osal.h

osal.c:24:34: fatal error: sys/pte_generic_osal.h: No such file or directory
compilation terminated.
osal.c:24:34: fatal error: sys/pte_generic_osal.h: No such file or directory
compilation terminated.
osal.c:24:34: fatal error: sys/pte_generic_osal.h: No such file or directory
compilation terminated.
make[3]: *** [osal.o] Error 1
make[3]: *** Waiting for unfinished jobs....
osal.c:24:34: fatal error: sys/pte_generic_osal.h: No such file or directory
compilation terminated.
make[3]: *** [__pspStubThreadEntry.o] Error 1
make[3]: *** [pte_osInit.o] Error 1
make[3]: *** [pte_osTerminate.o] Error 1
tls-helper.c:21:34: fatal error: sys/pte_generic_osal.h: No such file or directory
compilation terminated.
make[3]: *** [tls-helper.o] Error 1

before newlib 4.4.0 "support" was added (aka dropping support for anything else), this pthread library was optional, and it'd be nice if it stayed that way.

sceMp3Init() fails

compile the mp3 sample from the sdk and run it.
sceMp3Init returns 0x807F00FD

reproduced on 5.00-m33 and 6.60-ME cfw on psp-1000 and psp-2000

i found no solution so far unfortunately.

configure doesn't set default CFLAGS

usually when using autoconf-based configure scripts, the expectation is that when no CFLAGS are passed by the user (via command line or environment variables), the default of "-O2 -g" is used. this is currently not the case with the configure script. therefore, if the SDK is built without setting CFLAGS externally, no optimization nor debug info is available.

profiler crash

In my PSP Go 6.60 [Model: 5g] i can't get the sample to work from /samples/debug/profiler. Even the usual attempt to access the main address forces the crash.

Example:

PSP_MODULE_INFO("Profiler test", 0x1000, 1, 1);

/* main */
pspKernelSetKernelPC();
PspDebugProfilerRegs* prof_regs = (PspDebugProfilerRegs*)PROFILER_REG_BASE; // crash here!

Similarly, the function of enabling and disabling the Profiler, because it uses the same address.

Does this even work for anyone? Yes, I still think that something is cut in the PSP Go. One way you need to somehow get access to the Profiler, because the optimization problem has long been a problem when creating homebrew on the PSP. I try to dig in this direction, but so far I haven't found anything useful.

Sorry for my bad English.

Printf function isn't working

During the migration and upgrade of newlib I have faced that printf function is not working anymore in the current toolchain.
(@wally4000 double-checked it.)

I have been investigating for some days till I found why it wasn't working.

On the crt files we have __psp_libc_init as weak reference
https://github.com/pspdev/pspsdk/blob/master/src/startup/crt0.c#L41

/* Allow newlib/psplibc to provide an init hook to be called before main */
extern void __psp_libc_init(int argc, char *argv[]) __attribute__((weak));

Then in the _start method (entrance point of every single execution), we have:
https://github.com/pspdev/pspsdk/blob/master/src/startup/crt0.c#L78

	/* Call libc initialization hook */
	if(__psp_libc_init != NULL)
		__psp_libc_init(argc, argv);

Till this point everything looks fine, I think that the developer who implement this, was thinking:
"if user links the binary with libpsplibc.a then it will call the __psp_libc_init function"

Then on the build.mak that we usually use for compilation we have:
https://github.com/pspdev/pspsdk/blob/master/src/base/build.mak#L72

ifeq ($(USE_PSPSDK_LIBC),1)
# Use the pspsdk libc
PSPSDK_LIBC_LIB = -lpsplibc
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else

Cool! Everything still looks fine, where is the problem then?
The problem is that the __psp_libc_init definition in the libpsplibc.a is as well being weak:
https://github.com/pspdev/pspsdk/blob/master/src/libc/init.c#L20

__attribute__((weak, constructor))
void _pspsdk_libc_init()
{
    _pspsdk_alloc_init();
    _pspsdk_stdio_init();
    _pspsdk_stdlib_init();
}

So basically all the references of __psp_libc_init in the binary are weak, with the consequences of __psp_libc_init never being executed even if the user adds the libpsplibc.a during the linking process.

In my opinion, there are 2 solutions:

  1. To remove the weak refecence in the crt files
  2. To remove the weak reference in the libpsplibc.a

I honestly prefer the first one, and it is how I have done in the toolchain that I'm preparing.

Thanks

Global/Static variables never initialized

Hello, I'm trying to create a string outside of the main function.
Instead of printing hello twice, it's printing hello once.
Looks like that global constructors are never called. Not only with strings but with some other things like std::map.
I heard it might come from crtbegin and crtend or newlib.

#include <string>
#include <pspkernel.h>
#include <pspdisplay.h>
#include "psp/callbacks.h"

PSP_MODULE_INFO("XENITY ENGINE", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);

auto str = std::string("Hello"); //Same problem with std::string str = "hello";

int main(int argc, char *argv[])
{
    SetupCallbacks();
    auto str2 = std::string("Hello");
    pspDebugScreenInit(); // Initialize the debug screen
    pspDebugScreenPrintf(str.c_str()); // Print nothing or lot of spaces
    pspDebugScreenPrintf(str2.c_str()); // Print "Hello"
    while (true)
    {
        sceDisplayWaitVblankStart();
    }
}

Remove Corrupt PrxEncrypter from Tools

PrxEncrypter is breaking the pspsdk build. It needs to be removed immediately.
This can be done by moving the folder out of tools and editing pspsdk/tools/Makefile.am to comment out the line like this:
#SUBDIRS = PrxEncrypter
The pack-pbp command (should ideally be called elf2pbp) will then build with a few minor warnings about fread().
The reason for this is that Stackless Python is missing or has obfuscated/obstructed bindings to libgu for the graphics core.
Just breaking the C++ toolchain to favour Python is not the answer, both are required.

Remove -G0 flag in build_prx.mak ?

I've been working on plugins lately and using build_prx.mak to compile the source.
For some reason the -G0 flag is in the CFLAGS of the build_prx.mak file and I don't think it should be in there.

CFLAGS := $(addprefix -I,$(INCDIR)) -G0 $(CFLAGS)

The one argument I have against it being there is that it messes with debugging the plugin using psplink and psp-addr2line.

Unless there's a specific reason why -G0 has been added there I'm unaware of, I think it should be removed.

PS: Could be I'm just bad at using psplink too 🤷🏻‍♂️

Wrong struct format of SceNetAdhocctlParams

SceNetAdhocctlParams struct have a wrong format, it should have the bssid and nickname position swapped (at least on newer firmware, not sure about old firmware) otherwise games like Ys vs. Sora no Kiseki will shows the wrong game room name (gibberish/random letters) taken from mac address (bssid) instead of the player's nickname when a PSP emulator is using the wrong struct format like this:

struct SceNetAdhocctlParams
{
	/** Channel number */
	int channel;
	/** Name of the connection */
	char name[8];
	/** The BSSID */
	unsigned char bssid[6];
	/** Nickname */
	char nickname[128];
};

PS: This was tested by comparing the struct contents taken from Ys vs. Sora no Kiseki on JPCSP using prx files from official firmware 6.xx

Should have similar format to what VitaSdk have:

typedef struct SceNetAdhocctlParameter {
     int channel;
     struct SceNetAdhocctlGroupName groupName;
     struct SceNetAdhocctlNickname nickname;
     struct SceNetAdhocctlBSSId bssid;
 } SceNetAdhocctlParameter;

Missing `remove(const char *path)`

The remove function from stdio appears to be missing.

The implementation could probably be a wrapper around __set_errno(sceIoRemove(path)).

E.g. PS2 SDK does this:
https://github.com/ps2dev/ps2sdk/blob/6b656d1ae18dd2bb75a6caa03346cf9f933c12c6/ee/libcglue/src/glue.c#L576C17-L582

Whereas the PSP SDK currently stubs out the _unlink function (called by remove) to always fail:

pspsdk/src/libcglue/glue.c

Lines 603 to 608 in 2f723c3

#ifdef F__unlink
int _unlink(const char *path) {
errno = ENOSYS;
return -1; /* not supported */
}
#endif

Undefined reference to `__builtin_allegrex_wsbh'

When trying to compile pspsdk/src/samples/net/simple, it results in the following errors:

rm -f netsample.elf  main.o PARAM.SFO EBOOT.PBP EBOOT.PBP
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O0 -G0 -Wall -g -D_PSP_FW_VERSION=150   -c -o main.o main.c
psp-gcc -I. -I/usr/local/pspdev/psp/sdk/include -O0 -G0 -Wall -g -D_PSP_FW_VERSION=150  -L. -L/usr/local/pspdev/psp/sdk/lib   main.o  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk -lc -lpspnet -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility -lpspuser -lpspkernel -o netsample.elf
main.o: In function `make_socket':
(.text+0x17c): undefined reference to `__builtin_allegrex_wsbh'
main.o: In function `make_socket':
(.text+0x190): undefined reference to `__builtin_allegrex_wsbw'
main.o: In function `start_server':
(.text+0x480): undefined reference to `__builtin_allegrex_wsbh'
collect2: error: ld returned 1 exit status
/usr/local/pspdev/psp/sdk/lib/build.mak:176: recipe for target 'netsample.elf' failed
make: *** [netsample.elf] Error 1```

List of broken examples

I ran through these examples, and those marked FAILED are the ones that caused some sort of exception. I compiled each example with PSP_FW_REVISION=660.

Below is the list.

Status Filename
FAILED morphskin/morphskin.prx
PASSED shadowprojection/shadowprojection.prx
PASSED logic/logic.prx
PASSED speed/speed.prx
FAILED envmap/envmap.prx
FAILED beginobject/beginobject.prx
FAILED splinesurface/splinesurface.prx
PASSED blend/blend.prx
FAILED sprite/sprite.prx
FAILED spharm/spharm.prx
PASSED skinning/skinning.prx
PASSED blit/blit.prx
PASSED copy/copy.prx
PASSED text/gufont.prx
FAILED morph/morph.prx
FAILED reflection/reflection.prx
FAILED zbufferfog/zbufferfog.prx
FAILED cube/cube.prx
FAILED integerdrawing/integerdrawing.prx
FAILED vertex/vertex.prx
FAILED timing/timing.prx
FAILED lights/lights.prx
FAILED signals/signals.prx
PASSED lines/lines.prx
PASSED clut/clut.prx
FAILED ortho/ortho.prx
FAILED rendertarget/rendertarget.prx
FAILED celshading/celshading.prx

Some resource leaks

File fp is not closed at Line 135 and 142

pspsdk/tools/psp-prxgen.c

Lines 125 to 146 in d019dbc

fp = fopen(file, "rb");
if(fp != NULL)
{
(void) fseek(fp, 0, SEEK_END);
size = ftell(fp);
rewind(fp);
if(size < sizeof(Elf32_Ehdr))
{
fprintf(stderr, "Error, invalid file size\n");
break;
}
data = (unsigned char *) malloc(size);
if(data == NULL)
{
fprintf(stderr, "Error, could not allocate memory for ELF\n");
break;
}
(void) fread(data, 1, size, fp);
fclose(fp);

[fix] missing inlude in pspge.h

pspge.h needs

#include <psptypes.h>

otherwise type u32 will be undefined

if you cannot do this for any reason, I will file a pull request, but actually I don't want to make a fork just because of this

pspUtilityDialogCommon struct error.

psp-gcc -I. -IC:/pspsdk/psp/sdk/include -G0 -Wall -O2 -D_PSP_FW_VERSION=150 -c
-o main.o main.c
In file included from main.c:4:
C:/pspsdk/psp/sdk/include/psputility_htmlviewer.h:112: error: expected specifier
-qualifier-list before 'pspUtilityDialogCommon'
make: *** [main.o] Error 1

pspaudiolib.c:14:20: fatal error: stdlib.h: No such file or directory

Compiling on Arch with all dependencies met. Happens when /usr/local/pspdev is owned by the user and compiling starts with ./toolchain.sh, or when root runs the script through sudo ./toolchain-sudo.sh, or even using the AUR package

psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -DF_sceAudio_driver_0026 sceAudio_driver.S -c -o sceAudio_driver_0026.o
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -DF_sceAudio_driver_0027 sceAudio_driver.S -c -o sceAudio_driver_0027.o
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -MT pspaudiolib.o -MD -MP -MF .deps/pspaudiolib.Tpo -c -o pspaudiolib.o pspaudiolib.c
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -I../../src/base -I../../src/user -I../../src/debug -MT sceAudiocodec.o -MD -MP -MF .deps/sceAudiocodec.Tpo -c -o sceAudiocodec.o sceAudiocodec.S
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -DF_sceAudiocodec_0000 sceAudiocodec.S -c -o sceAudiocodec_0000.o
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -DF_sceAudiocodec_0001 sceAudiocodec.S -c -o sceAudiocodec_0001.o
pspaudiolib.c:14:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
psp-gcc -DHAVE_CONFIG_H -I. -I../.. -I../../src/base -I../../src/user -I../../src/debug  -I/opt/local/include  -I/opt/local/include -G0 -Wall -DF_sceAudiocodec_0002 sceAudiocodec.S -c -o sceAudiocodec_0002.o
make[3]: *** [Makefile:494: pspaudiolib.o] Error 1
make[3]: *** Waiting for unfinished jobs....
mv -f .deps/sceAudiocodec.Tpo .deps/sceAudiocodec.Po
make[3]: Leaving directory '/home/USER/psptoolchain/build/pspsdk/src/audio'
make[2]: *** [Makefile:393: all-recursive] Error 1
make[2]: Leaving directory '/home/USER/psptoolchain/build/pspsdk/src'
make[1]: *** [Makefile:465: all-recursive] Error 1
make[1]: Leaving directory '/home/USER/psptoolchain/build/pspsdk'
make: *** [Makefile:405: all] Error 2
../scripts/006-pspsdk-stage2.sh: Failed.

[ISSUE] SDL2_mixer: undefined reference to `ov_*`

I have an issue compiling this, is it my mistake? i tried #include <SDL2/SDL.h> and #include <SDL2/SDL_mixer.h> but the issue is the same :(

This is the output of the error:

/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: /usr/local/pspdev/psp/lib/libSDL2_mixer.a(music_ogg.o): in function `OGG_Load':
(.text+0x10): undefined reference to `ov_clear'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x18): undefined reference to `ov_clear'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x20): undefined reference to `ov_info'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x24): undefined reference to `ov_info'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x2c): undefined reference to `ov_comment'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x30): undefined reference to `ov_comment'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x38): undefined reference to `ov_open_callbacks'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x3c): undefined reference to `ov_open_callbacks'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x44): undefined reference to `ov_pcm_total'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x48): undefined reference to `ov_pcm_total'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x50): undefined reference to `ov_read'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x54): undefined reference to `ov_read'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x5c): undefined reference to `ov_time_seek'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x60): undefined reference to `ov_time_seek'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x68): undefined reference to `ov_pcm_seek'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x6c): undefined reference to `ov_pcm_seek'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x74): undefined reference to `ov_pcm_tell'
/usr/local/pspdev/lib/gcc/psp/11.2.0/../../../../psp/bin/ld: (.text+0x78): undefined reference to `ov_pcm_tell'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sdl2_mixer.dir/build.make:84: sdl2_mixer] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/sdl2_mixer.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

this is the c code:

#include <SDL.h>
#include <SDL_mixer.h>

// Define MAX and MIN macros
#define MAX(X, Y) (((X) > (Y)) ? (X) : (Y))
#define MIN(X, Y) (((X) < (Y)) ? (X) : (Y))

// Define screen dimensions
#define SCREEN_WIDTH    480
#define SCREEN_HEIGHT   272

// Define music path
#define MUSIC_PATH "test.ogg" // PPSSPP system
// #define MUSIC_PATH "ms0/MUSIC/test.ogg" // PSP system

int main(int argc, char **argv) {
	// Initialize sdl
	SDL_Init(SDL_INIT_VIDEO | 
		SDL_INIT_AUDIO |
		SDL_INIT_GAMECONTROLLER
	);

	// Initialize sdl2_mixer
	Mix_OpenAudio(22050, MIX_DEFAULT_FORMAT, 2, 4096);

	SDL_Window *win = SDL_CreateWindow(
		"psp_win",
		SDL_WINDOWPOS_UNDEFINED,
		SDL_WINDOWPOS_UNDEFINED,
		SCREEN_WIDTH,
		SCREEN_HEIGHT,
		0
	);

	// Create Renderer
	SDL_Renderer *renderer = SDL_CreateRenderer(
		win, -1, SDL_RENDERER_ACCELERATED
	);

	// Load ogg file
	Mix_Music *ogg_file = Mix_LoadMUS(MUSIC_PATH);
	if (!ogg_file) {
		return -1;
	}

	SDL_Rect rect;

	// Square dimensions: Half of the min(SCREEN_WIDTH, SCREEN_HEIGHT)
        rect.w = MIN(SCREEN_WIDTH, SCREEN_HEIGHT) / 2;
	rect.h = MIN(SCREEN_WIDTH, SCREEN_HEIGHT) / 2;

        // Square position: In the middle of the screen
        rect.x = SCREEN_WIDTH / 2 - rect.w / 2;
	rect.y = SCREEN_HEIGHT / 2 - rect.h / 2;


        // Declare rects of pause symbol
        SDL_Rect pause_rect1, pause_rect2;

        pause_rect1.h = rect.h / 2;
	pause_rect1.w = 40;
        pause_rect1.x = rect.x + (rect.w - pause_rect1.w * 3) / 2;
        pause_rect1.y = rect.y + rect.h / 4;
        pause_rect2 = pause_rect1;
	pause_rect2.x += pause_rect1.w * 2;

	int running = 1;
	SDL_Event e;
	while (running) {

		if (SDL_PollEvent(&e)) {
			switch(e.type) {
				case SDL_QUIT:
				    running = 0;
				break;
				case SDL_CONTROLLERDEVICEADDED:
                                    SDL_GameControllerOpen(e.cdevice.which);
                                break;
				case SDL_CONTROLLERBUTTONDOWN:
				if (e.cbutton.button == SDL_CONTROLLER_BUTTON_X) {
						if (Mix_PausedMusic()) {
							Mix_ResumeMusic();
						} else {
							Mix_PauseMusic();
						}
					}

					if (e.cbutton.button == SDL_CONTROLLER_BUTTON_START) {
						running = 0;
					}
				break;		
			}
		}

		// Initialize renderer color white for the background
        SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);

        // Clear screen
        SDL_RenderClear(renderer);

        // Set renderer color blue to draw the square
        SDL_SetRenderDrawColor(renderer, 0x19, 0x71, 0xA9, 0xFF);

    	// Draw filled square
        SDL_RenderFillRect(renderer, &rect);

        // Check pause status
        if(Mix_Paused(-1)) {
            // Set renderer color white to draw the pause symbol
        	SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);

            // Draw pause symbol
            SDL_RenderFillRect(renderer, &pause_rect1);
            SDL_RenderFillRect(renderer, &pause_rect2);
        }

		// Update screen
    	SDL_RenderPresent(renderer);
	}

	Mix_FreeMusic(ogg_file);
	SDL_DestroyRenderer(renderer);
	SDL_DestroyWindow(win);
	Mix_CloseAudio();
	SDL_Quit();

	return 0;
}

this is my cmakelists.txt

cmake_minimum_required(VERSION 3.0)

project(sdl2_mixer)

add_executable(${PROJECT_NAME} main.c)

find_package(PkgConfig REQUIRED)
pkg_search_module(SDL2 REQUIRED sdl2)

target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})

target_link_libraries(${PROJECT_NAME} PRIVATE
    ${SDL2_LIBRARIES}
)

if(PSP)
    target_link_libraries(${PROJECT_NAME} PRIVATE
        SDL2main
        SDL2_mixer
    )
    create_pbp_file(
        TARGET ${PROJECT_NAME}
        ICON_PATH NULL
        BACKGROUND_PATH NULL
        PREVIEW_PATH NULL
        TITLE ${PROJECT_NAME}
    )
endif()

sceGeEdramSetSize not working properly

Hello, I'm trying to use sceGeEdramSetSize(0x400000) to increase the vram but it's not working on my PSP Street.
Any idea why this code doesn't work?
Thanks!

#include <string>
#include <pspkernel.h>
#include <pspdisplay.h>
#include <pspge.h>

PSP_MODULE_INFO("PSP VRAM ISSUE", 0, 1, 0);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

int main(int argc, char *argv[])
{
    pspDebugScreenInit(); // Initialize the debug screen

    if (sceGeEdramSetSize(0x400000) == 0)
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ok\n"); // Never called
    }
    else
    {
        pspDebugScreenPrintf("sceGeEdramSetSize 4MB ERROR\n"); // Called
    }

    pspDebugScreenPrintf(std::to_string(sceGeEdramGetSize()).c_str()); // Prints "2097152" instead of the double

    while (true)
    {
        sceDisplayWaitVblankStart();
    }
}

Header(s) cannot be included warning-free with `-Wundef`

I am currently trying to build SDL cleanly with -Wundef.
When using the psddev sdk, it fails with:

 In file included from /usr/local/pspdev/psp/sdk/include/pspuser.h:23,
                 from /usr/local/pspdev/psp/sdk/include/pspkernel.h:17,
                 from /__w/SDL/SDL/src/render/psp/SDL_render_psp.c:27:
/usr/local/pspdev/psp/sdk/include/pspsysmem.h:105:5: error: "_PSP_FW_VERSION" is not defined, evaluates to 0 [-Werror=undef]
  105 | #if _PSP_FW_VERSION >= 150
      |     ^~~~~~~~~~~~~~~

#if _PSP_FW_VERSION >= 150

Because _PSP_FW_VERSION is used unguarded, it should be used as following instead:

#if defined(_PSP_FW_VERSION) && _PSP_FW_VERSION >= 150

RFC: failsafe dealing with _PSP_FW_VERSION

i've been trying to port my gnuboy fork to psp, and while it works fine in PPSSPP, it crashes on real psp with fw 6.60, which might or might not be due to wrong struct layouts when anything using these structs has been compiled with the wrong value for _PSP_FW_VERSION. so i recompiled pspsdk, GL, SDL2 etc with -D_PSP_FW_VERSION=600, yet it still crashes (i might have missed some library which is still using the default of 150).

which made me think of how this imo annoying situation with different struct layouts can be solved and the SDK user doesn't have to deal with it at all.
musl libc solves similar issues by having wrappers for syscalls that use structs that for some reason might be different in userspace than what the kernel expects.

let's say there's a syscall void sceFooBar(struct sceFooBarStruct*); and a struct sceFooBarStruct that would currently look like:

struct sceFooBarStruct {
  int x;
#if _PSP_FW_VERSION > 150
  int foo; /* fw 1.5.1 added foo member in the middle of struct */
#endif 
  int y;
};

this clearly raises a lot of issues, a user of sceFooBar() that doesn't have the entire sdk and all libraries compiled with the exact firmware macro then what this will run on may either pass a struct that's too short (which will result in the kernel overwriting or reading some unrelated memory) or values intended for the y slot will end up somewhere else.

this could be dealt with by designing the struct like this:

struct sceFooBarCompatStruct {
  int x;
  int y;
  int foo; /* put new member at the end */
};

struct sceFooBarStruct150 {
  int x;
  int y;
};

struct sceFooBarStructGt150 {
  int x;
  int foo;
  int y;
};

and then making sceFooBar() a wrapper:

void sceFooBar(struct sceFooBarCompatStruct *foo) {
  struct sceFooBarStruct150 f150;
  struct sceFooBarStructGt150 later;
  if (sceKernelDevkitVersion() <= 0x01050001) {
     f150.x = foo->x;
     f150.y = foo->y;
     realSceFooBar(&f150);
  } else {
     later.x = foo->x;
     later.y = foo->y;
     later.foo = foo->foo;
     realSceFooBar(&later);
  }
}

from what i can tell this would completely eliminate the need to set _PSP_FW_VERSION and would make the code work on all firmware versions.
i'm not sure how the actual syscalls are done but from what i've seen from psp-fixup-imports tool it looks like stubs are used that could be used for wrapping syscalls like this.

please let me know what you think of this proposal or if you have better ideas.

Missing header in psprtc.h

I tried to include psprtc.h on my project and I found that psptypes.h needs to be included before psprtc.h. Or you will have some errors about types.
I think we should add an include of psptypes.h in psprtc.h, I'm not doing a pullrequest because I can't test if this can cause some problems when compiling the sdk.

add a sample for pspge

there is no sample that demonstrates how to the functions included in pspge.h

I don't have a lot of time to write this but I'll do so eventually if nobody has pushed it

Optimization

In unpack-pbp.c, line 165, you should not allocate new memory with every iteration of the loop. This degrades performance a lot and is not required. Instead, do it before the loop. The free() call on line 184 needs to be after the loop as well in this case. Finally, when you are encountering an error, you return without freeing the memory. This should be done in every if-statement. Strictly speaking, it doesn't matter because here it's the main method and you are terminating anyway, but other projects use this code outsourced into a separate method and are affected negatively by this "mistake". Please take this into consideration. I could code a fix myself, but I'm new to Gihub and don't feel confident with forking yet, and certainly won't start by messing up this excellent project - so I thought I'd just open it as an issue.

What is the FOPEN_MAX of the real PSP console?

Hello!
It seems that only 10 files could be opened simultaneously in the PSP mode of a PSV console. So, is it the limitation of a real PSP console? What is the FOPEN_MAX of a real PSP console?
BTW, in the emulator PPSSPP, much more files could be opened simultaneously.

Thanks!

CMake using the incorect OUTPUT_NAME but stripping.

I've been working on a project that is using Cmake to configure the code. In my case I'm working on RSDKv5-Decompilation
The project renames the project according to what rev of the engine your building RSDKv5 or RSDKv5U.

set(RETRO_NAME "RSDKv5")

if(RETRO_REVISION STREQUAL "3")
    set(RETRO_NAME "RSDKv5U")
endif()

set(RETRO_OUTPUT_NAME ${RETRO_NAME} CACHE STRING "The exported name of the executable.")
set_target_properties(RetroEngine PROPERTIES OUTPUT_NAME ${RETRO_OUTPUT_NAME})

With the current version of CreatePBP.cmake all but Stripping use

$<TARGET_FILE_DIR:${ARG_TARGET}>/${ARG_TARGET}

While stripping uses

$<TARGET_FILE:${ARG_TARGET}>

I'm not versed with Cmake but changing out the first with the later fixes problems with my configuring setup.

undefined reference to `sceKernelVolatileMemTryLock'

Hello.
I'm trying to use sceKernelVolatileMemTryLock, but it fails to compile.
main.c:

#include <pspkernel.h>
#include <pspsuspend.h>

PSP_MODULE_INFO("template", 0, 1, 1);

PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER);

int main()
{
	sceKernelVolatileMemTryLock(0, NULL, NULL);

	return 0;
}

result:

psp-gcc -I. -I/home/taba/pspdev/psp/include -I/home/taba/pspdev/psp/sdk/include -G0 -O2 -Wall -D_PSP_FW_VERSION=150  -L. -L/home/taba/pspdev/psp/lib -L/home/taba/pspdev/psp/sdk/lib  -Wl,-zmax-page-size=128  main.o  -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspnet -lpspnet_apctl -o template.elf
/home/taba/pspdev/bin/../lib/gcc/psp/11.2.0/../../../../psp/bin/ld: main.o: in function `main':
(.text.startup+0x10): undefined reference to `sceKernelVolatileMemTryLock'
collect2: エラー: ld はステータス 1 で終了しました
make: *** [/home/taba/pspdev/psp/sdk/lib/build.mak:162: template.elf] エラー 1

This typo is causing the problem.
https://github.com/pspdev/pspsdk/blob/e20ebe38220705abcbd6693ee2161170fb9665f1/src/user/Makefile.am#L21C141-L21C164

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.