Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility for 306 firmware #39

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions offset_diff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sys

def comparer(file1, file2):
content1 = file1.readlines()
content2 = file2.readlines()
if len(content1) != len(content2):
print("Something went wrong. Length mismatch")
exit(1)
output = open("offset_differences.csv", "w")
# Grabbing the filename. It's weird, but it works
output.write("offset, " + str(file1).split("name='")[1].split("'")[0] + ", " +
str(file2).split("name='")[1].split("'")[0] + "\n")
for counter in range(len(content1)):
offset1, hexvalue1 = content1[counter].split(":")[0], content1[counter].split(" ")[1]
offset2, hexvalue2 = content2[counter].split(":")[0], content2[counter].split(" ")[1]
if offset1 != offset2:
print("Offset mismatch. Please run 'xxd -c 1 <file> > <file>.hex on both files again")
exit(1)
if hexvalue1 != hexvalue2:
# Looks weird, but just doing some CSV formatting
output.write("\"=\"\""+offset1+"\"\"\""+", \"=\"\""+hexvalue1+"\"\"\""+", \"=\"\""+hexvalue2+"\"\"\"\n")
# "=""123"""


if len(sys.argv) == 3 and sys.argv[1][-3:] != "bin" and sys.argv[2][-3:] != "bin":
with open(sys.argv[1],"r") as file1, open(sys.argv[2],"r") as file2:
comparer(file1,file2)
else:
print("This program will compare two hex dumps and will output non-matching offsets")
print("Run 'xxd -c 1 <file> > <file>.hex' on both files first.")
print("Usage: python offset_diff.py hexfile1 hexfile2")
sys.exit(1)
38 changes: 38 additions & 0 deletions offset_locator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import sys

def comparer(file1, file2):
content1 = file1.readlines()
content2 = file2.readlines()
if len(content1) != len(content2):
print("Something went wrong. Length mismatch")
exit(1)
output = open("offset_locator.csv", "w")
# Looks weird, but just doing some CSV formatting
output.write(str(file1).split("name='")[1].split("'")[0] + ", " +
str(file2).split("name='")[1].split("'")[0] + "\n")
for counter1 in range(len(content1)):
offset1, hexvalue1 = content1[counter1][0:8], content1[counter1][10:49]
offset2, hexvalue2 = content2[counter1][0:8], content2[counter1][10:49]
matched = False
if hexvalue1 == "0000 0000 0000 0000 0000 0000 0000 0000":
output.write(offset1+" is 0's, \"\"\n")
elif hexvalue1 == "FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF":
output.write(offset2+" is F's, \"\"")
elif hexvalue2 != hexvalue1:
for counter2 in range(len(content2)):
offset2, hexvalue2 = content2[counter2][0:8], content2[counter2][10:49]
if hexvalue1 == hexvalue2:
matched = True
output.write("\"=\"\""+offset1+"\"\"\""+", \"=\"\""+offset2+"\"\"\"\n")
if counter2 == len(content2)-1 and not matched:
output.write("\"=\"\""+offset1+"\"\"\""+", No Match\n")


if len(sys.argv) == 3 and sys.argv[1][-3:] != "bin" and sys.argv[2][-3:] != "bin":
with open(sys.argv[1],"r") as file1, open(sys.argv[2],"r") as file2:
comparer(file1,file2)
else:
print("This program will compare two hex dumps and will output matching possible offsets")
print("Run 'xxd <file> > <file>.hex' on both files first.")
print("Usage: python offset_diff.py hexfile1 hexfile2")
sys.exit(1)
18 changes: 13 additions & 5 deletions patch-airsense
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,15 @@ patch() {
dd bs=1 seek=$offset conv=notrunc of="$OUT" status=none
}

echo "533b91127aa22e05b933db203ad56c449dc12a8c3fd62f57bd88c472a8061775 $IN"\
| sha256sum --check \
|| die "$IN: wrong hash"
shasum=$( sha256sum $IN | cut -f 1 -d " " )
if [ $shasum = "533b91127aa22e05b933db203ad56c449dc12a8c3fd62f57bd88c472a8061775" ]; then
version="401"
elif [ $shasum = "363a204ba217f31223e929365d58b8f5ce038a7681e362fe157e190c2eacbd30" ]; then
version="306"
else
die "$IN: incompatible firmware version."
fi
echo "Found firmware version: $version"

cp "$IN" "$OUT" || die "$OUT: copy failed"

Expand All @@ -40,10 +46,12 @@ BUILD_FLAGS=0
patch_code() {
#if you want to add the extra breath mode
BUILD_FLAGS=$(( BUILD_FLAGS | (1 << 0) ))

if [ -r breath.bin ] ; then
if [ -r breath.bin ] && [ $version = "401" ] ; then
echo "Including breath.bin"
cat breath.bin | patch 0xbb734 || die "binary patch failed"
elif [ -r breath.bin ] && [ $version = "306" ] ; then
echo "Including breath.bin"
cat breath.bin | patch 0xbb4d4 || die "binary patch failed"
else
die "breath.bin not found, did you run make?"
fi
Expand Down