Fix "DRAM setup failed: unpack requires a buffer of 12 bytes" in mtkclient on Xiaomi Redmi 9A (dandelion, MT6765, 2GB Micron LPDDR4X)

Open
#405 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
embedded-iot

Research direction

Read the linked reverse-engineering repository and inspect the MTK_DA_V5.bin comparison at 0x214602 alongside the Xiaomi preloader EMI table entries described in the issue. Determine how the multi-byte MR5 values cause DA1 to reject the RAM configuration; done means the reported Redmi 9A setup no longer halts with the EMI error or freezes in BROM mode.

Written by the indexing model from the issue text.

Description

I recently reverse-engineered MTK_DA_V5.bin (Stage 1) to find the exact root cause of this crash on blossom/dandelion boards.
It turns out that the stock Download Agent bundled with mtkclient performs a strict 32-bit comparison (cmp r3, r2 at 0x214602) against the 8-bit MR5 RAM vendor ID read from the LPDDR4X chip. In Xiaomi's stock preloader EMI table, certain RAM entries (such as Entry 1 with MR5 = 0xff1301 and Entry 3 with MR5 = 0xff01) store multi-byte values in that field, so they get rejected by MTK_DA_V5.bin, causing DA1 to halt with "[EMI] setting failed 0xffffffff" and freeze the phone in BROM mode until the battery is physically disconnected.

Dominant language
Python
Stars
1.5k
Forks
309
Avg merge
1d 7h
Merged PRs (30d)
2

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bkerler/mtkclient

All issues in bkerler/mtkclient

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.