Skip to content

Commit bb61112

Browse files
authored
Merge pull request #368 from GrayJack/pspemu
feat(tools, base): Add support to generate `PBOOT.PBP` and to sign VITA PSPemu `PBOOT.PBP`
2 parents 887b07f + bdb48d1 commit bb61112

8 files changed

Lines changed: 2311 additions & 200 deletions

File tree

src/base/CreatePBP.cmake

Lines changed: 43 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
cmake_minimum_required(VERSION 3.10)
77

8+
option(PBOOT "Generates a PBOOT.PBP instead of EBOOT.PBP" OFF)
9+
option(PSPEMU "Does VITA PSPemu specific processes when needed" OFF)
810
option(BUILD_PRX "Build a PRX for use with PSPLink" OFF)
911
option(ENC_PRX "Encrypt the PRX to allow running on official firmware" OFF)
1012

@@ -23,11 +25,13 @@ macro(create_pbp_file)
2325
VERSION # optional, adds version information to PARAM.SFO
2426
OUTPUT_DIR # optional, set the output directory for the EBOOT.PBP
2527
MEMSIZE # optional, set to 1 by default for allowing access to all available memory. Can be set to 2 for better Vita compatibility, but limited memory access
26-
)
28+
)
2729
set(options
30+
PBOOT # optional, generates a PBOOT.PBP instead of EBOOT.PBP
31+
PSPEMU # optional, does VITA PSPemu specific processes when needed
2832
BUILD_PRX # optional, generates and uses PRX file instead of ELF in EBOOT.PBP
2933
ENC_PRX # optional, replaces PRX file with encrypted version.
30-
)
34+
)
3135
cmake_parse_arguments("ARG" "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
3236

3337
# set mksfoex parameter if VERSION was not defined
@@ -40,6 +44,12 @@ macro(create_pbp_file)
4044
set(ARG_SFO_PATH "")
4145
endif()
4246

47+
if (PBOOT)
48+
set(PBP_FILENAME "PBOOT.PBP")
49+
else()
50+
set(PBP_FILENAME "EBOOT.PBP")
51+
endif()
52+
4353
# set output directory to where the target is build if not set
4454
if (NOT DEFINED ARG_OUTPUT_DIR)
4555
set(ARG_OUTPUT_DIR $<TARGET_FILE_DIR:${ARG_TARGET}>)
@@ -91,27 +101,27 @@ macro(create_pbp_file)
91101
POST_BUILD COMMAND
92102
"${PSPDEV}/bin/psp-strip" "$<TARGET_FILE:${ARG_TARGET}>"
93103
COMMENT "Stripping binary for target ${ARG_TARGET}"
94-
)
104+
)
95105
elseif(${ARG_BUILD_PRX})
96106
add_custom_command(
97107
TARGET ${ARG_TARGET}
98108
POST_BUILD COMMAND
99109
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Not stripping binary for target ${ARG_TARGET} because building PRX."
100-
)
110+
)
101111
else()
102112
add_custom_command(
103113
TARGET ${ARG_TARGET}
104114
POST_BUILD COMMAND
105115
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Not stripping binary for target ${ARG_TARGET}, build type is ${CMAKE_BUILD_TYPE}."
106-
)
116+
)
107117
endif()
108118

109119
add_custom_command(
110120
TARGET ${ARG_TARGET}
111121
POST_BUILD COMMAND
112122
"$ENV{PSPDEV}/bin/psp-fixup-imports" "$<TARGET_FILE:${ARG_TARGET}>"
113123
COMMENT "Calling psp-fixup-imports for target ${ARG_TARGET}"
114-
)
124+
)
115125

116126
if (${ARG_BUILD_PRX})
117127
add_custom_command(
@@ -120,22 +130,28 @@ macro(create_pbp_file)
120130
"${PSPDEV}/bin/psp-prxgen" "$<TARGET_FILE:${ARG_TARGET}>"
121131
"$<TARGET_FILE:${ARG_TARGET}>.prx"
122132
COMMENT "Calling prxgen for target ${ARG_TARGET}"
123-
)
133+
)
134+
135+
if (ARG_ENC_PRX AND PBOOT AND PSPEMU)
136+
set(ENC_VITA_PBOOT_PARAM "--pspemu-pboot")
137+
else()
138+
set(ENC_VITA_PBOOT_PARAM "")
139+
endif()
124140

125141
if(${ARG_ENC_PRX})
126142
add_custom_command(
127-
TARGET ${ARG_TARGET}
128-
POST_BUILD COMMAND
129-
"${PSPDEV}/bin/PrxEncrypter" "$<TARGET_FILE_DIR:${ARG_TARGET}>/$<TARGET_FILE_NAME:${ARG_TARGET}>.prx"
130-
"$<TARGET_FILE:${ARG_TARGET}>.prx"
131-
COMMENT "Calling PrxEncrypter for target ${ARG_TARGET}"
132-
)
143+
TARGET ${ARG_TARGET}
144+
POST_BUILD COMMAND
145+
"${PSPDEV}/bin/PrxEncrypter" "${ENC_VITA_PBOOT_PARAM}" "$<TARGET_FILE_DIR:${ARG_TARGET}>/$<TARGET_FILE_NAME:${ARG_TARGET}>.prx"
146+
"$<TARGET_FILE:${ARG_TARGET}>.prx"
147+
COMMENT "Calling PrxEncrypter for target ${ARG_TARGET}"
148+
)
133149
else()
134150
add_custom_command(
135-
TARGET ${ARG_TARGET}
136-
POST_BUILD COMMAND
137-
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Not encrypting PRX for target ${ARG_TARGET}, use ENC_PRX flag if you need to."
138-
)
151+
TARGET ${ARG_TARGET}
152+
POST_BUILD COMMAND
153+
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Not encrypting PRX for target ${ARG_TARGET}, use ENC_PRX flag if you need to."
154+
)
139155
endif()
140156

141157
else()
@@ -150,11 +166,17 @@ macro(create_pbp_file)
150166
set(ARG_MEMSIZE "1")
151167
endif()
152168

169+
if(PBOOT)
170+
set(MKSFO_PBOOT_ARG "-p")
171+
else()
172+
set(MKSFO_PBOOT_ARG "")
173+
endif()
174+
153175
if(NOT ARG_SFO_PATH)
154176
add_custom_command(
155177
TARGET ${ARG_TARGET}
156178
POST_BUILD COMMAND
157-
"${PSPDEV}/bin/mksfoex" "-d" "MEMSIZE=${ARG_MEMSIZE}" "-s" "APP_VER=${ARG_VERSION}" "${ARG_TITLE}" "${ARG_OUTPUT_DIR}/PARAM.SFO"
179+
"${PSPDEV}/bin/mksfoex" "${MKSFO_PBOOT_ARG}" "-d" "MEMSIZE=${ARG_MEMSIZE}" "-s" "APP_VER=${ARG_VERSION}" "${ARG_TITLE}" "${ARG_OUTPUT_DIR}/PARAM.SFO"
158180
COMMENT "Calling mksfoex for target ${ARG_TARGET}"
159181
)
160182
set(SFO_PATH "${ARG_OUTPUT_DIR}/PARAM.SFO")
@@ -166,15 +188,15 @@ macro(create_pbp_file)
166188
add_custom_command(
167189
TARGET ${ARG_TARGET}
168190
POST_BUILD COMMAND
169-
"${PSPDEV}/bin/pack-pbp" "${ARG_OUTPUT_DIR}/EBOOT.PBP" "${SFO_PATH}" "${ARG_ICON_PATH}" "${ARG_ANIM_PATH}" "${ARG_PREVIEW_PATH}"
191+
"${PSPDEV}/bin/pack-pbp" "${ARG_OUTPUT_DIR}/${PBP_FILENAME}" "${SFO_PATH}" "${ARG_ICON_PATH}" "${ARG_ANIM_PATH}" "${ARG_PREVIEW_PATH}"
170192
"${ARG_BACKGROUND_PATH}" "${ARG_MUSIC_PATH}" "$<TARGET_FILE:${ARG_TARGET}>.prx" "${ARG_PSAR_PATH}"
171193
COMMENT "Calling pack-pbp with PRX file for target ${ARG_TARGET}"
172194
)
173195
else()
174196
add_custom_command(
175197
TARGET ${ARG_TARGET}
176198
POST_BUILD COMMAND
177-
"${PSPDEV}/bin/pack-pbp" "${ARG_OUTPUT_DIR}/EBOOT.PBP" "${SFO_PATH}" "${ARG_ICON_PATH}" "${ARG_ANIM_PATH}" "${ARG_PREVIEW_PATH}"
199+
"${PSPDEV}/bin/pack-pbp" "${ARG_OUTPUT_DIR}/${PBP_FILENAME}" "${SFO_PATH}" "${ARG_ICON_PATH}" "${ARG_ANIM_PATH}" "${ARG_PREVIEW_PATH}"
178200
"${ARG_BACKGROUND_PATH}" "${ARG_MUSIC_PATH}" "$<TARGET_FILE:${ARG_TARGET}>" "${ARG_PSAR_PATH}"
179201
COMMENT "Calling pack-pbp with ELF file for target ${ARG_TARGET}"
180202
)
@@ -192,7 +214,7 @@ macro(create_pbp_file)
192214
add_custom_command(
193215
TARGET ${ARG_TARGET}
194216
POST_BUILD COMMAND
195-
${CMAKE_COMMAND} -E cmake_echo_color --cyan "EBOOT.PBP file created for target ${ARG_TARGET}."
217+
${CMAKE_COMMAND} -E cmake_echo_color --cyan "${PBP_FILENAME} file created for target ${ARG_TARGET}."
196218
)
197219

198220
endmacro()

src/base/build.mak

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,27 @@ ifndef PSP_EBOOT_PSAR
124124
PSP_EBOOT_PSAR = NULL
125125
endif
126126

127+
ifndef PSP_PRODUCE_PBOOT
128+
ifeq ($(ENCRYPT), 2)
129+
PSP_PRODUCE_PBOOT = 1
130+
endif
131+
endif
132+
127133
ifndef PSP_EBOOT
134+
ifeq ($(PSP_PRODUCE_PBOOT), 1)
135+
PSP_EBOOT = PBOOT.PBP
136+
else
128137
PSP_EBOOT = EBOOT.PBP
129138
endif
139+
endif
140+
141+
ifeq ($(PSP_PRODUCE_PBOOT), 1)
142+
SFOFLAGS := -p $(SFOFLAGS)
143+
endif
144+
145+
ifeq ($(ENCRYPT), 2)
146+
SFOFLAGS := -d USE_USB=1 $(SFOFLAGS)
147+
endif
130148

131149
ifeq ($(BUILD_PRX),1)
132150
ifneq ($(TARGET_LIB),)
@@ -180,6 +198,8 @@ ifeq ($(BUILD_PRX),1)
180198
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
181199
ifeq ($(ENCRYPT), 1)
182200
- $(ENC) $(TARGET).prx $(TARGET).prx
201+
else ifeq ($(ENCRYPT), 2)
202+
- $(ENC) --pspemu-pboot $(TARGET).prx $(TARGET).prx
183203
endif
184204
$(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON) \
185205
$(PSP_EBOOT_ICON1) $(PSP_EBOOT_PIC0) $(PSP_EBOOT_PIC1) \

src/base/build_prx.mak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CXX = psp-g++
1919
AS = psp-gcc
2020
LD = psp-gcc
2121
FIXUP = psp-fixup-imports
22+
ENC = PrxEncrypter
2223

2324
# Add PSPSDK includes and libraries.
2425
INCDIR := $(INCDIR) . $(PSPDEV)/psp/include $(PSPSDK)/include
@@ -56,6 +57,11 @@ endif
5657

5758
%.prx: %.elf
5859
psp-prxgen $< $@
60+
ifeq ($(ENCRYPT), 1)
61+
- $(ENC) $@ $@
62+
else ifeq ($(ENCRYPT), 2)
63+
- $(ENC) --pspemu-pboot $@ $@
64+
endif
5965

6066
%.c: %.exp
6167
psp-build-exports -b $< > $@

src/base/pspdev.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ endif()
77
SET(CMAKE_SYSTEM_NAME Generic)
88
SET(CMAKE_SYSTEM_VERSION 1)
99
SET(CMAKE_SYSTEM_PROCESSOR mips)
10-
SET(CMAKE_C_COMPILER psp-gcc)
11-
SET(CMAKE_CXX_COMPILER psp-g++)
10+
SET(CMAKE_C_COMPILER "${PSPDEV}/bin/psp-gcc")
11+
SET(CMAKE_CXX_COMPILER "${PSPDEV}/bin/psp-g++")
1212
SET(CMAKE_C_FLAGS_INIT "-I${PSPDEV}/psp/include -I${PSPDEV}/psp/sdk/include -DPSP")
1313
SET(CMAKE_CXX_FLAGS_INIT "-I${PSPDEV}/psp/include -I${PSPDEV}/psp/sdk/include -DPSP")
1414
SET(CMAKE_EXE_LINKER_FLAGS_INIT "-L${PSPDEV}/lib -L${PSPDEV}/psp/lib -L${PSPDEV}/psp/sdk/lib -Wl,-zmax-page-size=128")

0 commit comments

Comments
 (0)