Recompiling fastboot to integrate reboot-edl command


The fastboot command line is an android tool that allows to interact with an android device when in fastboot mode. I needed to switch from "fastboot mode" toward "EDL mode" (EDL stands for "Emergency Download").

If this is usually done with the command fastboot oem edl, but on the Xiaomi RedMi note 3 Pro, for some reasons, it uses a specific non-standard root command reboot-edl. This is a new occasion for showing why open-source matters, and to recompile fastboot and add the missing command.


The following is for debian related systems. In a previous blog post I explained in detail each command for a similar hack in empathy source code.

This time, I'll give the full transcript without much explanation:

mkdir /tmp/fastboot &&
cd /tmp/fastboot &&
apt-get source android-tools-fastboot </dev/null &&
cd android-tools-*
cat <<EOF | patch -p1 &&
--- a/core/fastboot/fastboot.c
+++ b/core/fastboot/fastboot.c
@@ -284,6 +284,7 @@ void usage(void)
             "  continue                                 continue with autoboot\n"
             "  reboot                                   reboot device normally\n"
             "  reboot-bootloader                        reboot device into bootloader\n"
+            "  reboot-edl                               reboot device into EDL (RedMi Note 3 Pro)\n"
             "  help                                     show this help message\n"
@@ -803,6 +804,7 @@ int main(int argc, char **argv)
     int wants_wipe = 0;
     int wants_reboot = 0;
     int wants_reboot_bootloader = 0;
+    int wants_reboot_edl = 0;
     int erase_first = 1;
     void *data;
     unsigned sz;
@@ -929,6 +931,9 @@ int main(int argc, char **argv)
         } else if(!strcmp(*argv, "reboot-bootloader")) {
             wants_reboot_bootloader = 1;
+        } else if(!strcmp(*argv, "reboot-edl")) {
+            wants_reboot_edl = 1;
+            skip(1);
         } else if (!strcmp(*argv, "continue")) {
             fb_queue_command("continue", "resuming boot");
@@ -1009,6 +1014,8 @@ int main(int argc, char **argv)
     } else if (wants_reboot_bootloader) {
         fb_queue_command("reboot-bootloader", "rebooting into bootloader");
+    } else if (wants_reboot_edl) {
+        fb_queue_command("reboot-edl", "rebooting into EDL mode");

     if (fb_queue_is_empty())

apt-get build-dep android-tools-fastboot -y </dev/null &&  ## prefix with `sudo` if needed
dpkg-buildpackage -rfakeroot -b </dev/null &&
cd .. &&
dpkg -i android-tools-fastboot*.deb  ## prefix with `sudo` if needed

You should now have a new fastboot command with the reboot-edl command.

Once your Redmi Note 3 Pro is in fastboot mode (power it up with Power and Volume-Down button pressed), you are ready to fire:

# fastboot reboot-edl
rebooting into EDL mode...
OKAY [  0.001s]
finished. total time: 0.001s

Checking that your device is now in EDL mode could be done with:

# lsusb | grep Qualcomm
Bus 001 Device 086: ID 05c6:9008 Qualcomm, Inc. Gobi Wireless Modem (QDL mode)

Happy hacking !

More info