Skip to content

Questions on the process. #1

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

Open
santiac89 opened this issue Jun 5, 2023 · 41 comments
Open

Questions on the process. #1

santiac89 opened this issue Jun 5, 2023 · 41 comments

Comments

@santiac89
Copy link

Hey, just reaching out since I'm diving into the same but with less experience.

I've tied to UART and USB but on fastboot I don't get a green ring on the device, neither fastboot lists the device. I'm wondering if I'm doing the connection wrongly since I'm only using 3 of the pads (D-, D+, GND). On the other side, a USB device is appearing on my computer, so I'm not entirely sure. I'm using a USB-C female connector type as interface, maybe I did a mistake trying to figure which pad goes to which pin.

Besides that, I tried https://github.com/MTK-bypass/bypass_utility which allegedly disables bootrom protection, and then using SP Flash Tool I'm trying to dump the entire memory of the thing. The thing is that I'm missing a scatter file for it, do you think that is possible to build one just using the partition table that you documented? (btw, my UART log shows a different and shorter partition table, maybe a SW difference?).

As I mentioned, I'm a beginner in all of this so probably mostly of what I mentioned makes no sense or is incorrect.

Hope you are good!

@jvandewiel
Copy link
Owner

Hi, thank you for your interest in this little project :-). I have been working on this on and off over the past year, and will have to update some information on the wiki/repo, which I will do this week.

I have tried a couple of different tools that are used for bypassing the bootloader protection (I will add a page of the tools) but none of them with success, including the MTK-bypass utility and the flash tool. There is bootloader source code available (I will add a page to the wiki) and it is possible to interact with the bootloader, but none of the things I have tried get me much further. The scatter file I also tried, and did not get to work. I do have the dump from the flash and managed to de-scramble it and find out more about the filesystems and files that are used, but also here ran into some challenges. I am also not sure how much of this can legally be shared via github.

What you can try is to connect to the UART - you only need 2 - and connect TM54 to GND (it is right of the connector on the main board) which gave me this log which I think goes into fastboot. Let me try to collect and structure some more info add it to the wiki.

When I started this I did not know anything either, still don't, but it's always fun to learn something new :-)

@santiac89
Copy link
Author

Thanks for the response!

What you mention about the bypass utility, I believe it did bypass the protection for me, I will later share some output logs but there is another tool called mtkclient which showed me some more info about the matter. What I did was first run MTK-bypass and later retrieve some information and the output showed SLA, SBC and DAA as disabled. But still, not sure if that is really the case.

I also managed through mtkclient to dump the brom, preloader and sram presumably succesfully. Not sure what to do with that though, I pass it to ghidra and managed to see some decompiled strings and functions but did not gave it too much time to be honest.

Something about your log that I noticed is that the partition table printed at the end differs from mine as I mentioned earlier, I will try pulling TM54 to ground to check if the output is different.

Glad to hear that you are still working on it! Good work so far! And I agree, always fun to learn!

@jvandewiel
Copy link
Owner

Hi, I would very much like to try the mtkclient approach, see if it works for me as well. I have managed to read the flash data and have the binary images, but it is hard to actually read and I have tried a lot of things to get from the original binary data from the flash via xor-ing, various filesystems (ubifs, squash, etc) to something that resembles files and directories, but with very little success. But it gives a benchmark to compare against when reading via MTK-bypass and mtkclient. I will look into that.

The partitions and what is logged can indeed be different, I also have a later dot firmware version which does not even show the partition data in any of the UART logs.

@jvandewiel
Copy link
Owner

Hi, I did a quick check of the files you have uploaded in the mtkclient issue.

The preloader looks good - see the brhgptpl_0.bin file here, which is basically a (semi-raw) dump of the brhgptpl partition that I read from the flash, where you find the same data as in your preloader starting at offset 24576 in that file. This helps me as well, because I was trying to find a way to convert/map the raw flash data (4096 bytes per flash-page with xor-data and ecc-data) to something else and with this I think I can figure that out.

The brom also looks good, I can recognize some of the strings that are also in the above linked file, at least the following:

  • BRLYT at brom offset 15900 which is a header at offset 3072 in brhgptpl_0.bin
  • [USBDL] at brom offset 24330 which is also logged in the UART logs, it is the brom waiting for a USB connection (and what you used with the bypass)
  • MMMFILE_INFO at brom offset 58149 which is refering to the MMM-related headers at offset 24576 in brhgptpl_0.bin, see also here
  • NFIINFO.BOOTLOADER at brom offset 67668 which is referring to the bootloader header at offset 0 in brhgptpl_0.bin

So I would say this looks very promising!

What is in the the sram data?

@santiac89
Copy link
Author

I checked it really fast yesterday and it was mostly strings, but again I have no experience and didn't put much time in it.
I'm writing this really fast since I need to go out right now but will come back. meanwhile here is the file.

sram_mt8516_echo_dot_3.zip

Will come back later and check your messages :)

@santiac89
Copy link
Author

I checked a bit the sram file with ghidra and as I said there are a lot of strings, they seem templates of what the device spits out through UART when booting

image

@jvandewiel
Copy link
Owner

I don't know what the right settings are to load the brom into ghidra - I tried various languages (i.e. arm v8a, le 64 bits) and ram offsets, but I don't get any function tree or anything, except for the same strings as you have. I would expect that the brom can be loaded and it is possible to find i.e. the USB connection functions and see how the functions are related. A bit more research is needed. Also never really used ghidra, so no idea what the right approach is...

Maybe I will try with my echo version to get the same files - did you use the mtk-bypass and client tools in Windows or Linux or other?

@santiac89
Copy link
Author

I'm running on Windows 10.

From what I checked, the processor is a Cortex-A35 (64-Bit Armv8-A). But ghidra cant decompile it for some reason (could be encryption?).

If you use arm v8 as languaje it can decompile some, but also there some stuff at the end that I guess it cannot, it appears as ?? symbols but I'm not sure if that means that it is not decompiled or something else (maybe data?).

image

I never used ghidra before so I'm on the same boat.

@jvandewiel
Copy link
Owner

OK, I am running Ubuntu and Windows 11. On Ubuntu the bypass utility fails, on windows it is stuck. Do you have a step-by-step on how you managed to run the bypass and mtk client utils and the payload you used for the bypass?

I think, if you managed to get the brom, sram etc, that with a scatter file it might be possible to get a dump from the flash. I tried once to put something together - maybe this helps as a start, see this google sheet under the scatter tab. It concatenates in the O column which you can copy to a text file. Some basic parameters might be needed as well (e.g. page size).

I think it might also be possible to get the scatter from the sram dump, will look into that, specifically if your partition table is different. But with your results so far, I would think it becomes possible to dump the flash, bypass the security in the bootloader or LK and flash a modified version.

@santiac89
Copy link
Author

santiac89 commented Jun 8, 2023

Actually, I think my table is shorter due to a communication issue only. I'm using a JTAGulator and 921600 baud rate is not entirely supported, I added it myself to the firmware but it seems to skip bytes at that speed .

What I do is:

  1. MTK-bypass setup:
    a. Download https://github.com/MTK-bypass/exploits_collection
    b. Download https://github.com/MTK-bypass/bypass_utility
    c. Move contents of exploits_collection to the bypass_utility folder
  2. Connect device to USB and UART but no power.
  3. Run (python3) PS C:\Users\XXXX\Development\EchoDotV3\bypass_utility> python .\main.py
    a. I don't specify payload but it is using payload_mt8167.bin that I downloaded from exploits_collection.
  4. Connect the power cord while pressing the Dot button (like fastboot mode)
    Output:
[2023-06-07 16:48:08.666633] Waiting for device
(Once power is applied while pressing dot button)
[2023-06-07 16:48:14.038230] Found device = 0e8d:0003

[2023-06-07 16:48:14.280230] Device hw code: 0x8167
[2023-06-07 16:48:14.281230] Device hw sub code: 0x8a00
[2023-06-07 16:48:14.281230] Device hw version: 0xcb00
[2023-06-07 16:48:14.281230] Device sw version: 0x1
[2023-06-07 16:48:14.282229] Device secure boot: True
[2023-06-07 16:48:14.282229] Device serial link authorization: False
[2023-06-07 16:48:14.282229] Device download agent authorization: True

[2023-06-07 16:48:14.282229] Disabling watchdog timer
[2023-06-07 16:48:14.284229] Disabling protection
[2023-06-07 16:48:14.341228] Protection disabled
  1. And then just run mtk-client gettargetconfig option to check status
(python3) PS C:\Users\XXXX\Development\EchoDotV3\mtkclient> python mtk gettargetconfig
MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile
Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0x0
Preloader -     SBC enabled:            False
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            False
Preloader -     SWJTAG enabled:         False
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          False
Preloader -     Mem write auth:         False
Preloader -     Cmd 0xC8 blocked:       False
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      92691A43F8E190DD5326A2EB62B31109
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
Main - Getting target info...
Preloader - Target config:              0x0
Preloader -     SBC enabled:            False
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            False
Preloader -     SWJTAG enabled:         False
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          False
Preloader -     Mem write auth:         False
Preloader -     Cmd 0xC8 blocked:       False

That is why I believed is bypassed. BUT, compared with the output when bypass_utility has not been run I see that some others parameters are set to False

(python3) PS C:\Users\XXXX\Development\EchoDotV3\mtkclient> python mtk gettargetconfig
MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile
Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      92691A43F8E190DD5326A2EB62B31109
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
Main - Getting target info...
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True

Check Mem read auth, Mem write auth, and so on. In normal operation (without bypass_utility) they are set to True.

Will check what you mention about the scatter.

@jvandewiel
Copy link
Owner

Hi, I tried this with another echo dot I have not tinkered with, and this seems to works for me now as well. I only had GND and USB D+/D- connected, no UART. I managed to run the bypass and got the same output for python mtk gettargetconfig:

$ python3 mtk gettargetconfig

MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile
Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0x0
Preloader -     SBC enabled:            False
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            False
Preloader -     SWJTAG enabled:         False
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          False
Preloader -     Mem write auth:         False
Preloader -     Cmd 0xC8 blocked:       False
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      CCCA4E53BFD309EADCF4351BF3379434
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
Main - Getting target info...
Preloader - Target config:              0x0
Preloader -     SBC enabled:            False
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            False
Preloader -     SWJTAG enabled:         False
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          False
Preloader -     Mem write auth:         False
Preloader -     Cmd 0xC8 blocked:       False

I tried dumpbrom, dumpsram and dumppreloader but that did not work on my Ubuntu system - I tries to send Kamakiri which requires a special kernel etc. so maybe that is the reason - will investigate a bit more. It might be possible to read/write to the flash with this - exciting!

@santiac89
Copy link
Author

Cool! I just got home, I will try to recreate a scatter file from your google sheet to see if I can do it through SP Flash Tool.

@jvandewiel
Copy link
Owner

jvandewiel commented Jun 9, 2023

Hi, I have made some progress but not much further than you were. I though that the bypass utility was to be used together with the mtk client, but I guess the mtk client does it all - no need to use the bypass utility first. I have now been able to get the sram, bootrom and preloader binaries as well, and I can confirm that they are the same (or similar enough) to yours. The mtk client hangs on DAXFlash upload (see below) and there is an error with the DA (Download agent) patching - I will try to find out what that is.

$ python3 mtk r boot1 boot.img
MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile

Port - Hint:

Power off the phone before connecting.
For brom mode, press and hold vol up, vol dwn, or all hw buttons and connect usb.
For preloader mode, don't press any hw button and connect usb.
If it is already connected and on, hold power for 10 seconds to reset.


...........
Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      CCCA4E53BFD309EADCF4351BF3379434
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
PLTools - Loading payload from mt8167_payload.bin, 0x264 bytes
PLTools - Kamakiri / DA Run
Kamakiri - Trying kamakiri2..
Kamakiri - Done sending payload...
PLTools - Successfully sent payload: /home/joost/Projects/gitea/echodotv3/tools/mtkclient/mtkclient/payloads/mt8167_payload.bin
Port - Device detected :)
DA_handler - Device is protected.
DA_handler - Device is in BROM mode. Trying to dump preloader.
DAXFlash - Uploading xflash stage 1 from MTK_AllInOne_DA_9.9999.bin
xflashext - Patching da1 ...
Mtk - Patched "Patched loader msg" in preloader
xflashext
xflashext - [LIB]: Error on patching da1 version check...
Mtk - Patched "Patched loader msg" in preloader
Mtk - Patched "get_vfy_policy" in preloader
xflashext - Patching da2 ...
DAXFlash - Successfully uploaded stage 1, jumping ..
Preloader - Jumping to 0x200000
Preloader - Jumping to 0x200000: ok.
DAXFlash - Successfully received DA sync
DAXFlash - Sending emi data ...
DAXFlash - DRAM setup passed.
DAXFlash - Sending emi data succeeded.
DAXFlash - Uploading stage 2...
DAXFlash - Upload data was accepted. Jumping to stage 2...
DAXFlash - Successfully uploaded stage 2
DAXFlash - EMMC FWVer:      0x0
DAXFlash - EMMC ID:         H4G2a
DAXFlash - EMMC CID:        90014a483447326111020f58b11225c7
DAXFlash - EMMC Boot1 Size: 0x400000
DAXFlash - EMMC Boot2 Size: 0x400000
DAXFlash - EMMC GP1 Size:   0x0
DAXFlash - EMMC GP2 Size:   0x0
DAXFlash - EMMC GP3 Size:   0x0
DAXFlash - EMMC GP4 Size:   0x0
DAXFlash - EMMC RPMB Size:  0x400000
DAXFlash - EMMC USER Size:  0xe9000000
DAXFlash - HW-CODE         : 0x8167
DAXFlash - HWSUB-CODE      : 0x8A00
DAXFlash - HW-VERSION      : 0xCB00
DAXFlash - SW-VERSION      : 0x1
DAXFlash - CHIP-EVOLUTION  : 0x0
DAXFlash - DA-VERSION      : 1.0
DAXFlash - Reconnecting to preloader
DeviceClass - [Errno 2] Entity not found
DAXFlash - Connected to preloader
DAXFlash - Upload data was accepted. Jumping to stage 2...
^Z
[8]+  Stopped                 python3 mtk r boot1 boot.img

You can also see some information about the flash pparitions in this section, with wich we maybe can make a scatter file

DAXFlash - EMMC FWVer:      0x0
DAXFlash - EMMC ID:         H4G2a
DAXFlash - EMMC CID:        90014a483447326111020f58b11225c7
DAXFlash - EMMC Boot1 Size: 0x400000
DAXFlash - EMMC Boot2 Size: 0x400000
DAXFlash - EMMC GP1 Size:   0x0
DAXFlash - EMMC GP2 Size:   0x0
DAXFlash - EMMC GP3 Size:   0x0
DAXFlash - EMMC GP4 Size:   0x0
DAXFlash - EMMC RPMB Size:  0x400000
DAXFlash - EMMC USER Size:  0xe9000000

Files are
bootrom
preloader
sram

@santiac89
Copy link
Author

santiac89 commented Jun 9, 2023

Nice to hear that we can get rid of bypass_utility!

Btw, I also have the same error on da1 patching but mine never got past DAXFlash - Uploading stage 2.... I get a DA Hash mismatch error right after that!

(python3) C:\Users\Santiago\Development\EchoDotV3\mtkclient>python mtk r boot1 boot.img
MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile

Port - Hint:

Power off the phone before connecting.
For brom mode, press and hold vol up, vol dwn, or all hw buttons and connect usb.
For preloader mode, don't press any hw button and connect usb.
If it is already connected and on, hold power for 10 seconds to reset.


....Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      92691A43F8E190DD5326A2EB62B31109
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
PLTools - Loading payload from mt8167_payload.bin, 0x264 bytes
PLTools - Kamakiri / DA Run
Kamakiri - Trying kamakiri2..
Kamakiri - Done sending payload...
PLTools - Successfully sent payload: C:\Users\Santiago\Development\EchoDotV3\mtkclient\mtkclient\payloads\mt8167_payload.bin
Port - Device detected :)
DA_handler - Device is protected.
DA_handler - Device is in BROM mode. Trying to dump preloader.
DAXFlash - Uploading xflash stage 1 from MTK_AllInOne_DA_5.2152.bin
xflashext - Patching da1 ...
Mtk - Patched "Patched loader msg" in preloader
xflashext
xflashext - [LIB]: ←[33mError on patching da1 version check...←[0m
Mtk - Patched "Patched loader msg" in preloader
Mtk - Patched "get_vfy_policy" in preloader
xflashext - Patching da2 ...
DAXFlash - Successfully uploaded stage 1, jumping ..
Preloader - Jumping to 0x200000
Preloader - Jumping to 0x200000: ok.
DAXFlash - Successfully received DA sync
DAXFlash - Sending emi data ...
DAXFlash - DRAM setup passed.
DAXFlash - Sending emi data succeeded.
DAXFlash - Uploading stage 2...
DAXFlash - Booting to DA at 0x40000000
DAXFlash
DAXFlash - [LIB]: ←[31mError on sending data: DA hash mismatch (0xc0070004)←[0m
DAXFlash
DAXFlash - [LIB]: ←[31mError on booting to da (xflash)←[0m

Also, is the download agent MTK_AllInOne_DA_9.9999.bin included in mtkclient? Or is just a modified version?

Note: I found these articles about some deep dive of the booting process for some other MediaTek device which I think could be helpful http://www.lieberbiber.de/category/mediatek/

@santiac89
Copy link
Author

Is there any significante message on UART side when it hangs?

@jvandewiel
Copy link
Owner

I don't know, but I will try with UART connected later this weekend. I downloaded an old version of the MTK_AllInOne_DA_*.bin which is the 9.999 version. It's actually 3.-something, found that somewhere on the 'net for the MT8167. The mtk client uses the latest version so that's why I named in 9.999
MTK_AllInOne_DA_9.9999.zip

@santiac89
Copy link
Author

It seems that mtkclient for Windows works differently so I get that hash mismatch error. And I don't have any Linux machine to try with :( Tried with VM but seems to be a pain

@santiac89
Copy link
Author

So, not OS related. I tried with the Live DVD from mtkclient and I'm getting teh same hash mismatch error :(

@jvandewiel
Copy link
Owner

I tried with the UART connected, not much more there - this is a log of python3 mtk r boot1 boot.img:

mtk client

For preloader mode, don't press any hw button and connect usb.
If it is already connected and on, hold power for 10 seconds to reset.


...........
Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      CCCA4E53BFD309EADCF4351BF3379434
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
PLTools - Loading payload from mt8167_payload.bin, 0x264 bytes
PLTools - Kamakiri / DA Run
Kamakiri - Trying kamakiri2..
Kamakiri - Done sending payload...
PLTools - Successfully sent payload: /home/joost/Projects/gitea/echodotv3/tools/mtkclient/mtkclient/payloads/mt8167_payload.bin
DA_handler - Device is protected.
DA_handler - Device is in BROM mode. Trying to dump preloader.
DAXFlash - Uploading xflash stage 1 from MTK_AllInOne_DA_5.2152.bin
xflashext - Patching da1 ...
Mtk - Patched "Patched loader msg" in preloader
xflashext
xflashext - [LIB]: Error on patching da1 version check...
Mtk - Patched "Patched loader msg" in preloader
Mtk - Patched "get_vfy_policy" in preloader
xflashext - Patching da2 ...
Preloader
Preloader - [LIB]: Error on DA_Send cmd
DAXFlash
DAXFlash - [LIB]: Error on sending DA.

UART

[DL] 00001388 00000000 010303

Entered mt8167 brom patcher
Copyright k4y0z/bkerler 2021
R:USB
S:ACK
W:Handshake

@santiac89
Copy link
Author

I was not able to get past Uploading stage 2 step while trying to read entire flash. I got in contact with mtkclient developer and he was trying to help me with a bunch of modifications to the program and a DA file but no luck so far.

I tried with the Live DVD from him to see if I can get rid of the hash mismatch error but got the same.

The only thing I was able to was to read back 256Mb of memory using the stage commands from mtkclient, but it wont read past the 256Mb mark.

You can check it here, maybe it works different for you since you were able to go further.

I also found 2 papers regarding reading the NAND dumps, maybe that can help you:

D_Pawlaszczyk_J_Friese_C_Hummert_Alexa_tell_me_-_A.pdf

Amazon_Echo_Forensics_for_WISEC_final.pdf

I'm stuck at this point since I cannot get a dump of the entire flash

@jvandewiel
Copy link
Owner

Hi, what were the stag/stage2 commands you tried? The normal mtk client attempts gave me the same resutls in the mentioned issue.

@santiac89
Copy link
Author

python mtk stage uploads some generic stage1 payload to the device, which I guess is some code that receives commands from the stage2 script and responds accordingly while in BROM mode.

Then python stage2 memread <offset> <length> for example for dumping the preloader.

@jvandewiel
Copy link
Owner

OK, I see - but this python stage2 memread <offset> <length> is a memory/sram dump, not a dump of the flash drive. So probably that's why you never get more than 512MB as that is the available RAM. You can also check the contents of the file, and probably see that there are only of 00's at the end and that bytes at the start are the same as the dumped bootrom binary. Will investigate the other route via mtk a bit more.

@santiac89
Copy link
Author

From this comment from the dev it seems the other way 🤔 but it could be. I will check the file contents and compare to the other dumps

@santiac89
Copy link
Author

So I was able to find both the preloader and bootrom in the dumped file, but there is also a lot of other data.

@jvandewiel
Copy link
Owner

If the dev says so, then it probably is - sure he knows better than me :-) I will try to memread it all with python3 stage2 memread 0 1fffffff > dump_all.bin and see what I get. There should be around 520mb of data in total, and I have some of the data from the flash in another way, so should be able to determine if it is indeed more than just brom and preloader. To be continued ...

@santiac89
Copy link
Author

santiac89 commented Jun 12, 2023 via email

@santiac89
Copy link
Author

@jvandewiel If I sent you the dump would you be able to compare it against the dump that you have?

@jvandewiel
Copy link
Owner

Hi, yes, that would certainly be possible. I can also put the dumps that I have somewhere, not sure about github policies for this. My dump is direct from the flash and needs a bit of work to make it useable - but I can share what I have. I tried the dump through stage/stage2, but it looks like it is all 00's after about 3mb; I will try again. I will also try to erase the pre-loader and run the stage/stage2 as suggested by the mtk client dev after that - likely tomorrow.

@jvandewiel
Copy link
Owner

Hi, I tried a few times to dump via stage2, each time the file maxes out around 268 MB and then the mtk tool "hangs". The contents of them are the same: the first ~3.14 MB (0-0x2FFFFE) contains data which is bootrom, preloader and some other data and then 0x00 for the rest of the file. The logs are below.

Loading stage2

$ python3 mtk stage
MTK Flash/Exploit Client V1.6.2 (c) B.Kerler 2018-2023

Preloader - Status: Waiting for PreLoader VCOM, please connect mobile

Port - Hint:

Power off the phone before connecting.
For brom mode, press and hold vol up, vol dwn, or all hw buttons and connect usb.
For preloader mode, don't press any hw button and connect usb.
If it is already connected and on, hold power for 10 seconds to reset.


....Port - Device detected :)
Preloader -     CPU:                    MT8167/MT8516/MT8362()
Preloader -     HW version:             0x0
Preloader -     WDT:                    0x10007000
Preloader -     Uart:                   0x11005000
Preloader -     Brom payload addr:      0x100a00
Preloader -     DA payload addr:        0x201000
Preloader -     CQ_DMA addr:            0x10212c00
Preloader -     Var1:                   0xcc
Preloader - Disabling Watchdog...
Preloader - HW code:                    0x8167
Preloader - Target config:              0xe5
Preloader -     SBC enabled:            True
Preloader -     SLA enabled:            False
Preloader -     DAA enabled:            True
Preloader -     SWJTAG enabled:         True
Preloader -     EPP_PARAM at 0x600 after EMMC_BOOT/SDMMC_BOOT:  False
Preloader -     Root cert required:     False
Preloader -     Mem read auth:          True
Preloader -     Mem write auth:         True
Preloader -     Cmd 0xC8 blocked:       True
Preloader - Get Target info
Preloader - BROM mode detected.
Preloader -     HW subcode:             0x8a00
Preloader -     HW Ver:                 0xcb00
Preloader -     SW Ver:                 0x1
Preloader - ME_ID:                      CCCA4E53BFD309EADCF4351BF3379434
Preloader - SOC_ID:                     0000000000000000000000000000000000000000000000000000000000000000
Main - Uploading stage 1
PLTools - Loading payload from generic_stage1_payload.bin, 0x3e8 bytes
PLTools - Kamakiri / DA Run
Kamakiri - Trying kamakiri2..
Kamakiri - Done sending payload...
PLTools - Successfully sent payload: /home/joost/Projects/gitea/echodotv3/tools/mtkclient/mtkclient/payloads/generic_stage1_payload.bin
Main - Successfully uploaded stage 1, sending stage 2
Main - Done sending stage2, size 0x4000.
Main - Done jumping stage2 at 00201000
Main - Successfully loaded stage2

For dumping via stage2 (which I broke-off after an overnight run)

$ python3 stage2 memread 0 1fffffff --filename dump_all2.bin
^CTraceback (most recent call last):
  File "/home/joost/Projects/gitea/echodotv3/tools/mtkclient/stage2", line 710, in <module>
    main()
  File "/home/joost/Projects/gitea/echodotv3/tools/mtkclient/stage2", line 629, in main
    st2.memread(start, length, args.filename)
  File "/home/joost/Projects/gitea/echodotv3/tools/mtkclient/stage2", line 262, in memread
    wf.write(self.usbread(size))
  File "/home/joost/Projects/gitea/echodotv3/tools/mtkclient/mtkclient/Library/Connection/usblib.py", line 432, in usbread
    extend(epr(resplen))
  File "/usr/local/lib/python3.10/dist-packages/usb/core.py", line 423, in read
    return self.device.read(self, size_or_buffer, timeout)
  File "/usr/local/lib/python3.10/dist-packages/usb/core.py", line 1029, in read
    ret = fn(
  File "/usr/local/lib/python3.10/dist-packages/usb/backend/libusb1.py", line 846, in bulk_read
    return self.__read(self.lib.libusb_bulk_transfer,
  File "/usr/local/lib/python3.10/dist-packages/usb/backend/libusb1.py", line 946, in __read
    retval = fn(dev_handle.handle,
KeyboardInterrupt

I will try with a --loader and also to erase the preloader and see if that helps, later today.

@santiac89
Copy link
Author

Exactly like my dump, 256Mb or so, bootrom, preloader, other stuff, and zeros.

@jvandewiel
Copy link
Owner

jvandewiel commented Jun 14, 2023 via email

@santiac89
Copy link
Author

I didn't. I'm still thinking about the error I get about a DA hash mismatch. The mtkclient dev patched it somehow but I believe that the underlying error will keep me from going further since I get the same error with SP Flash Tools.

I wonder if it is OS related even that I tried with a Linux Live DVD but I don't have any other computer to try with.

@santiac89
Copy link
Author

Hi @jvandewiel hope you are doing well. Any update? I managed to get a hold on a Linux laptop to discard that my issue is with the OS but still same results, I guess my Dot is a little different or different SW version that yours.

@jvandewiel
Copy link
Owner

jvandewiel commented Jun 27, 2023

Hi, thanks, all fine here - you? No updates on my end. I have not managed to get the erase to work, somehow it fails. Will try a few other things, but so far no progress.

@retpolanne
Copy link

I'm interested in participating on this. I did some work on reversing Chromecast/Google Home a while back and would love to de-Amazon my Echo.

@jvandewiel
Copy link
Owner

Hi, thank you for reaching out! To be fair, I have had this project on ice for a while, but perhaps it is time to start it up again :-)

Last year we have had some progress with the mtkclient and managed to get the preloader and bootloader, but we (see above) did not get much further. I also have all the data that I retrieved from the flash, but this is a raw nand dump and encoded in various ways. I can share what I have, both what I figured out and where I got stuck. It is not in this repo, but I can add it, the dump maybe via another route - I am not sure about that one?

I was wondering if it would be possible to extract the certificates from the dump and pretend to be an amazon device and that way get a full new firmware version that can be analyzed, but this is a very much out of my comfort zone. Anyways, what can I give you to help you get started?

@santiac89
Copy link
Author

I haven't had done any progress neither and I think this is way out of my league but I'm here to help with anything related to software.

Good to see there is some interest in this!

@nk-gears
Copy link

This may be a out of topic on the Echo 3rd Gen. But would like to know whether you have any infromation on this strange behaviour.

  • Echo Dot 3rd Gen - Restarts Randomly (every 2-4 mins). Then becomes unresponsive with a blue ring static
  • None of the buttons responding. Except the MIC red LED
  • After Factory Resetting multiple times, worked for 10 minutes and again becomes unresponsive.

The same device was working few months back. Di anyone faced this behaviour?. Do you think Amazon bricked all old generation devices as the same issue reported in multiple forums.

@gilderchuck
Copy link

gilderchuck commented Mar 18, 2025

https://github.com/jvandewiel/no-alexa/wiki/Hardware#overview

There are multiple revision in the wild with some differences.

Just a reminder that the Echo Dot 3rd Generation was in fact TWO devices: an MMC version and a NAND one.
(At least that's what I've found so far. This must be the reason why there have been two 'latest' version numbers shown for years next to the Echo Dot 3rd Gen on Amazon's Alexa Device Software Versions page.)

The initial/early one (model no D9N29T, codename 'Donut') released in 2018 contained a combined DDR + MMC chip (eMCP). It stored user data on an ext4 filesystem. High quality teardowns: 1, 2

A year later the Echo Flex and Echo Dot with Clock were announced. Their internals had gone through an important redesign: they used separate DDR RAM and raw NAND flash chips. Around the same time a new version of the regular Dot 3 also started shipping: model no C78MP8 (codename 'Crumpet'), the NAND version. Teardowns: 1, 2
(Running ext4 filesystem would wear out NAND blocks in a short time, so the user data partition type was changed to the flash-aware UBIFS on the new devices.)

Based on the teardowns I've seen it's quite likely that Amazon made the switch to raw NAND storage for smart speakers in 2019. (The only exception I found so far was the Spot 2024.)


While most of this repository is neatly focused on the Crumpet/NAND variant I can see a few additions suggesting that they were run/taken on a Donut model. Please be aware of the differences ... which start at what type of storage the preloader can handle:

$ strings preloader_donut.bin | grep -Eo '(nand|mmc)_[A-Za-z_]*'
mmc_set_part_config
mmc_set_part_config
mmc_rpmb_req_handle
mmc_rpmb_part_ops
mmc_rpmb_block_read
mmc_rpmb_start_req
mmc_rpmb_check_result
mmc_rpmb_block_write
mmc_rpmb_get_wc
mmc_rpmb_post_frame
mmc_rpmb_send_command

$ strings preloader_mt8516_echo_dot_3.bin | grep -Eo '(nand|mmc)_[A-Za-z_]*'
nand_bbt
nand_mem_len
nand_default_bbt
nand_markbad_bbt
nand_block_mapping
nand_bwrite
nand_move_worn_bad_blk
nand_bread
nand_berase
nand_do_erase_ops
nand_do_write_ops
nand_IO_strength_adjust
nand_flash_get
nand_wait_func
nand_scan
nand_wait_ready
nand_block_markbad
nand_malloc
nand_chip_init

The preloaders attached here and in the linked ticket also seem to be different versions, they were compiled years apart:

$ strings preloader_donut.bin | grep -A1 'Build Time'
%s Build Time: %s
20191028_221405
$ strings preloader_mt8516_echo_dot_3.bin | grep -A1 'Build Time'
%s Build Time: %s
20220323_062523

@jvandewiel
Copy link
Owner

Hello everyone - this is just to inform you that @gilderchuck has been able to actually make the dumped binary files into a readable and mountable image. If you are interested, please reach out privately; this image will not be published in the open due to the DMCA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants