mediatek-preloader-tools
mediatek-preloader-tools copied to clipboard
Option device=firetv2? Help request for support for other devices.
Hi I compiled your plugin and I am trying to make some scripts around that to automatically dump MMC.
Here is some WIP script:
#!/bin/bash
#Clean-up
rm -f comport.txt
echo "Waiting for device&port"
python3 handshake.py
while ! test -f "comport.txt"; do
echo -n "."; sleep 0.5;
done
device=(`cat comport.txt`)
echo ""
echo "Device detected!"
nbdkit --verbose --tls=off `pwd`/nbdkit-mtkpreloader-plugin.so tty="$device" device="firetv2"
xnbd-client --blocksize 4096 localhost 10809 /dev/nbd0
Here is what I get:
Waiting for device&port
Waiting for preloader...
Found port = /dev/ttyACM0
Handshake complete!
Device detected!
nbdkit: debug: registering plugin /home/anarchist/code/mediatek-preloader-tools/nbdkit-mtkpreloader-plugin.so
nbdkit: debug: registered plugin /home/anarchist/code/mediatek-preloader-tools/nbdkit-mtkpreloader-plugin.so (name mtkpreloader)
nbdkit: debug: mtkpreloader: load
nbdkit: debug: mtkpreloader: config key=tty, value=/dev/ttyACM0
nbdkit: debug: mtkpreloader: config key=device, value=firetv2
nbdkit: debug: mtkpreloader: config_complete
nbdkit: debug: bound to IP address <any>:10809 (2 socket(s))
nbdkit: debug: forked into background (new pid = 5660)
** Message: 18:44:59.673: bs=4096 timeout=0 localhost 10809 /dev/nbd0
** Message: 18:44:59.673: connecting to localhost(10809)
** Message: 18:44:59.675: connected to [::1]:10809,TCP
nbdkit: debug: accepted connection
nbdkit: debug: mtkpreloader: open readonly=0
nbdkit: mtkpreloader[1]: debug: newstyle negotiation: flags: global 0x3
** (process:5661): WARNING **: 18:44:59.676: plain server expected, wrapped server found
** (process:5661): WARNING **: 18:44:59.677: negotiation with localhost:10809 failed
** Message: 18:44:59.677: sleep for a moment and try again ...
** Message: 18:45:04.677: connecting to localhost(10809)
** Message: 18:45:04.677: connected to [::1]:10809,TCP
nbdkit: debug: accepted connection
Is option device=firetv2 mandatory? are there any other possible ones? Does it mean that no other devices are supported? Thanks!
ok now i see it's in https://github.com/androidrbox/mediatek-preloader-tools/blob/master/common.h#L36
what is this value? { "firetv2", 0x11230000 },
base_addr? uint32_t? Is it device size?
@androidrbox How can I get that value for my devices?
I will test and make PR if it works.
That's the memory address of the flash controller. I got it from the Linux device tree.
Do you remeber where it was exacly? Or keywords to grep tree for?
It might be called sdio or mmc or something like that. I don't have the firetv2 hooked up right now, so i'm referencing the fire stick 4k, but it seems like the address is the same. I have this directory:
/sys/class/mmc_host
And in it i have an mmc0 and an mmc1 and they are symlinks and the directory they point to has the memory address in it. It looks like mmc0 is the mmc and mmc1 is sdio. So the mmc0 would be right one.
It's also /base/soc/mmc@11230000 in the device tree.
Ok I just checked the other Mediatek device I have (that is working; my main phone) and it has the same value for mmc address as firetv2 and it doesn't seem to work with your plugin either. Here is what I get from dmesg:
[319348.465362] cdc_acm 1-1.1:1.0: ttyACM0: USB ACM device
[319406.797297] usb 1-1.1: USB disconnect, device number 90
[319408.497905] usb 1-1.1: new high-speed USB device number 91 using ehci-pci
[319408.608502] usb 1-1.1: New USB device found, idVendor=0e8d, idProduct=2000, bcdDevice= 1.00
[319408.608505] usb 1-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=6
[319408.608506] usb 1-1.1: Product: MT65xx Preloader
[319408.608507] usb 1-1.1: Manufacturer: MediaTek
[319408.670178] cdc_acm 1-1.1:1.0: Zero length descriptor references
[319408.670196] cdc_acm: probe of 1-1.1:1.0 failed with error -22
[319408.710472] cdc_acm 1-1.1:1.1: ttyACM1: USB ACM device
[319411.388682] usb 1-1.1: USB disconnect, device number 91
So it looks like handshake.py script is keeping bootloader alive for longer than 2secs and then your plugin comes in. Last thing I get from script is:
nbdkit: debug: accepted connection
and then after few seconds preloader disappears and appears as ACM1 instead of ACM0 and after around 2 seconds as expected disconnects.
What might be wrong here?
I also have this line:
ATTRS{idVendor}=="0e8d", ATTRS{idProduct}=="2000", ENV{ID_MM_DEVICE_IGNORE}="1"
in /etc/udev/rules.d/20-mm-blacklist-mtk.rules.
I had to add this before to make SP Flash Tools work. So it doesn't interfere with ModemManager but still the same output. I tried with and without rule with restarting of udev in between of course. Without this rule preloader doesn't appear and phone gets detected as idVendor=0e8d, idProduct=0003.
@androidrbox Could you see if it's still working for you and what should be the correct output?
Sorry, I forgot to reply. I would recommend completely removing modemmanager to ensure it's not causing any problems. As for the whole process not working. If you're bootloader doesn't have debug enabled, the commands to read and write memory aren't going to work.
ModemManager gone and still same problem. Somehow it happened I can look at bootloader source^^ Do you know which flag should enable debugging?