summaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorKhalid Zubair <kzubair@cyngn.com>2016-02-18 14:56:12 -0800
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-02-20 09:40:48 -0800
commit1724115cc329e59331185a4c723f68b874b2d6b9 (patch)
treeb48b4c4fa5c45ddd0ad82db90f29922e44661acc /fastboot
parent515ea005fd1860a04ee37973aba352d3f3ee6954 (diff)
downloadsystem_core-1724115cc329e59331185a4c723f68b874b2d6b9.zip
system_core-1724115cc329e59331185a4c723f68b874b2d6b9.tar.gz
system_core-1724115cc329e59331185a4c723f68b874b2d6b9.tar.bz2
fastboot: add 'fastboot update -a' argument
Add an argument to accept an alternate filepath for the boot image when using fastboot update. This lets the user skip the steps of unzipping a release update.zip and manually flashing system, recovery partitions etc from the zip file and their debuggable boot image separately. Example usage: fastboot update -a boot-debuggable.img update.zip Change-Id: Ic15e1aa271e19b7a61cb783c4ecf94fa4230507f
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/fastboot.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/fastboot/fastboot.cpp b/fastboot/fastboot.cpp
index c7d8c90..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"
@@ -330,6 +330,8 @@ void usage(void)
" -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"
);
}
@@ -741,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();
@@ -764,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);
}
@@ -1018,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'},
@@ -1035,12 +1048,15 @@ int main(int argc, char **argv)
serial = getenv("ANDROID_SERIAL");
while (1) {
- c = getopt_long(argc, argv, "wub:k:n:r:t:s:S:lp:c:i:m:hR", 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;
@@ -1256,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;