ABL2ESP 测试

本文最后更新于 2025年8月19日 下午

本文章仅限unfuse高通设备,如果你不知道unfuse是是什么意思,
或者你的设备是fused,请勿轻易尝试。

ABL2ESP 测试

项目地址:https://github.com/qualcomm/abl2esp

编译

  • 环境: Linux
  • 工具:rustup/cargo
  1. 安装工具链
    国内安装工具链的时候推荐配置镜像源

    1
    2
    3
    4
    5
    # USTC Mirror
    export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
    export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
    # Install ARM64 Toolchain
    rustup target add aarch64-unknown-uefi
  2. 拉代码

    1
    2
    git clone https://github.com/qualcomm/abl2esp --depth=1
    cd abl2esp
  3. 构建

    1
    cargo build --target aarch64-unknown-uefi

    build finished

  4. 打包
    参考README中的代码

    1
    2
    3
    4
    5
    6
    7
    8
    # 初始化EDK2环境
    git clone https://github.com/tianocore/edk2.git --depth=1
    cd edk2
    git submodule update --init --depth=1
    make -C BaseTools
    . edksetup.sh
    # 打包
    ./package.sh

    构建完成之后,可以看到目录下生成了abl-unsigned.elf文件。

  5. 签名

    github有个开源的sectools平替来着,参考项目qtestsign

    使用sectools签名abl-unsigned.elf

    1
    2
    # sectools v1
    python2.7 sectools.py secimage -p rennell -i abl-unsigned.elf -g abl -sa
    1
    2
    # sectools v2
    ./ext/Linux/sectools secure-image --sign --security-profile security_profile.xml --outfile abl-signed.elf --signing-mode TEST abl-unsigned.elf --image-id ABL

测试

上面已经签名完成了,现在使用fastboot/edl刷写abl2esp到abl分区,并且确保已经在开发板的任意FAT分区存放bootaa64.efi

1
fastboot flash abl abl-signed.elf

刷写完成后,重启进行测试,日志如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
UEFI Ver           : BOOT.MXF.2.0-WAIPIO-1
Platform : HDK
Subtype : 0
Boot Device : UFS
Chip Name : SMP_WAIPIO
Chip Ver : 2.2
-----------------------------
UEFI Total : 568 ms
POST Time [ 2738] OS Loader
[ INFO]: src/main.rs@121: Found bootaa64.efi, starting..
error: no such device: /.disk/info.
error: no video mode activated.
GNU GRUB version 2.02+dfsg1-20

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? Use the and keys to select which entry is highlighted.
Press enter to boot the selected OS, `e' to edit the commands
before booting or `c' for a command-line. ESC to return previous
menu. *Linux Entry

我才用的是HDK,我这没屏幕,所以只能看看日志了,看起来已经正常加载GRUB了,但是由于按键映射问题,PWR等按键没有被映射到回车和上下,所以无法正常切换启动项,只能等待倒计时完成之后自动启动。

使用abl2esp启动LinuxLoader.efi?

LinuxLoader.efi是默认abl中的efi application,现在尝试使用abl2esp加载存放在esp分区里面的LinuxLoader.efi,应该会很有意思。
从原机的abl.elf中解包LinuxLoader.efi,尝试用Grub chainload Linuxloader。

1
2
3
menuentry "LinuxLoader" {
chainloader /LinuxLoader.efi
}

重启系统,测试:
LinuxLoader Loaded

测试一下getvar命令,看起来没啥问题,应该是可以用了。

1
2
3
4
5
6
7
8
9
10
11
12
13
❯ fastboot getvar all
(bootloader) parallel-download-flash:yes
(bootloader) hw-revision:20002
(bootloader) unlocked:yes
(bootloader) off-mode-charge:0
(bootloader) charger-screen-enabled:0
(bootloader) battery-soc-ok:yes
(bootloader) battery-voltage:4309
(bootloader) version-baseband:
(bootloader) version-bootloader:
(bootloader) erase-block-size: 0x1000
(bootloader) logical-block-size: 0x1000
...

编译GRUB

为了兼容电源按键到回车的映射,需要修改代码,并重新编译grub,或者注册一个服务拦截原来的输入发布新的输入,这里选择简单的修改GRUB。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
index 258b52737..340435661 100644
--- a/grub-core/term/efi/console.c
+++ b/grub-core/term/efi/console.c
@@ -219,6 +219,9 @@ grub_efi_translate_key (grub_efi_input_key_t key)
else
return key.unicode_char;
}
+ /* Treat UEFI SCAN_SUSPEND (0x0102) as Enter (\r). */
+ else if (key.scan_code == 0x0102)
+ return '\r';
/* Some devices send enter with scan_code 0x0d (F3) and unicode_char 0x0d. */
else if (key.scan_code == '\r' && key.unicode_char == '\r')
return key.unicode_char;

经过测试后,可以正常使用按键了。

附录

测试了一下启动Linux,能正常启动,不过不能启动Windows bootmgr,会直接gg。
Booting Linux

用QRD720测试了一下,图形界面是正常的
QRD720 GRUB

之后去测试了一下高通最近又开源的一个fastboot.efi项目,丢grub里面一起测试一下,参考下一篇文章


ABL2ESP 测试
https://kancy.life/2025/08/16/ABL2ESP/
作者
Kancy Joe
发布于
2025年8月16日
许可协议