Last active
July 21, 2017 12:13
-
-
Save jankowskib/507a8ec7681e1048020fac3cddf098cb to your computer and use it in GitHub Desktop.
Read Focaltech touchpanel eeprom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/system/bin/sh | |
# Check if needed tools are in path | |
which i2cget i2cset i2cdetect 1&>/dev/null || (echo "No i2ctools available!" && exit 0) | |
which seq 1&>/dev/null || (echo "Need seq tool to work!" && exit 0) | |
function into_fw_mode() | |
{ | |
DELAY_AA=0.01 | |
DELAY_55=0.03 | |
i2cset -y -f 1 0x38 0xBC 0xAA | |
sleep $DELAY_AA | |
i2cset -y -f 1 0x38 0xBC 0x55 | |
sleep $DELAY_55 | |
i2cset -y -f 1 0x38 0x55 0xAA | |
} | |
function read_word() | |
{ | |
i2cset -y -f 1 0x38 0x03 0x00 | |
i2cset -y -f 1 0x38 $1 $2 | |
word=`i2cget -y -f 1 0x38 0x00 w` | |
echo -e -n "\x${word:4:2}\x${word:2:2}" | |
} | |
if [[ `i2cdetect -y 1 0x38 0x38 | grep -Eq 'UU|38' && echo 1` == "1" ]]; then | |
echo "Device found!" | |
else | |
echo "Device not found!" | |
exit 0 | |
fi | |
mode=`i2cget -y -f 1 0x38 0x00` | |
chip="`i2cget -y -f 1 0x38 0xA3``i2cget -y -f 1 0x38 0x9F`" | |
chip=`echo ${chip//0x}` | |
ver=`i2cget -y -f 1 0x38 0xA6` | |
state=`i2cget -y -f 1 0x38 0xA7` | |
echo "Touchpanel is ${chip}. FW version is: ${ver}, state ${state}. Mode is ${mode}" | |
if [[ ${chip} == "6426" ]]; then | |
into_fw_mode | |
# Get the bootloader version to ensure we're in FW burn mode | |
i2cset -y -f 1 0x38 0x90 0x00 | |
i2cset -y -f 1 0x38 0x00 0x00 | |
version=`i2cget -y -f 1 0x38 0x00 w` | |
if [[ ${version:2:2} == "00" || ${version:2:2} == "ff" ]]; then | |
echo "Failed to get into FW mode!" | |
exit 0 | |
fi | |
echo "Bootloader version is ${version}." | |
rm /cache/rom | |
echo -n "Dumping data...Be patient" | |
for i in `seq 0 255`; do | |
progress=$((i*100/255)) | |
echo -n "\rDumping data...Be patient ${progress} %" | |
for j in `seq 0 2 255`; do | |
read_word $i $j >> /cache/rom | |
done | |
done | |
# Return to normal mode | |
i2cset -y -f 1 0x38 0x07 | |
else | |
echo "Touchpanel chip is not recognized. Modify file to match your TP!" | |
exit 0 | |
fi | |
echo "Done!" | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment