Skip to content

Instantly share code, notes, and snippets.

@swingflip swingflip/start.sh
Last active Mar 26, 2019

Embed
What would you like to do?
True Blue PSC Hack dump `TRUEBLUE_IS_THE_BEST_-_FUCK_THE_HATERS`
#!/bin/sh
# settings
PACK_NUM=2000
HACK_USBPOWER=1
HACK_UART=1
HACK_CONTROLLERS=1
TBTMP="/tmp/trueblue"
LOGFILE="$TBTMP"/log.txt
CUSTOM_GAADATA=/media/gaadata
CONSOLE_GAADATA=/gaadata
dbgprint() {
date +%s | tr -d '\n' >> "$LOGFILE"
echo : "$1" >> "$LOGFILE"
}
gaadata_is_same() {
if [ ! -f "$CUSTOM_GAADATA"/"$1" ]; then
dbgprint "$CUSTOM_GAADATA/$1 does not exist"
return 1
fi
if cmp -s "$CUSTOM_GAADATA"/"$1" "$CONSOLE_GAADATA"/"$1"; then
# files are the same
dbgprint "$CUSTOM_GAADATA/$1 and $CONSOLE_GAADATA/$1 are the same"
# cat $CUSTOM_GAADATA/$1
# cat $CONSOLE_GAADATA/$1
return 0
else
# files are different
dbgprint "$CUSTOM_GAADATA/$1 and $CONSOLE_GAADATA/$1 are different"
return 1
fi
}
gaadata_get() {
mkdir -p "$(dirname "$CUSTOM_GAADATA"/"$1")"
cp "$CONSOLE_GAADATA"/"$1" "$CUSTOM_GAADATA"/"$1"
dbgprint "copying $CONSOLE_GAADATA/$1 to $CUSTOM_GAADATA/$1"
}
gaadata_get_if_different() {
gaadata_is_same "$1" || gaadata_get "$1"
}
red_led () {
SLEEP=1
LOOP=1
if [ x"$1" != x ]; then LOOP=$1; fi
if [ x"$2" != x ]; then SLEEP=$2; fi
for i in $(seq 1 "$LOOP"); do
echo 1 > /sys/class/leds/red/brightness
sleep "$SLEEP"
echo 0 > /sys/class/leds/red/brightness
sleep "$SLEEP"
echo "$i"
done
}
wait_till_logo_is_done() {
dbgprint "showlogo check"
showlogo_pid=$(ps | grep "showLog[o]" | awk '{print $1}')
dbgprint "showlogo_pid is $showlogo_pid"
while [ -n "$showlogo_pid" ] && [ -e "/proc/$showlogo_pid" ]; do
sleep .2
done
#wait "$showlogo_pid"
#pwait "$showlogo_pid"
dbgprint "showlogo finished"
}
# check that a compatible usb stick is being used
usb_info=$(cat /sys/kernel/debug/usb/devices)
lic_file="/media/TRUEBLUE_IS_THE_BEST_-_FUCK_THE_HATERS"
usb_stick_is_allowed=0
if echo "$usb_info" | grep -q "Vendor=abcd ProdID=1234"; then
# it is our usb key
echo trueblue usb stick 1 is present
usb_stick_is_allowed=1
elif echo "$usb_info" | grep -q "Vendor=ffff ProdID=5678"; then
# it is our usb key
echo trueblue usb stick 2 is present
usb_stick_is_allowed=1
elif [ -e "$lic_file" ]; then
# this stick might have support added for it
lic_data=$(cat "$lic_file")
if echo "$lic_data" | grep -q "^Vendor=.... ProdID=....$"; then
if echo "$usb_info" | grep -q "$lic_data"; then
echo licensed usb stick is present
usb_stick_is_allowed=1
fi
fi
else
# unsupported usb stick is present
usb_stick_is_allowed=0
fi
if [ "$usb_stick_is_allowed" -ne 1 ]; then
exit 0
fi
# create temp dir for every we do
mkdir -p "$TBTMP"
# let user know that we are running
#red_led "5" "0.2"
# only run once
if [ -e "$TBTMP"/running ]; then
exit 1
fi
touch "$TBTMP"/running
# let user know that we are running
red_led "8" "0.2"
# start new temp log file
touch "$LOGFILE"
# unlock uart access
if [ "$HACK_UART" -eq 1 ]; then
dbgprint "doing uart hack"
systemctl stop getty.target
systemctl stop console-getty.service
systemctl stop serial-getty@ttyS0.service
killall agetty
#exec setsid /sbin/agetty -a root -8 -L ttyS0 921600 xterm
exec /sbin/agetty -a root -8 -L ttyS0 921600 xterm &
fi
# unlock usb powered by PC
if [ "$HACK_USBPOWER" -eq 1 ]; then
dbgprint "doing usb power hack"
# TODO: add usb power fix here
:
fi
# hack for controllers allowed in hub
if [ "$HACK_CONTROLLERS" -eq 1 ]; then
dbgprint "doing controllers hack"
# create custom joystick rules file in tmp
# then overwrite original joystick rules file
echo 'KERNEL=="js0",SUBSYSTEMS=="input",SYMLINK+="input/joystick0"' > "$TBTMP"/20-joystick.rules
echo 'KERNEL=="js1",SUBSYSTEMS=="input",SYMLINK+="input/joystick1"' >> "$TBTMP"/20-joystick.rules
mount -o bind "$TBTMP"/20-joystick.rules /etc/udev/rules.d/20-joystick.rules
# sync
# Reload and apply udev rules that were overmounted above
# Allows both controllers to be detected through a USB hub
udevadm control --reload-rules
udevadm trigger
fi
# wait for showLogo to finish
wait_till_logo_is_done
# stop any of the main apps running so that we can safely change mounts
dbgprint "about to kill all"
killall -s KILL sonyapp showLogo ui_menu
# while usb is still read/write we will check the various settings files in gaadata
dbgprint "checking gaadata files"
gaadata_get_if_different "geninfo/REGION"
gaadata_get_if_different "preferences/regional.pre"
dbgprint "done checking gaadata files"
# unmount usb drive and remount as read only
dbgprint "remounting usb as read only"
SD_DEVICE_NAME="$(blkid | grep "^/dev/sd\(a\|b\)1:" | grep -E "LABEL=\"SONY.{0,4}\"" | awk -F: '{print $1}' | head -1)"
sync
mount -o remount,ro "$SD_DEVICE_NAME" /media
# prepare games
dbgprint "preparing gaadata"
#mkdir -p "$TBTMP"/gaadata
MOUNT_FAIL=0
umount /gaadata || MOUNT_FAIL=1
mount -o bind "$CUSTOM_GAADATA" "$CONSOLE_GAADATA" || MOUNT_FAIL=1
if [ "$MOUNT_FAIL" -eq 1 ]; then
dbgprint "MOUNT FAILED!!!"
fi
# PCSX_DIR="/data/AppData/sony/pcsx"
#
# sonyapp-copylink
# for every numbered game dir in "/gaadata" do:
# mkdir -p $PCSX_DIR/$COUNT/.pcsx
# ln -sf /gaadata/$COUNT/pcsx.cfg $PCSX_DIR/$COUNT/.pcsx
# link bios
# ln -sf /gaadata/system/bios /data/AppData/sony/pcsx
#
# sonyapp-copy
# for every numbered game dir in "/gaadata" do:
# mkdir -p $PCSX_DIR/$COUNT/.pcsx
# cp /gaadata/$COUNT/pcsx.cfg $PCSX_DIR/$COUNT/.pcsx
# cp $BIOS_SRC/SCPH1001.BIN $PCSX_DIR/bios/ ?????
# cp $BIOS_SRC/romJP.bin $PCSX_DIR/bios/
# cp $BIOS_SRC/romw.bin $PCSX_DIR/bios/
# fix links to game dirs
PCSX_DIR="/data/AppData/sony/pcsx"
rm -f $PCSX_DIR/bios
ln -sf /gaadata/system/bios $PCSX_DIR
ls /media/gaadata | grep '^[0-9]\+$' | xargs -I % mkdir -p $PCSX_DIR/%/.pcsx
ls /media/gaadata | grep '^[0-9]\+$' | xargs -I % ln -sf /media/gaadata/%/pcsx.cfg $PCSX_DIR/%/.pcsx
# overmount system.db to replace boot msg string
mount -o bind /media/gaadata/system/system.db /usr/sony/share/data/databases/system.db
# Fix for last selected game issue.
# Since trueblue has more games it can cause issues when the usb stick is removed
#sed -i "s/iUiUserSettingLastSelectGameCursorPos.*/iUiUserSettingLastSelectGameCursorPos=0/" /data/AppData/sony/ui/user.pre
PRE_FILE_ORIG=/data/AppData/sony/ui/user.pre
PRE_FILE_TB="$PRE_FILE_ORIG.trueblue.$PACK_NUM"
if [ ! -f "$PRE_FILE_TB" ]; then
if [ -f "$PRE_FILE_ORIG" ]; then
cp "$PRE_FILE_ORIG" "$PRE_FILE_TB"
else
touch "$PRE_FILE_TB"
fi
fi
mount -o bind "$PRE_FILE_TB" "$PRE_FILE_ORIG"
# boot main menu
cd /data/AppData/sony/pcsx || dbgprint "cd to pcsx dir failed"
export PCSX_ESC_KEY=2
sync
/usr/sony/bin/ui_menu --power-off-enable &> "$TBTMP"/ui_menu.log
rm "$TBTMP"/running
sync
sync
umount /media
reboot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.