fastboot: add the support of the second stage image [DO NOT MERGE]
The AOSP bootimage format allows the use of a second stage image however the fastboot boot and flash:row commands do not allow the "secondstage" optional argument. This patch adds the support of this argument for both commands. Change-Id: I00403a95d7460a00233841ba0fe0e8a69d78c7b4 Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
This commit is contained in:
parent
69d68b69e5
commit
a42adff905
1 changed files with 32 additions and 13 deletions
|
@ -298,8 +298,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"
|
||||
|
@ -327,10 +328,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;
|
||||
|
||||
|
@ -366,10 +368,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");
|
||||
|
@ -1147,6 +1157,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];
|
||||
|
@ -1156,7 +1167,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");
|
||||
|
@ -1180,14 +1195,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);
|
||||
}
|
||||
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) die("cannot load bootable image");
|
||||
fb_queue_flash(pname, data, sz);
|
||||
} else if(!strcmp(*argv, "flashall")) {
|
||||
|
|
Loading…
Reference in a new issue