#!/usr/bin/env bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # Pack a linked PSP program into the EBOOT.PBP the PSP runs, the way the # PSPSDK's own build.mak does: fix up its module imports in place, write a # PARAM.SFO with its title, and pack that and a stripped copy of the ELF # (no icon, pictures or sound) into the EBOOT.PBP. The unstripped ELF stays # where it is, for psp-addr2line. Run as make/psp.mk's packing step. # # Usage: packEboot.sh PROGRAM.elf TITLE EBOOT.PBP # # Requires $PSPDEV (exported by make from the installer's # toolchains/config.mk; toolchains/env.sh for a shell). set -euo pipefail if [[ $# -ne 3 ]]; then echo "usage: $0 PROGRAM.elf TITLE EBOOT.PBP" >&2 exit 2 fi elf=$1 title=$2 eboot=$3 # PARAM.SFO's MEMSIZE: the PSPSDK's default for firmware after 3.90 (the # whole user memory a model has). memSize=2 if [[ -z "${PSPDEV:-}" ]]; then echo "PSPDEV not set; run ./install.sh install toolchain:psp" >&2 exit 1 fi stem=${elf%.elf} "$PSPDEV/bin/psp-fixup-imports" "$elf" "$PSPDEV/bin/psp-strip" "$elf" -o "$stem.stripped.elf" "$PSPDEV/bin/mksfoex" -d MEMSIZE="$memSize" "$title" "$stem.sfo" "$PSPDEV/bin/pack-pbp" "$eboot" "$stem.sfo" NULL NULL NULL NULL NULL "$stem.stripped.elf" NULL > /dev/null