How can i modify the boot.img files so that when the power button and volume + is pressed during startup it doesnt start recovery but instead starts fastboot?

P.S I can unpack the boot.img

  • I am not 100% sure but from my understanding those key combinations are checked before boot.img is ever called. Hence these keys are checked by the bootloader which runs before boot.img. Therefore by modifying boot.img you will not be able to change the keys to press or which mode to start. – Robert Sep 15 '20 at 16:16
  • 1
    Key preases during boot are not handled by boot.img (ramdisk and kernel), but by bootloader (ABOOT, ABL or equivalent) which hosts fastboot protocol as well. Bootloader starts main OS (kernel from boot.img) or recovery (kernel from recovery.img) or fastboot, depending on key combination or file/bits in cache / misc partitions. However you can modify recovery.img to make the kernel/init run a program (even a shell script) which reads key combination and restarts device to fastboot. – Irfan Latif Sep 15 '20 at 16:26
  • 1
    I'll again suggest you read my threads or other internet resources on Android partitions and filesystems and boot process so that you don't have to ask very basic questions. – Irfan Latif Sep 15 '20 at 16:33
  • 1
    Rebuild preloader the way you want it. – Irfan Latif Sep 15 '20 at 19:07
  • 1
    You can't actually do this with just modifying boot image. You can do it but it is not that easy. If you have a QCOM, you have to modify aboot. If you have a mtk, follow other's instructions. – Tipz Team Sep 18 '20 at 2:01

The preloader is fetching from hrawork10/hra_huangxj/mt8788_v9.0_G26/P08765_git/vendor/mediatek/proprietary/bootable/bootloader/preloader/platform/mt6771/src/core/main.c as shown in your screenshot which is holding the variable which decides as to whether it should boot factory mode when you hold the power and volume up buttons or not.

Do not try to rebuild your preloader and flash it otherwise you may end up with a nice brick.

  • Irfan Latif is incorrect in that you should rebuild the preloader. – Jitesh Kumar Sep 16 '20 at 9:10
  • Sir you are supposed to answer the question, not my comments. I know that compiling bootloaders and playing with low level things is not an ordinary user does, but if you have a better solution please put it forward so that OP and future visitors can benefit. And btw, if source code is available and binary isn't signed with OEM's private keys, why one should not build the preloader? What's the restricting factor? Instead of giving advice or opinion, better back your answers with technical reasons (not just the expected risks). I'd love to learn from you. Thanks. – Irfan Latif Sep 16 '20 at 10:21
  • Given that he has a Mediatek device , where the preloader binary is closed source, its not possible for him to change the factory boot settings so that it starts recovery mode, from the preloader. Also as shown in his screenshot, the preloader is building the code from src/core/main.c, thus to change the factory boot settings that is where the changes should be made. – Jitesh Kumar Sep 16 '20 at 10:45
  • When I say "Rebuild preloader the way you want it." but the source code is not available (as is the case with mostly bootloaders for Android devices), it's obvious that OP is asking for something impossible, or at least something that he/she cannot handle technically. So it doesn't need a warning "Do not try to rebuild your preloader". // I still wonder how your answer addresses the question. This is a Q&A site where you answer the question to partially or completely solve OP's problem. But as I said, you answered my comment, not OP's question. You may edit it to make helpful for OP. – Irfan Latif Sep 16 '20 at 12:00
  • i think the point is, there is no known method to unbrick from corrupt preloader - playing with preloader is not worth the risk – alecxs Dec 16 '20 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.