Skip to content
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

How do I write a partition table to a brand new UFS chip? Xiaomi 6 #555

Open
alderous opened this issue Jun 5, 2024 · 5 comments
Open

Comments

@alderous
Copy link

alderous commented Jun 5, 2024

My Xiaomi Mi 6 memory chip has dropped significantly, so I switched to a new larger and faster UFS2.1 chip.
I backed up the full 5 LUN partition and I unlocked BL.
The physical replacement of the chip went smoothly and QPST could correctly identify the correct model.
However, I encountered a problem writing to the backup.

~/edl$ edl wl dumps --memory=ufs --loader=Loaders/000930e100010000_a7b8b82545a98eca_fhprg_peek.bin
Qualcomm Sahara / Firehose Client V3.60 (c) B.Kerler 2018-2022.
main - Using loader Loaders/000930e100010000_a7b8b82545a98eca_fhprg_peek.bin ...
main - Waiting for the device
...main - Device detected :)
sahara - Protocol version: 2, Version supported: 1
main - Mode detected: sahara
sahara -

HWID: 0x0005e0e100000000 (MSM_ID:0x0005e0e1,OEM_ID:0x0000,MODEL_ID:0x0000)
CPU detected: "MSM8998_SDM835"
PK_HASH: 0xa7b8b82545a98eca23d6e9105fb464568d1b5828264903441bdef0cd57e3c370

sahara - Protocol version: 2, Version supported: 1
sahara - Uploading loader Loaders/000930e100010000_a7b8b82545a98eca_fhprg_peek.bin ...
sahara - 64-Bit mode detected.
sahara - Firehose mode detected, uploading...
sahara - Loader successfully uploaded.
main - Trying to connect to firehose loader ...
firehose
firehose - [LIB]: !DEBUG! rsp.data: 'bytearray(b'\n\n\n\n\n\n\n\n\n\n\n\n')'
firehose - TargetName=MSM8996
firehose - MemoryName=UFS
firehose - Version=1
firehose - Trying to read first storage sector...
firehose - Running configure...
firehose
firehose - [LIB]: GetStorageInfo command isn't supported.
firehose_client - Supported functions:

firehose
firehose - [LIB]: ERROR: Failed to open the UFS Device slot 0 partition 0
firehose
firehose - [LIB]: ERROR: Failed to open the device 3 slot 0 partition 0
firehose
firehose - [LIB]: INFO: Device type 3, slot 0, partition 0, error 0
firehose
firehose - [LIB]: WARN: Get Info failed to open 3 slot 0, partition 0, error 0
firehose
firehose - [LIB]: storage_device_get_num_partition_sectors FAILED!
firehose
firehose - [LIB]: parseSectorValue could not handle start_sector value
firehose
firehose - [LIB]: ERROR: Failed to open the UFS Device slot 0 partition 0
firehose
firehose - [LIB]: ERROR: Failed to open the device 3 slot 0 partition 0
firehose
firehose - [LIB]: INFO: Device type 3, slot 0, partition 0, error 0
firehose
firehose - [LIB]: WARN: Get Info failed to open 3 slot 0, partition 0, error 0
firehose
firehose - [LIB]: storage_device_get_num_partition_sectors FAILED!
firehose
firehose - [LIB]: parseSectorValue could not handle start_sector value

I'm getting the same error when using qpst and miflash.
The search engine told me that I needed to build a lub partition table first.i need provision.xml.How do I create this file? Is there an easier way?

@alderous
Copy link
Author

alderous commented Jun 5, 2024

I've also noticed the issue about firehose. EDL uses the default hit to boot, which will load the Firehose of the Xiaomi Mi A2. After my tests, only 2 of the loders were loaded correctly. The effect is exactly the same.

@alderous alderous closed this as completed Jun 5, 2024
@alderous alderous reopened this Jun 5, 2024
@RenateUSB
Copy link

RenateUSB commented Jun 6, 2024

I know nothing about UFS.
But some? are eMMC compatible with 4 fixed LUNs (user, boot0, boot1, rpmb).
But others? are flash/OTP configurable for number/size of LUNs.
It seems like you need to provision this thing into LUNs?

From a UFS manufacturer (probably not yours):
"By default, Device comes with no LUs provisioned therefore device must be provisioned to be able to store anything in the device."

See also https://patchwork.kernel.org/project/linux-scsi/patch/1528981432-23065-3-git-send-email-sayalil@codeaurora.org/

See also https://github.com/westerndigitalcorporation/ufs-utils

@alderous
Copy link
Author

alderous commented Jun 7, 2024

I know nothing about UFS. But some? are eMMC compatible with 4 fixed LUNs (user, boot0, boot1, rpmb). But others? are flash/OTP configurable for number/size of LUNs. It seems like you need to provision this thing into LUNs?

From a UFS manufacturer (probably not yours): "By default, Device comes with no LUs provisioned therefore device must be provisioned to be able to store anything in the device."

See also https://patchwork.kernel.org/project/linux-scsi/patch/1528981432-23065-3-git-send-email-sayalil@codeaurora.org/

See also https://github.com/westerndigitalcorporation/ufs-utils

Thank you for your reply.I've figured out the current situation.There is a qfil tool in the Qualcomm QPST toolkit. There is a FireJose Configuration setting in qfil, and the Provision function inside can solve my problem. But I lack a partition table configuration file: Provision.xml
I will continue to try to find this xml file.

@RenateUSB
Copy link

RenateUSB commented Jun 7, 2024

I'd be interested to see what the provisioning does.
It would be great if you had a USB sniffer or hardware analyzer to capture what it does.
I just meant the LUN provisioning, the GPT partitioning is just program in Firehose.
Don't forget the RPMB provisioning or you won't have any userdata (or maybe just encrypted userdata).

@RenateUSB
Copy link

I learned something new. The Firehose ufs command can provision UFS. Which makes sense. Unfortunately the XML for that takes a zillion attributes.

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

2 participants