summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Levand <geoffrey.levand@am.sony.com>2008-01-06 15:23:10 -0800
committerGeoff Levand <geoffrey.levand@am.sony.com>2008-01-06 15:23:10 -0800
commit57bae399de01c5efaadd5adf423f93043ba13659 (patch)
treebf8adf2280008467e6d07c85a43ad96888bfeb82
parentbc20d0597ccc7780018df6cd5b3fcffd255f00e9 (diff)
downloadps3-utils-57bae399de01c5efaadd5adf423f93043ba13659.tar.gz
ps3-dump-bootloader: Improve help text, get ldr_offset from flash.
-rw-r--r--ps3-dump-bootloader.in68
1 files changed, 49 insertions, 19 deletions
diff --git a/ps3-dump-bootloader.in b/ps3-dump-bootloader.in
index 307d8ad..b5ff2cb 100644
--- a/ps3-dump-bootloader.in
+++ b/ps3-dump-bootloader.in
@@ -19,32 +19,62 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+usage() {
+ echo "ps3-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@" >&2
+ echo "" >&2
+ echo "DESCRIPTION" >&2
+ echo " Dump the bootloader from PS3 flash memory to stdout" >&2
+ echo "" >&2
+ echo "OPTIONS" >&2
+ echo " -h, --help" >&2
+ echo " Print a help message." >&2
+ echo "" >&2
+ echo " -s, --sum" >&2
+ echo " Compute the md5sum and print it to stdout." >&2
+ echo "" >&2
+ echo "" >&2
+ echo "Send bug reports to @PACKAGE_BUGREPORT@" >&2
+ echo "" >&2
+ exit 1
+}
+
sum=
-if [ "x$1" = "x-s" -o "x$1" = "x--sum" ]; then
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ --sum|-s)
sum="y"
-elif [ "x$1" != "x" ]; then
- echo "ps3-dump-bootloader (@PACKAGE_NAME@) @PACKAGE_VERSION@"
- echo ""
- echo "DESCRIPTION"
- echo " Dump the bootloader from PS3 flash memory to stdout"
- echo ""
- echo " Use the following command to check the integrity of"
- echo " the bootloader:"
- echo ""
- echo " ps3-dump-bootloader | md5sum"
- echo ""
- echo "Send bug reports to @PACKAGE_BUGREPORT@"
- echo ""
- exit 0
-fi
+ ;;
+ *)
+ usage
+ ;;
+ esac
+ shift
+done
+
ldr_size=`@prefix@/sbin/ps3-flash-util -s \
| grep 'h\.ldr_size' \
| tr -d ' ' | cut -d':' -f4 | cut -d'(' -f1`
-if [ "x$sum" != "x" ]; then
- dd if=/dev/ps3flash bs=1 skip=2K count=$ldr_size | md5sum
+if [ ! "$ldr_size" ]; then
+ echo "ERROR: can't dump image" 2>&1;
+ exit 1;
+fi
+
+ldr_offset=`@prefix@/sbin/ps3-flash-util -s \
+ | grep 'h\.ldr_area_offset' \
+ | tr -d ' ' | cut -d':' -f4`
+
+if [ ! "ldr_offset" ]; then
+ echo "ERROR: can't dump image" 2>&1;
+ exit 1;
+fi
+
+let ldr_offset=512*ldr_offset
+
+if [ "$sum" ]; then
+ dd if=/dev/ps3flash bs=1 skip=$ldr_offset count=$ldr_size | md5sum
else
- dd if=/dev/ps3flash bs=1 skip=2K count=$ldr_size
+ dd if=/dev/ps3flash bs=1 skip=$ldr_offset count=$ldr_size
fi