bkerler / edl

Inofficial Qualcomm Firehose / Sahara / Streaming / Diag Tools :)
GNU General Public License v3.0
1.59k stars 372 forks source link

Erase of userdata is brutally slow #500

Closed bongbui321 closed 7 months ago

bongbui321 commented 8 months ago

I'm trying to replace fastboot and use edl instead for flashing my devices. The workflow involves flashing and erase partition such as userdata and cache. I don't know if anyoneelse experience this but the erase of userdata partition is extremely slow compared to that of fastboot which takes ~0.5s. Any idea of how to fix this or what causes this? Tks in advance

Erasing from physical partition 0, sector 75336, sectors 6383027
Progress: |██--------|  18.0% Erase (Sector 0x117C of 0x6165, 52m:32s left) 6.45 MB/s
RenateUSB commented 8 months ago

A good question. This is a 32 GB UFS device?

firehose.cmdErase() is not an actual erase but a Firehose program command with zeroes.

You're running10% of USB 2 HS. Can this do USB 3?

Both eMMC and UFS support actual erase, but I'm not sure if the Firehose loaders support that with erase. I have used erase over Firehose for (raw) NAND memories.

bongbui321 commented 8 months ago

Thank you for the response. I want to erase an ufs memory

RenateUSB commented 8 months ago

fastboot -w is probably quicker.

bongbui321 commented 7 months ago

@RenateUSB just trying to get what you saying. Do you mean the memory itself has erase but eh firehose loader doesnt support it? hmm I want to make it edl only, is that possible without the penalty of slowness?

RenateUSB commented 7 months ago

All current "flash" memory is actually NAND, but it has different controllers. Therefore, theoretically, they are capable of erasing as a single "BLAM!" event. Actually, writing NAND memory as zeroes (or even ones) is counterproductive. You are still saying, "I am using this page and it is filled with this data". When you erase a page, you are saying, "I don't need this page, clear it and leave it for someone who needs it". Ok, in NAND (vs. eMMC or UFS) the difference is clear.

In any case, as I read it from the code, an erase in this Firehose client is the same as writing zeroes from a file. Which will take long. But not as long as you are experiencing because there appears to be something slowing down your USB.

bongbui321 commented 7 months ago

Hmm, I just check that my programmer if I understand correctly is the firehose loader is an empty string, but when I run the write and reset or erase it still works. Doesn't it require the loader for the data to be transferred? I'm using a leeco phone. Does the hardware matter? Do I have to get an edl cable from what I understand it just get the phone into edl mode which I can do manually?

RenateUSB commented 7 months ago

It does transfer. It sends 32 GB (or so) of zeroes. Don't want to "erase"? Just make a file with 32 GB of zeroes and "program" instead. It's the same thing with this version of Python EDL client. Can you do this with an atomic erase option? Maybe, but this doesn't do that. Who cares? Do people erase on a daily basis?

bongbui321 commented 7 months ago

@RenateUSB

  1. Yup, but I want to ask if an edl cable is required or any cable should work with edl mode turned on manually?
  2. I'm not sure what you mean by "program"?
  3. And yes, I would like to erase since I would like to factory reset the machine.
  4. My firehose loader has programmer = "" in the edl_config.json file. Is the programmer the same as the loader? But the PBL (sahara protocol) does get a Loader that has firehose protocol. Thank you for spending time answering my questions.
RenateUSB commented 7 months ago

I'm just saying that with this EDL client there is no real erase, just program and that an erase takes exactly as long as it would take to program 32 GB of random data. Is it erased afterward? Well, it's filled with zeroes. Is that good enough for you?

User       Python          Firehose    Data
Input      Function        Command     Sent
─────────  ──────────────  ──────────  ────────────────────
"edl w"    cmd_program()   <program>   32 GB data from file
"edl e"    cmd_erase()     <program>   32 GB of zeroes

If you're talking Firehose protocol you must have loaded a Firehose loader at some point. You only need to do this once per reset.

Recovery has factory reset, fastboot has wipe, EDL has program with zeroes, whatever.