- English (PayPal): https://www.paypal.com/paypalme/agrman
- 中文(支付宝 / 微信):
Qualcomm EDL (Emergency Download) 相关操作库,支持 Sahara/Firehose 通信、分区读写、OnePlus 兼容流程、
super免合并刷写、设备信息读取与 OCDT 生成。
A C# library for Qualcomm EDL workflows, including Sahara/Firehose communication, partition read/write, OnePlus compatibility flows, directsuperflashing, device info extraction, and OCDT generation.
Flash:串口连接、Sahara 引导下载、Firehose 配置、分区读写、擦除、重启、部分 OnePlus 认证流程。
Flash: serial connection, Sahara programmer download, Firehose configuration, partition read/write, erase, reboot, and selected OnePlus auth flows.SuperDirectWriter:识别散包并将逻辑分区直接写入super(支持官方 metadata 或重算 metadata)。
SuperDirectWriter: detect scattered ROM packages and write logical partitions directly intosuper(official metadata or regenerated metadata).DeviceInfoReader:从super/system读取build.prop并解析为键值。
DeviceInfoReader: read and parsebuild.propfromsuper/systeminto key-value pairs.OcdtGenerator:按projId生成/保存 OCDT,支持从文本中提取projId和 rawprogram 中的 OCDT 大小。
OcdtGenerator: generate/save OCDT byprojId, with helpers to extractprojIdand OCDT size from text/rawprogram.ProgressManager:统一进度事件(百分比、速度、状态)。
ProgressManager: unified progress event reporting (percentage, speed, status).
- .NET SDK:
10.0(项目目标框架为net10.0)
.NET SDK:10.0(target framework isnet10.0) - 操作系统:Windows(依赖
System.IO.Ports串口通信)
OS: Windows (usesSystem.IO.Portsserial communication) - 设备需处于 EDL 模式并可通过 COM 口访问。
Device must be in EDL mode and reachable through a COM port.
dotnet restore
dotnet build -c Releaseusing EDLLibrary;
using EDLLibrary.code.Utility;
using System;
using System.Threading;
ProgressManager.ProgressUpdated += (_, e) =>
{
Console.WriteLine($"{e.Progress:F2}% | {e.Speed:F2} MB/s | {e.Status}");
};
using var flash = new Flash("COM5", "ufs"); // storageType: "ufs" or "emmc"
flash.RegisterPort();
bool inFirehose = flash.ProbeDeviceMode();
if (!inFirehose)
{
bool saharaOk = flash.Sahara(@"C:\path\prog_firehose.elf");
if (!saharaOk) throw new Exception("Sahara failed.");
}
string cfg = flash.ConfigureDDR();
if (cfg != "success")
{
// possible values: success / failed / needsig / oplus_auth_failed
throw new Exception($"ConfigureDDR failed: {cfg}");
}
// Example write: file -> LUN0, start sector 0, label boot
flash.WriteFile(
filepath: @"C:\path\boot.img",
start_sector: "0",
num_sector: "0",
physical_partition_number: "0",
label: "boot",
token: CancellationToken.None);- 初始化与连接 / Init and connect
new Flash(portName, storageType)Initialize(portName, storageType)RegisterPort()
- Sahara / Firehose
Sahara<T>(T programmerFile)(string路径或Stream)ConfigureDDR(),ConfigureDDR_Oplus(bool enableVip = true)
- 读写擦除 / Read, write, erase
WriteFile(...),WriteFileAsync(...)Read(...),ReadWithLabel(...)Erase(...),WriteBytes(...)
- OnePlus 相关 / OnePlus related
EnableOnePlusLegacyMode(projId, socSn)RunOnePlusAuth()AutoEnableOnePlusLegacyMode()
using EDLLibrary;
using System;
using System.Threading;
var info = SuperDirectWriter.DetectScatteredPackage(@"C:\rom\rawprogram0.xml");
if (!info.IsScatteredPackage) throw new Exception("Not a scattered package.");
using var flash = new Flash("COM5", "ufs");
flash.RegisterPort();
var writer = new SuperDirectWriter(flash);
info = writer.ParseOffsetsFromOfficialMeta(info); // or: writer.ParseAndCalculateOffsets(info)
if (!info.ValidateAllPartitions(out var errors))
throw new Exception(string.Join(Environment.NewLine, errors));
bool ok = await writer.WriteScatteredToSuper(
info,
lun: 0,
superStartSector: 0,
useOfficialMeta: true,
partitionCallback: (name, size, index, total, status) =>
Console.WriteLine($"{index}/{total} {name} {size} {status}"),
cancellationToken: CancellationToken.None);
if (!ok) throw new Exception(writer.LastError ?? "WriteScatteredToSuper failed.");using EDLLibrary;
using System.Threading;
var reader = new DeviceInfoReader(flash);
var props = await reader.ReadBuildInfoAsync(
superLun: 0,
superStartSector: 0,
ct: CancellationToken.None);
if (props.TryGetValue("ro.build.fingerprint", out var fp))
Console.WriteLine(fp);using EDLLibrary;
int projId = 19821;
if (!OcdtGenerator.IsSupported(projId))
throw new ArgumentException("Unsupported projId");
byte[] ocdt = OcdtGenerator.Generate128KB(projId);
OcdtGenerator.GenerateAndSave(projId, @"C:\out\ocdt.img", 131072);
int extracted = OcdtGenerator.ExtractProjId(ocdt);- 库日志默认写入:
<AppBase>\tool\logs\NeKo-Edl-*.log
Default log path:<AppBase>\tool\logs\NeKo-Edl-*.log - 进度事件:
ProgressManager.ProgressUpdated
Progress event:ProgressManager.ProgressUpdated
- 此库会直接操作设备底层分区,存在数据丢失或设备变砖风险。
This library writes low-level partitions and may cause data loss or device bricking. - 请确保 loader、分区表参数、LUN 与扇区偏移准确。
Ensure loader, partition parameters, LUN, and sector offsets are correct. - 建议先在测试设备验证流程。
Validate your workflow on a test device first.
本项目采用 GNU General Public License v3.0 (GPL-3.0),详见 LICENSE.txt。
This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE.txt for details.

