Skip to content

Commit

Permalink
v0.1.5
Browse files Browse the repository at this point in the history
FW detection bugfix, slim model, 18 region
  • Loading branch information
andy-man committed Nov 14, 2023
1 parent 388d25a commit df22160
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 154 deletions.
20 changes: 16 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# PS5 Wee Tools

PS5 wee tools help to work with PS5 nor dump.
PS5 wee tools help to work with PS5 sflash dump.

Written in Python to keep it simple.

Expand All @@ -23,22 +23,25 @@ NOR tool
* MD5, Board ID, Model, SKU, Region, SN / Mobo SN
* Kiban ID, FW (current/min/factory), MAC (LAN/WiFi)
* Flags toggle:
* kiosk mode (idu), model (disc/digital)
* kiosk mode (idu), model (slim/disc/digital), active slot
* Extract NOR's partitions
* Build dump from extracted files
* Basic validation

Common
* File browser
* Terminal (UART) with highlighting
* sFlash r/w (SPIway by Judges)
* Multy files compare
* Pack / Unpack 2BLS files

Don't use if you don't understant what is it for!

## Credits

* theCoder
* zecoxao
[Abkarino](https://github.com/AbkarinoMHM),
[zecoxao](https://github.com/zecoxao),
[TheCod3r](https://www.youtube.com/@TheCod3r)

And of course [PSDevWiki](https://www.psdevwiki.com/ps5/)

Expand All @@ -56,6 +59,15 @@ And of course [PSDevWiki](https://www.psdevwiki.com/ps5/)

## Changelog

### v0.1.5
* FW detection bugfix
* Slim model support
* Flags toggle: active slot
* Region #18 added
* Code optimization
* Minor bug fixes


### v0.1 - Initial release
* PS5 Nor dump info
* Flags toggle: idu, model
Expand Down
6 changes: 4 additions & 2 deletions lang/_i18n_.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#==========================================================
import sys, os

APP_VERSION = '0.1.1'
APP_VERSION = '0.1.5'

# Colors stuff

Expand Down Expand Up @@ -60,6 +60,9 @@ class UI:
DIVIDER_DASH = Clr.fg.yellow + '-'*LINE_WIDTH + Clr.reset + '\n'
DIVIDER_BOLD = '='*LINE_WIDTH + '\n'

def clearScreen():
os.system('cls' if sys.platform[:3] == 'win' else 'clear')

# Colors

def link(str):
Expand Down Expand Up @@ -162,7 +165,6 @@ def showStatus(cls):

# Fill strings

STR_MPATCH_INPUT = UI.DIVIDER + STR_MPATCH_INPUT
STR_CHOICE = UI.DIVIDER + STR_CHOICE
STR_BACK = UI.DIVIDER + STR_BACK
STR_CONFIRM = UI.DIVIDER + STR_CONFIRM
Expand Down
36 changes: 14 additions & 22 deletions lang/en.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'erase': 'Erasing',
}

STR_SECONDS = '{:0.0f} seconds'
STR_SECONDS = '%0.0f seconds'
STR_PORTS_LIST = 'Serial ports'
STR_MAIN_MENU = 'Main menu'
STR_FILE_LIST = 'Files list'
Expand Down Expand Up @@ -107,7 +107,7 @@
STR_OK = 'OK'
STR_FAIL = 'Fail'
STR_CANCEL = 'Cancel'
STR_IS_PART_VALID = '[{}] {} FW {}'
STR_IS_PART_VALID = '[%s] %s FW %s'
STR_SERIAL_MONITOR = 'Terminal'

STR_NO_PORTS = ' No one serial port was found'
Expand All @@ -122,17 +122,17 @@
STR_PERFORMED = ' Performed action: '

STR_EMPTY_FILE_LIST = ' File list is empty'
STR_NO_FOLDER = ' Folder {} doesn\'t exists'
STR_EXTRACTING = ' Extracting sflash to {} folder'
STR_NO_FOLDER = ' Folder %s doesn\'t exists'
STR_EXTRACTING = ' Extracting sflash to %s folder'
STR_FILES_CHECK = ' Checking files'
STR_BUILDING = ' Building file {}'
STR_BUILDING = ' Building file %s'

STR_DONE = ' All done'
STR_PROGRESS = ' Progress {:2d}% '
STR_PROGRESS_KB = ' Progress: {}KB / {}KB'
STR_PROGRESS = ' Progress %2d%% '
STR_PROGRESS_KB = ' Progress: %dKB / %dKB'
STR_WAIT = ' Please wait...'
STR_WAITING = ' Waiting...'
STR_SET_TO = ' {} was set to [{}]'
STR_SET_TO = ' %s was set to [%s]'
STR_ABORT = ' Action was aborted'
STR_FILENAME = ' Filename: '

Expand All @@ -145,28 +145,20 @@
STR_DIFF_SLOT_VALUES = ' Values in slots are different!'
STR_SYSFLAGS_CLEAN = ' Sys flags were cleared. Tip: turn on UART'

STR_RECOMMEND = ' Recommended method [{}]'
STR_PATCH_CANCELED = ' Patch was canceled'
STR_PATCH_SUCCESS = ' Successfully removed {} entries'
STR_PATCH_SAVED = ' Patch was saved to {}'
STR_MPATCH_INPUT = ' How many records to clean (from end): '
STR_CHOICE = ' Make choice: '
STR_BACK = ' Press [ENTER] to go back'
STR_TOO_MUCH = ' {} is too much, maximum value is {}'

STR_UNPATCHABLE = ' Can\'t patch!'
STR_PARTITIONS_CHECK = ' Checking partitions'
STR_ENTROPY = ' Entropy statistics'
STR_MAGICS_CHECK = ' Checking magics'
STR_DUPLICATES = ' {} duplicate(s) found {}'

STR_FW_VERSION = ' FW version {} / Active slot {}'
STR_FW_VERSION = ' FW version %s / Active slot %s'

STR_INCORRECT_SIZE = ' {} - incorrect dump size!'
STR_FILE_NOT_EXISTS = ' File {} doesn\'t exist!'
STR_INCORRECT_SIZE = ' %s - incorrect dump size!'
STR_FILE_NOT_EXISTS = ' File %s doesn\'t exist!'
STR_ERROR_FILE_REQ = ' You need to select file first'
STR_SAVED_TO = ' Saved to {}'
STR_SAVING_TO = ' Saving to {}'
STR_SAVED_TO = ' Saved to %s'
STR_ERROR_INPUT = ' Incorrect input'
STR_ERROR_DEF_VAL = ' Setting default values'
STR_ERROR_CHOICE = ' Invalid choice'
Expand All @@ -185,8 +177,8 @@
STR_GO_BACK = ' Go back'
STR_FLASH_PATCHED = ' Flash patched to console (SPIway)? [y] '

STR_EMC_CMD_MODE = 'Turning EMC cmd mode: [{}]'
STR_SHOW_BYTECODES = 'Show byte codes < 0x20: [{}]'
STR_EMC_CMD_MODE = 'Turning EMC cmd mode: [%s]'
STR_SHOW_BYTECODES = 'Show byte codes < 0x20: [%s]'
STR_MONITOR_STATUS = 'RX/TX: %d/%d (bytes) Elapsed: %d (sec)'

STR_CHIP_CONFIG = ' Chip config'
Expand Down
29 changes: 15 additions & 14 deletions tools/SFlashTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def screenExtractNorDump(file):
os.system('cls')
UI.clearScreen()
print(TITLE+UI.getTab(STR_NOR_EXTRACT))

with open(file, 'rb') as f:
Expand All @@ -28,7 +28,7 @@ def screenExtractNorDump(file):
info += '{} : {}\n'.format(key.ljust(12,' '),data[key])
info += '\n'

print(STR_EXTRACTING.format(sn)+'\n')
print(STR_EXTRACTING%sn+'\n')

i = 0
for k in SFlash.NOR_PARTITIONS:
Expand All @@ -43,7 +43,7 @@ def screenExtractNorDump(file):
with open(folder + Utils.INFO_FILE_SFLASH, 'w') as txt:
txt.write(info)

print('\n'+STR_SAVED_TO.format(folder))
print('\n'+STR_SAVED_TO%folder)

print('\n'+STR_DONE)

Expand All @@ -52,11 +52,11 @@ def screenExtractNorDump(file):


def screenBuildNorDump(folder):
os.system('cls')
UI.clearScreen()
print(TITLE+UI.getTab(STR_NOR_BUILD))

if not os.path.exists(folder):
print(STR_NO_FOLDER.format(folder)+'\n\n'+STR_ABORT)
print(STR_NO_FOLDER%(folder)+'\n\n'+STR_ABORT)
input(STR_BACK)
return

Expand Down Expand Up @@ -93,7 +93,7 @@ def screenBuildNorDump(folder):

fname = os.path.join(folder, 'sflash0.bin')

print(STR_BUILDING.format(fname))
print(STR_BUILDING%fname)

out = open(fname,"wb")

Expand All @@ -113,7 +113,7 @@ def screenBuildNorDump(folder):


def screenFlagsToggler(file):
os.system('cls')
UI.clearScreen()
print(TITLE+UI.getTab(STR_WARNING))

print(UI.warning(STR_PATCHES))
Expand All @@ -125,6 +125,7 @@ def screenFlagsToggler(file):
patches = [
{'k':'MODEL', 'v':list(SFlash.PS_MODELS.keys()), 'd':list(SFlash.PS_MODELS.values())},
{'k':'IDU', 'v':[b'\x00',b'\x01'], 'd':[STR_OFF,STR_ON]},
{'k':'ACT_SLOT', 'v':[b'\x00',b'\x80'], 'd':['A','B']},
]

for i in range(len(patches)):
Expand Down Expand Up @@ -172,12 +173,12 @@ def toggleFlag(file, patch):
# Set flag in backup area
SFlash.setNorDataB(f, patch['k'], patch['v'][i])

UI.setStatus(STR_SET_TO.format(SFlash.getNorAreaName(patch['k']),patch['d'][i]))
UI.setStatus(STR_SET_TO%(SFlash.getNorAreaName(patch['k']), patch['d'][i]))



def screenPartitionsInfo(file):
os.system('cls')
UI.clearScreen()
print(TITLE+UI.getTab('Partitions info'))

with open(file,'rb') as f:
Expand All @@ -200,15 +201,15 @@ def screenPartitionsInfo(file):


def screenValidate(file):
os.system('cls')
UI.clearScreen()
print(TITLE + UI.getTab(STR_NOR_VALIDATOR))

with open(file,'rb') as f:
data = f.read()
fw = SFlash.getNorFW(f, False)['c']
fw = SFlash.getNorFW(f, 4)['c']
slot = 'A' if SFlash.getNorData(f, 'ACT_SLOT')[0] == 0x00 else 'B'

print(STR_FW_VERSION.format(fw,slot)+'\n')
print(STR_FW_VERSION%(fw,slot)+'\n')

magics = {}
for k in SFlash.MAGICS:
Expand Down Expand Up @@ -256,7 +257,7 @@ def screenValidate(file):


def screenSFlashTools(file):
os.system('cls')
UI.clearScreen()
print(TITLE+UI.getTab(STR_NOR_INFO))

info = SFlash.getSFlashInfo(file)
Expand All @@ -281,7 +282,7 @@ def screenSFlashTools(file):
elif choice == '2':
screenExtractNorDump(file)
elif choice == '3':
screenBuildNorDump(os.path.dirname(file) + os.sep + SFlash.getNorDataByPath(file, 'SN', True))
screenBuildNorDump(os.path.dirname(file) + os.sep + SFlash.getNorData(file, 'SN', True))
elif choice == '4':
screenValidate(file)

Expand Down
Loading

0 comments on commit df22160

Please sign in to comment.