Lekensteyn / lglaf

LG Download Mode utility and documentation
https://lekensteyn.nl/lglaf/
MIT License
137 stars 74 forks source link

MISC READ/WRTE ISSUES #52

Open P3nguin-M opened 6 years ago

P3nguin-M commented 6 years ago

Following instructions, cannot get any useful commands to go through. For my example, I followed the instructions on issue #48 written by runningNak3d where the MISC partition is being written and read from. I was able to find the sizes I needed collecting the data from ./partitions script. Here's the output of the MISC partition:

$ ./partitions.py --list | grep -B 2 -A 2 "misc" 2AB301DC-B302-BC20-6D2E-846FD0FE17AE abootbak 12 1152921504606846976 20480 53247 20117F86-E985-4357-B9EE-374BC1D8487D Unknown 46C2E671-08B2-C2FB-FFF6-94396C3F5797 misc 13 1152921504606846976 53248 86015 EBD0A0A2-B9E5-4433-87C0-68B6B72699C7 Basic data partition 64943174-93E7-D470-B376-3152366DEEDD persist

The offset starts at 20480, the size with a multiplicity of 512 comes out to 32768. Here's what I get. I have no idea what I'm doing wrong, a little help would be appreciated!!

OUTPUT: $ python3 lglaf.py --debug --cr --rawshell -c 'MISC WRTE,20480,32768'

LGLAF.py: DEBUG: product id in CR list: >G4< LGLAF.py: DEBUG: Device is: 633a, G4. Enabling Challenge/Response! LGLAF.py: DEBUG: Using endpoints 83 (IN), 02 (OUT) LGLAF.py: DEBUG: Using Protocol version: 0x1000003 LGLAF.py: DEBUG: CR detection: 1 LGLAF.py: DEBUG: Hello done, proceeding with commands LGLAF.py: DEBUG: Challenge: b'0e3a527c' LGLAF.py: DEBUG: Response: b'65effcc74ac3e005eb48a20d4a6e5521' LGLAF.py: DEBUG: KILO METR Response -> Header: b'4b494c4f4d455452000000000200000000000000000000002f5d0000b4b6b3b0', Body: b'' Hello, I am LAF. Nice to meet you.

runningnak3d commented 5 years ago

You aren't putting a ! in your command. It would be -c '!MISC WRTE blah blah'

Your second problem is that you don't specify the offset OF the misc partition, you specify an offset WITHIN the misc partition. MISC WRTE and MISC READ already know the offset of misc.

So if you want to start writing at the beginning of misc:

!MISC WRTE,0,4 TEST

That will write TEST at the very start of the misc partition.

You can read it back with:

!MISC READ,0,4 And you will get TEST back. Here is output from my phone:

71° [swango:~/dev/lglaf] h932-dd-write(+1/-1)+* 8s ± ./lglaf.py --cr --debug --rawshell
LGLAF.py: DEBUG: product id in CR list: >G4<
LGLAF.py: DEBUG: Device is: 633a, G4. Enabling Challenge/Response!
LGLAF.py: DEBUG: Using endpoints 83 (IN), 02 (OUT)
LGLAF.py: DEBUG: Using Protocol version: 0x1000004
LGLAF.py: DEBUG: CR detection: 1
LGLAF.py: DEBUG: Hello done, proceeding with commands
LGLAF.py by Peter Wu (https://lekensteyn.nl/lglaf)
Type a shell command to execute or "exit" to leave.
# !MISC WRTE,0,4 TEST
LGLAF.py: DEBUG: Header: b'MISC' b'WRTE' b'\0\0\0\0' b'\x04\0\0\0' b'\0\0\0\0' b'\0\0\0\0' b';i\0\0' b'\xb2\xb6\xac\xbc'
# !MISC READ,0,4
LGLAF.py: DEBUG: Header: b'MISC' b'READ' b'\0\0\0\0' b'\x04\0\0\0' b'\0\0\0\0' b'\x04\0\0\0' b'\xc2+\0\0' b'\xb2\xb6\xac\xbc'
TEST# 

Now without all the debug output:

Type a shell command to execute or "exit" to leave.
# !MISC WRTE,0,4 1234
# !MISC READ,0,4
1234# 

Unless you have a backup of your misc partition, you NEVER want to write more than one block unless you are trying to modify values on the misc partition itself (for example serial number, or MAC address).

For eMMC devices that is 512 and for UFS devices that is 4096.

-- Brian