summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2015-09-24 21:15:14 +1000
committerDamien Zammit <damien@zamaudio.com>2015-09-24 21:15:14 +1000
commit8cf285971f75cc1613fbe0805c2468c279624c5a (patch)
treec0453408bcea19eb1c884b5a390f947a6ae81c24
parent0d73e869c4f706a716e2cd4f8647ad3b369d7d4c (diff)
Added tool to swap endian
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r--swap.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/swap.py b/swap.py
new file mode 100644
index 0000000..32cc3a9
--- /dev/null
+++ b/swap.py
@@ -0,0 +1,41 @@
+# smutool Tool for SMU
+# Copyright (C) 2015 Damien Zammit <damien@zamaudio.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# See <http://www.gnu.org/licenses/>.
+#
+
+import sys
+
+args=sys.argv
+if len(sys.argv) == 1:
+ print "Usage: python signsmu.py <smu firmware>"
+ sys.exit()
+
+def reverse(strs):
+ return ''.join([strs[i] for i in xrange(len(strs)-1, -1, -1)])
+
+f = open(args[1], "rb")
+firmware = bytearray()
+try:
+ firmware = bytearray(f.read())
+finally:
+ f.close()
+
+for wcnt in range(0,len(firmware)/4):
+ tmp = firmware[wcnt*4]
+ firmware[wcnt*4] = firmware[wcnt*4+3]
+ firmware[wcnt*4+3] = tmp
+ tmp = firmware[wcnt*4+1]
+ firmware[wcnt*4+1] = firmware[wcnt*4+2]
+ firmware[wcnt*4+2] = tmp
+
+sys.stdout.write(firmware)