summaryrefslogtreecommitdiffstats
path: root/fastboot
diff options
context:
space:
mode:
authorColin Cross <ccross@android.com>2014-08-16 04:09:41 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-08-16 04:08:14 +0000
commit39ab11d0d46b9be1bb41241ff58e3f6f3259dd74 (patch)
treefb821f5113ad4ceca6f6749eba60b71c6f6e5c38 /fastboot
parent25a7d5f892f2606ed28eff761c59693398497343 (diff)
parentecd28eff0a1389796141caa47a19060ee25c78ae (diff)
downloadsystem_core-39ab11d0d46b9be1bb41241ff58e3f6f3259dd74.zip
system_core-39ab11d0d46b9be1bb41241ff58e3f6f3259dd74.tar.gz
system_core-39ab11d0d46b9be1bb41241ff58e3f6f3259dd74.tar.bz2
Merge "fastboot: add the support of the second stage image"
Diffstat (limited to 'fastboot')
-rw-r--r--fastboot/fastboot.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/fastboot/fastboot.c b/fastboot/fastboot.c
index 266d0b5..ed92ebb 100644
--- a/fastboot/fastboot.c
+++ b/fastboot/fastboot.c
@@ -295,8 +295,9 @@ void usage(void)
" Can override the fs type and/or\n"
" size the bootloader reports.\n"
" getvar <variable> display a bootloader variable\n"
- " boot <kernel> [ <ramdisk> ] download and boot kernel\n"
- " flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it\n"
+ " boot <kernel> [ <ramdisk> [ <second> ] ] download and boot kernel\n"
+ " flash:raw boot <kernel> [ <ramdisk> [ <second> ] ] create bootimage and \n"
+ " flash it\n"
" devices list all connected devices\n"
" continue continue with autoboot\n"
" reboot reboot device normally\n"
@@ -324,10 +325,11 @@ void usage(void)
}
void *load_bootable_image(const char *kernel, const char *ramdisk,
- unsigned *sz, const char *cmdline)
+ const char *secondstage, unsigned *sz,
+ const char *cmdline)
{
- void *kdata = 0, *rdata = 0;
- unsigned ksize = 0, rsize = 0;
+ void *kdata = 0, *rdata = 0, *sdata = 0;
+ unsigned ksize = 0, rsize = 0, ssize = 0;
void *bdata;
unsigned bsize;
@@ -363,10 +365,18 @@ void *load_bootable_image(const char *kernel, const char *ramdisk,
}
}
+ if (secondstage) {
+ sdata = load_file(secondstage, &ssize);
+ if(sdata == 0) {
+ fprintf(stderr,"cannot load '%s': %s\n", secondstage, strerror(errno));
+ return 0;
+ }
+ }
+
fprintf(stderr,"creating boot image...\n");
bdata = mkbootimg(kdata, ksize, kernel_offset,
rdata, rsize, ramdisk_offset,
- 0, 0, second_offset,
+ sdata, ssize, second_offset,
page_size, base_addr, tags_offset, &bsize);
if(bdata == 0) {
fprintf(stderr,"failed to create boot.img\n");
@@ -1144,6 +1154,7 @@ int main(int argc, char **argv)
} else if(!strcmp(*argv, "boot")) {
char *kname = 0;
char *rname = 0;
+ char *sname = 0;
skip(1);
if (argc > 0) {
kname = argv[0];
@@ -1153,7 +1164,11 @@ int main(int argc, char **argv)
rname = argv[0];
skip(1);
}
- data = load_bootable_image(kname, rname, &sz, cmdline);
+ if (argc > 0) {
+ sname = argv[0];
+ skip(1);
+ }
+ data = load_bootable_image(kname, rname, sname, &sz, cmdline);
if (data == 0) return 1;
fb_queue_download("boot.img", data, sz);
fb_queue_command("boot", "booting");
@@ -1177,14 +1192,18 @@ int main(int argc, char **argv)
char *pname = argv[1];
char *kname = argv[2];
char *rname = 0;
+ char *sname = 0;
require(3);
- if(argc > 3) {
- rname = argv[3];
- skip(4);
- } else {
- skip(3);
+ skip(3);
+ if (argc > 0) {
+ rname = argv[0];
+ skip(1);
+ }
+ if (argc > 0) {
+ sname = argv[0];
+ skip(1);
}
- data = load_bootable_image(kname, rname, &sz, cmdline);
+ data = load_bootable_image(kname, rname, sname, &sz, cmdline);
if (data == 0) die("cannot load bootable image");
fb_queue_flash(pname, data, sz);
} else if(!strcmp(*argv, "flashall")) {