PSPSDK Documentation

repository·master·Indexed 22 days ago

https://github.com/pspdev/pspsdk

An open-source software development kit for the Sony PlayStation Portable (PSP). It provides core libraries for graphics (libGU), audio, networking, and OS interfacing, along with a suite of build tools such as psp-config, psp-prxgen, and PrxEncrypter. The SDK includes support for profiling C++ programs via gprof and psp-gprof, and provides a build.mak library to simplify the creation of PSP executables and PRX modules.

Tokens
3K
Snippets
11
Records
19
Agent score
78%

What's inside PSPSDK

  1. Overview of PSPSDK libraries and tools

    master

    PSPSDK provides a comprehensive environment for PSP development, including core libraries for OS interfacing, graphics, and audio, as well as specialized build tools.

    Core Libraries

    • OS Interface: Stub libraries and headers for threading, file I/O, display drivers, and WiFi networking.
    • Runtime Support: Basic crt0 support for executables and libraries.
    • libcglue: Fulfills newlib system call requirements.
    • libGU: Interface for 2D and 3D hardware acceleration (Graphic Engine).
    • libGUM: Interface for 3D matrix manipulation.
    • Audio: Simple library for PCM audio stream playback.
    • Standard C Library: Support for linking with the full C library provided by the PSPDEV toolchain.

    Build Tools

    • bin2c, bin2o, bin2s: Convert binary files to C source, object files, or assembler source.
    • mksfo, mksfoex: Create PARAM.SFO files.
    • pack-pbp, unpack-pbp: Manage files within EBOOT.PBP.
    • psp-config: Locate PSPDEV tools and libraries.
    • psp-prxgen: Convert specific ELFs to PRX files.
    • psp-build-exports: Create export tables.
    • psp-fixup-imports: Fix import tables post-linking to remove unused functions.
    • build.mak: A library for Make to simplify building programs and libraries.
  2. Build projects using build.mak

    master

    PSPSDK includes a build.mak library to simplify the creation of simple programs and libraries.

    Important Note on Project Structure: The provided Makefile templates are designed to build either a single executable or a library, but not both in the same context. If your project requires both, you must structure your project so that each library and executable is built in a separate directory.

  3. Install PSPSDK from source

    master

    To build and install PSPSDK from the Git repository, ensure you have the required dependencies installed and follow the autotools build process. You can also use the provided build-and-install.sh script for a more convenient installation.

    Requirements

    • PSPDEV Toolchain
    • GNU Make
    • Git client
    • GNU autoconf and automake (GNU Autotools)
    • Zlib development libraries and headers

    Optional (for documentation): Doxygen and Graphviz.

    # 1. Clone the repository
    git clone https://github.com/pspdev/pspsdk.git
    cd pspsdk
    
    # 2. Prepare the build environment
    ./bootstrap
    
    # 3. Configure, build, and install
    ./configure
    make
    make doxygen-doc
    make install
  4. Encrypt savegames using the sceChnnlsv module

    master

    You can perform savegame encryption by using the sceChnnlsv module directly.

    Important Constraints:

    • Mode Requirement: This functionality currently only works in VSH mode (for example, when running via the TIFF exploit).
    • Save Formats: It supports both old and new save formats. The supported SaveParam structure sizes are:
      • 0x5c8 (Old format)
      • 0x5dc (New format)
      • 0x600 (New format)
    • Encryption Keys: For new format saves, a game-specific encryption key is required.
  5. Profile C++ programs with gprof

    master

    To enable profiling in C++ programs using the PSPSDK, you must configure your build flags to include profiling instrumentation and link against the C++ standard library.

    Build Requirements

    Add the following flags to your build configuration:

    • CFLAGS: -g -pg
    • LDFLAGS: -g -pg
    • C++ Linking: You must also link with -lstdc++.

    Workflow

    1. Execute the program: Run your compiled binary on the PSP hardware or emulator. Upon program termination, a gmon.out file will be automatically generated in the Current Working Directory (CWD).
    2. Analyze the profile: Use the psp-gprof tool on your host machine to inspect the gmon.out file using your compiled .elf binary.
    # Syntax for analyzing the profile
    psp-gprof -b {binary.elf} gmon.out
    
    # Example usage
    psp-gprof -b gprofbasic_cpp.elf gmon.out
  6. Perform targeted profiling using gprof_start and gprof_stop

    master

    By default, gprof profiles the entire application from startup. To profile only a specific section of code and avoid noise from the initialization process, follow this pattern:

    1. Call gprof_stop(NULL, false); at the start of your application to discard the initial profiling data.
    2. Call gprof_start(); immediately before the code block you wish to measure.
    3. Call gprof_stop("filename.out", true); immediately after the code block to stop profiling and save the results to a file.
    // 1. Discard default startup profiling
    gprof_stop(NULL, false);
    
    // ... some code ...
    
    // 2. Start measuring specific section
    gprof_start();
    
    // ... code to profile ...
    
    // 3. Stop and save to custom file
    gprof_stop("gmon_custom.out", true);
  7. Use the SIO (Serial I/O) remote control port for communication

    master

    The SIO sample demonstrates how to use the PSP's serial interface via the remote control port. To communicate with the PSP using this interface, you must configure your local terminal software with the following serial settings:

    • Baud rate: 4800
    • Data bits: 8
    • Parity: None (N)
    • Stop bits: 1

    This configuration is referred to as 4800 baud 8N1.

    For detailed information on how the hardware interface is constructed, refer to the technical documentation at: http://nil.rpc1.org/psp/remote.html

    Terminal Settings:
    Baud: 4800
    Data bits: 8
    Parity: None
    Stop bits: 1
  8. Enable and use gprof profiling

    master

    To profile your PSP software using gprof, you must compile your code with profiling support enabled and then use the psp-gprof tool to analyze the resulting data.

    1. Compilation

    Add the -g and -pg flags to both your CFLAGS and LDFLAGS during the build process. This enables debug symbols and profiling instrumentation.

    2. Execution

    Run your compiled program on the PSP. Once the program terminates, it will automatically generate a gmon.out file in the Current Working Directory (CWD).

    3. Analysis

    Use the psp-gprof binary to inspect the gmon.out file. You must provide the path to your compiled ELF binary using the -b flag so the tool can map the profile data to your function names.

    # 1. Compile with flags
    # (Ensure -g and -pg are in CFLAGS and LDFLAGS)
    
    # 2. Run the program on PSP to generate gmon.out
    
    # 3. Analyze the results
    psp-gprof -b {your_binary.elf} gmon.out
  9. Decrypt savegames using sceChnnlsv

    master

    The sceChnnlsv module can be used directly to perform savegame decryption.

    Constraints and Requirements:

    • Mode: This method currently only works in VSH mode (for example, when running via the TIFF exploit).
    • Save Formats: It supports both old and new save formats. The supported SaveParam structure sizes are:
      • 0x5c8 (Old format)
      • 0x5dc (New format)
      • 0x600 (New format)
    • Encryption Keys: For new format saves, a game-specific encryption key is required to complete the decryption process.
  10. Configure the PSPSDK installation directory

    master

    By default, PSPSDK installs into the same directory as your PSPDEV toolchain. If you wish to install PSPSDK to a custom location, you must define the PSPSDK environment variable pointing to that directory.

    The psp-config utility uses this environment variable to locate tools and libraries. It checks the PSPSDK environment variable first before falling back to its own installation path.

  11. Explore the `sceSasCore` library via the SAS Core Sample

    master

    The sascore sample project serves as a demonstration of the capabilities provided by the sceSasCore library. It is useful for developers looking to understand how to implement audio-related features on the PSP using this specific library.

    Note that the audio assets used in this sample (.VAG files) were encoded using the psxavenc tool.