Write patched boot.img failed - details inside
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Domain
- mobile-dev, operating-systems, security
Research direction
Start with the attached bug report and the kptools output, then inspect tools/patch.c at patch_update_img() and tools/kallsym.c at find_approx_addresses(). Compare the reported kallsyms and relocation data with the MI MIX 2 kernel, and use the patching flow to reproduce the failure. Done means the Android 16 boot image patches successfully and the Superkey can be set.
Written by the indexing model from the issue text.
Description
Please check before submitting an issue | 在提交 Issue 前请检查
- I searched the issues and didn't found anything relevant | 我已经搜索了 Issues 列表,没有发现于本问题相关内容
- If the patch fails or the image cannot be booted after flashing the new boot.img, visit KernelPatch to clarify your doubts | 修复失败或刷入修补后镜像不能启动,请前往 KernelPatch 提问
- I will upload the bug report file in APatch Manager > Settings > Send logs | 我会上传 Bug Report 文件从 APatch 管理器 > 设置 > 发送日志
- I know how to reproduce the issue, which might not be specific to my device | 我知道如何重新复现这个问题
Version requirements | 版本要求
- I'm using the latest CI version of APatch Manager | 我正在使用最新 CI 版本
Bug description | 描述 Bug
Hello,
I have been using Apatch (this time, the latest release) on previous versions of crDroid, up to Android 15, always on a MI MIX 2 device.
But this time, after flashing from scratch a new version of crDroid with Android 16 (the latest one for crDroid for this device), I am getting an error just after I try to set the Superkey:
*As a side note, when I try to click the 'Nightly Release' of Apatch, I get the message 'Artifact 'APatch' not found for run #23749677320.'.
This is the error I am getting trying to set the Superkey (please see the logs beside this text):
APatch Boot Image Patcher
- Backing boot.img
- Patching kernel
- ./kptools -p -i kernel.ori -S mypassword -k kpimg -o kernel
[-] /home/runner/work/KernelPatch/KernelPatch/tools/patch.c:392/patch_update_img(); analyze_kallsym_info error
[+] kernel image_size: 0x02554820
[+] kernel uefi header: false
[+] kernel load_offset: 0x00080000
[+] kernel kernel_size: 0x029e3000
[+] kernel page_shift: 12
[+] new kernel image ...
[+] linux_banner 1: Linux version 4.4.302-cip107-perf-ge3ebf6b3eeeb (build-user@build-host) (Android (14054515, +pgo, +bolt, +lto, +mlgo, based on r563880c) clang version 21.0.0 (https://android.googlesource.com/toolchain/llvm-project 5e96669f06077099aa41290cdb4c5e6fa0f59349)) #1 SMP PREEMPT Wed Mar 11 05:47:54 CET 2026
[+] linux_banner offset: 0x131000f
[+] kernel version major: 4, minor: 4, patch: 255
[+] kallsyms_token_table offset: 0x01821200
[+] endian: little
[+] kallsyms_token_index offset: 0x01821600
[+] arm64 relocation kernel_va: 0xffffff8010000000
[+] arm64 relocation table range: [0x01c6d9f8, 0x023174f8), count: 0x00047120
[?] bad rela offset: 0xffffff8012573e60
[+] kallsyms_markers range: [0x01820100, 0x018211e8), count: 0x0000021c
[-] /home/runner/work/KernelPatch/KernelPatch/tools/kallsym.c:380/find_approx_addresses(); find approximate kallsyms_addresses error
[+] kallsyms_markers range: [0x01820100, 0x018211e8), count: 0x0000021c
[-] /home/runner/work/KernelPatch/KernelPatch/tools/kallsym.c:380/find_approx_addresses(); find approximate kallsyms_addresses error - patch_rc=1
- set +x
- Patch kernel error: 1
Write patched boot.img failed
Thanks in advance !
Reproduce method | 复现方法
APatch_bugreport_2026-04-15_13_49.tar.gz
Expected behavior | 预期行为
I expect Apatch to work XD
Actual behavior | 实际行为
Apatch throws an error when I click on the button to save the superkey...
Screenshots | 截图
No response
Logs | 日志
No response
Device name | 设备名称
MI MIX 2
OS version | 系统版本
Android 16
APatch version | APatch 版本
v11142
Kernel version | 内核版本
https://github.com/crdroidandroid/android_kernel_xiaomi_msm8998
KernelPatch version | KernelPatch 版本
https://github.com/crdroidandroid/android_kernel_xiaomi_msm8998
Other information | 其他信息
- Dominant language
- Kotlin
- Stars
- 8.2k
- Forks
- 809
- Avg merge
- 7d 17h
- Merged PRs (30d)
- 1
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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bmax121/APatch
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 4 days
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
bmax121/APatch#1669 · 2 comments ·
Maintainers usually reply within 4 days
-
Direct Install reports success when boot partition write failsMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 4 days
-
boot_patch.sh: flash guard precedence allows flash attempt on missing new-boot.imgMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 4 days
Similar issues
-
enhancement good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsotto/sotto-authenticator#68 ·
Maintainers usually reply within 1 day
-
mobile prio:low
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
digitalfabrik/entitlementcard#3324 ·
Maintainers usually reply within 2 days
-
Contributions are welcome Type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
owncloud/android#5065 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
sameerasw/essentials#1913 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day