diff options
author | Pat Tjin <pattjin@google.com> | 2015-09-01 21:01:40 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-01 21:01:40 +0000 |
commit | 7af4865215320e6b58a33fec776b7ae4f1717f86 (patch) | |
tree | 7710d77665a1140c8ef5ae77435e4ce096845234 /fastboot/fastboot.cpp | |
parent | a4b2312387aa7143e8bedb3c3d45ff2bb8033dc3 (diff) | |
parent | 6442153cbc673ee2f3799ed56eb4965f09ae40b8 (diff) |
am 6442153c: Merge "fastboot: add flashing bootloader commands" into mnc-dr-dev
* commit '6442153cbc673ee2f3799ed56eb4965f09ae40b8':
fastboot: add flashing bootloader commands
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r-- | fastboot/fastboot.cpp | 56 |
1 files changed, 44 insertions, 12 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp index be80cced4..de4c0ea41 100644 --- a/fastboot/fastboot.cpp +++ b/fastboot/fastboot.cpp @@ -279,17 +279,22 @@ void usage(void) " flashall flash boot, system, vendor and if found,\n" " recovery\n" " flash <partition> [ <filename> ] write a file to a flash partition\n" - " flashing lock locks the device. Prevents flashing" + " flashing lock locks the device. Prevents flashing\n" " partitions\n" - " flashing unlock unlocks the device. Allows user to" - " flash any partition except the ones" + " flashing unlock unlocks the device. Allows user to\n" + " flash any partition except the ones\n" " that are related to bootloader\n" - " flashing lock_critical Prevents flashing bootloader related" + " flashing lock_critical Prevents flashing bootloader related\n" " partitions\n" - " flashing unlock_critical Enables flashing bootloader related" + " flashing unlock_critical Enables flashing bootloader related\n" " partitions\n" - " flashing get_unlock_ability Queries bootloader to see if the" + " flashing get_unlock_ability Queries bootloader to see if the\n" " device is unlocked\n" + " flashing get_unlock_bootloader_nonce Queries the bootloader to get the\n" + " unlock nonce\n" + " flashing unlock_bootloader <request> Issue unlock bootloader using request\n" + " flashing lock_bootloader Locks the bootloader to prevent\n" + " bootloader version rollback\n" " erase <partition> erase a flash partition\n" " format[:[<fs type>][:[<size>]] <partition> format a flash partition.\n" " Can override the fs type and/or\n" @@ -831,6 +836,27 @@ void do_flashall(usb_handle *usb, int erase_first) #define skip(n) do { argc -= (n); argv += (n); } while (0) #define require(n) do { if (argc < (n)) {usage(); exit(1);}} while (0) +int do_bypass_unlock_command(int argc, char **argv) +{ + unsigned sz; + void *data; + + if (argc <= 2) return 0; + skip(2); + + /* + * Process unlock_bootloader, we have to load the message file + * and send that to the remote device. + */ + require(1); + data = load_file(*argv, &sz); + if (data == 0) die("could not load '%s': %s", *argv, strerror(errno)); + fb_queue_download("unlock_message", data, sz); + fb_queue_command("flashing unlock_bootloader", "unlocking bootloader"); + skip(1); + return 0; +} + int do_oem_command(int argc, char **argv) { char command[256]; @@ -1230,12 +1256,18 @@ int main(int argc, char **argv) wants_reboot = 1; } else if(!strcmp(*argv, "oem")) { argc = do_oem_command(argc, argv); - } else if(!strcmp(*argv, "flashing") && argc == 2) { - if(!strcmp(*(argv+1), "unlock") || !strcmp(*(argv+1), "lock") - || !strcmp(*(argv+1), "unlock_critical") - || !strcmp(*(argv+1), "lock_critical") - || !strcmp(*(argv+1), "get_unlock_ability")) { - argc = do_oem_command(argc, argv); + } else if(!strcmp(*argv, "flashing")) { + if (argc == 2 && (!strcmp(*(argv+1), "unlock") || + !strcmp(*(argv+1), "lock") || + !strcmp(*(argv+1), "unlock_critical") || + !strcmp(*(argv+1), "lock_critical") || + !strcmp(*(argv+1), "get_unlock_ability") || + !strcmp(*(argv+1), "get_unlock_bootloader_nonce") || + !strcmp(*(argv+1), "lock_bootloader"))) { + argc = do_oem_command(argc, argv); + } else + if (argc == 3 && !strcmp(*(argv+1), "unlock_bootloader")) { + argc = do_bypass_unlock_command(argc, argv); } else { usage(); return 1; |