summaryrefslogtreecommitdiffstats
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp60
1 files changed, 44 insertions, 16 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index de4c0ea..91152a4 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -203,7 +203,14 @@ int match_fastboot_with_serial(usb_ifc_info *info, const char *local_serial)
(info->dev_vendor != 0x413c) && // DELL
(info->dev_vendor != 0x2314) && // INQ Mobile
(info->dev_vendor != 0x0b05) && // Asus
- (info->dev_vendor != 0x0bb4)) // HTC
+ (info->dev_vendor != 0x0bb4) && // HTC
+ (info->dev_vendor != 0x0421) && // Nokia
+ (info->dev_vendor != 0x1ebf) && // Coolpad
+ (info->dev_vendor != 0x2b4c) && // Zuk
+ (info->dev_vendor != 0x2a96) && // MMX
+ (info->dev_vendor != 0x19d2) && // ZTE
+ (info->dev_vendor != 0x2c3f) && // Nextbit
+ (info->dev_vendor != 0x1bbb)) // Alcatel
return -1;
if(info->ifc_class != 0xff) return -1;
if(info->ifc_subclass != 0x42) return -1;
@@ -275,7 +282,7 @@ void usage(void)
"usage: fastboot [ <option> ] <command>\n"
"\n"
"commands:\n"
- " update <filename> reflash device from update.zip\n"
+ " update <filename> [ -a <boot.img> ] reflash device from update.zip\n"
" flashall flash boot, system, vendor and if found,\n"
" recovery\n"
" flash <partition> [ <filename> ] write a file to a flash partition\n"
@@ -325,6 +332,9 @@ void usage(void)
" default: 2048\n"
" -S <size>[K|M|G] automatically sparse files greater\n"
" than size. 0 to disable\n"
+ " -R reboot device (e.g. after flash)\n"
+ " -a <boot.img> use alternate <boot.img> instead of\n"
+ " boot.img in update.zip file\n"
);
}
@@ -736,7 +746,7 @@ void do_update_signature(ZipArchiveHandle zip, char *fn)
fb_queue_command("signature", "installing signature");
}
-void do_update(usb_handle *usb, const char *filename, int erase_first)
+void do_update(usb_handle *usb, const char *filename, int erase_first, const char *alt_boot_fname)
{
queue_info_dump();
@@ -759,18 +769,27 @@ void do_update(usb_handle *usb, const char *filename, int erase_first)
setup_requirements(reinterpret_cast<char*>(data), sz);
for (size_t i = 0; i < ARRAY_SIZE(images); ++i) {
- int fd = unzip_to_file(zip, images[i].img_name);
- if (fd == -1) {
- if (images[i].is_optional) {
- continue;
+ fastboot_buffer buf;
+ // support alt images only for boot partition
+ bool from_zip = alt_boot_fname == NULL ||
+ strncmp(images[i].part_name, "boot", sizeof(images[i].part_name));
+ if (from_zip) {
+ int fd = unzip_to_file(zip, images[i].img_name);
+ if (fd == -1) {
+ if (images[i].is_optional) {
+ continue;
+ }
+ CloseArchive(zip);
+ exit(1); // unzip_to_file already explained why.
}
- CloseArchive(zip);
- exit(1); // unzip_to_file already explained why.
+ int rc = load_buf_fd(usb, fd, &buf);
+ if (rc) die("cannot load %s from flash", images[i].img_name);
+ do_update_signature(zip, images[i].sig_name);
+ } else {
+ int rc = load_buf(usb, alt_boot_fname, &buf);
+ if (rc) die("cannot load %s", alt_boot_fname);
}
- fastboot_buffer buf;
- int rc = load_buf_fd(usb, fd, &buf);
- if (rc) die("cannot load %s from flash", images[i].img_name);
- do_update_signature(zip, images[i].sig_name);
+
if (erase_first && needs_erase(usb, images[i].part_name)) {
fb_queue_erase(images[i].part_name);
}
@@ -1013,8 +1032,10 @@ int main(int argc, char **argv)
int status;
int c;
int longindex;
+ const char *alt_boot_fname = NULL;
const struct option longopts[] = {
+ {"alt-boot", required_argument, 0, 'a'},
{"base", required_argument, 0, 'b'},
{"kernel_offset", required_argument, 0, 'k'},
{"page_size", required_argument, 0, 'n'},
@@ -1023,18 +1044,22 @@ int main(int argc, char **argv)
{"help", no_argument, 0, 'h'},
{"unbuffered", no_argument, 0, 0},
{"version", no_argument, 0, 0},
+ {"reboot", no_argument, 0, 'R'},
{0, 0, 0, 0}
};
serial = getenv("ANDROID_SERIAL");
while (1) {
- c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:h", longopts, &longindex);
+ c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:hRa:", longopts, &longindex);
if (c < 0) {
break;
}
/* Alphabetical cases */
switch (c) {
+ case 'a':
+ alt_boot_fname = optarg;
+ break;
case 'b':
base_addr = strtoul(optarg, 0, 16);
break;
@@ -1070,6 +1095,9 @@ int main(int argc, char **argv)
case 'r':
ramdisk_offset = strtoul(optarg, 0, 16);
break;
+ case 'R':
+ wants_reboot = 1;
+ break;
case 't':
tags_offset = strtoul(optarg, 0, 16);
break;
@@ -1247,10 +1275,10 @@ int main(int argc, char **argv)
wants_reboot = 1;
} else if(!strcmp(*argv, "update")) {
if (argc > 1) {
- do_update(usb, argv[1], erase_first);
+ do_update(usb, argv[1], erase_first, alt_boot_fname);
skip(2);
} else {
- do_update(usb, "update.zip", erase_first);
+ do_update(usb, "update.zip", erase_first, alt_boot_fname);
skip(1);
}
wants_reboot = 1;