aboutsummaryrefslogtreecommitdiffstats
path: root/fastboot/fastboot.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'fastboot/fastboot.cpp')
-rw-r--r--fastboot/fastboot.cpp51
1 files changed, 36 insertions, 15 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index ec3b84a..5112c15 100644
--- a/fastboot/fastboot.cpp
+++ b/fastboot/fastboot.cpp
@@ -279,7 +279,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"
@@ -329,6 +329,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"
);
}
@@ -740,7 +743,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();
@@ -763,18 +766,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);
}
@@ -1017,8 +1029,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'},
@@ -1027,18 +1041,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;
@@ -1074,6 +1092,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;
@@ -1251,10 +1272,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;