main: When dumping, store image versions to fiasco image
This commit is contained in:
1 parent
8c624670cc
commit
d5ff815e72
1 file changed
+69
-26
+69
-26
@@ -392,8 +392,15 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
int i;
|
int i;
|
||||||
char buf[512];
|
char buf[512];
|
||||||
|
char * ptr = NULL;
|
||||||
char * tmp = NULL;
|
char * tmp = NULL;
|
||||||
|
|
||||||
|
char nolo_ver[512];
|
||||||
|
char kernel_ver[512];
|
||||||
|
char initfs_ver[512];
|
||||||
|
char sw_ver[512];
|
||||||
|
char content_ver[512];
|
||||||
|
|
||||||
simulate = 0;
|
simulate = 0;
|
||||||
noverify = 0;
|
noverify = 0;
|
||||||
verbose = 0;
|
verbose = 0;
|
||||||
@@ -906,30 +913,25 @@ int main(int argc, char **argv) {
|
|||||||
else
|
else
|
||||||
printf("HW revision: %d\n", dev->detected_hwrev);
|
printf("HW revision: %d\n", dev->detected_hwrev);
|
||||||
|
|
||||||
buf[0] = 0;
|
nolo_ver[0] = 0;
|
||||||
dev_get_nolo_ver(dev, buf, sizeof(buf));
|
dev_get_nolo_ver(dev, nolo_ver, sizeof(nolo_ver));
|
||||||
printf("NOLO version: %s\n", buf[0] ? buf : "(not detected)");
|
printf("NOLO version: %s\n", nolo_ver[0] ? nolo_ver : "(not detected)");
|
||||||
|
|
||||||
buf[0] = 0;
|
kernel_ver[0] = 0;
|
||||||
dev_get_kernel_ver(dev, buf, sizeof(buf));
|
dev_get_kernel_ver(dev, kernel_ver, sizeof(kernel_ver));
|
||||||
printf("Kernel version: %s\n", buf[0] ? buf : "(not detected)");
|
printf("Kernel version: %s\n", kernel_ver[0] ? kernel_ver : "(not detected)");
|
||||||
|
|
||||||
buf[0] = 0;
|
initfs_ver[0] = 0;
|
||||||
dev_get_initfs_ver(dev, buf, sizeof(buf));
|
dev_get_initfs_ver(dev, initfs_ver, sizeof(initfs_ver));
|
||||||
printf("Initfs version: %s\n", buf[0] ? buf : "(not detected)");
|
printf("Initfs version: %s\n", initfs_ver[0] ? initfs_ver : "(not detected)");
|
||||||
|
|
||||||
buf[0] = 0;
|
sw_ver[0] = 0;
|
||||||
dev_get_sw_ver(dev, buf, sizeof(buf));
|
dev_get_sw_ver(dev, sw_ver, sizeof(sw_ver));
|
||||||
printf("Software release version: %s\n", buf[0] ? buf : "(not detected)");
|
printf("Software release version: %s\n", sw_ver[0] ? sw_ver : "(not detected)");
|
||||||
|
|
||||||
if ( buf[0] && dev_flash && ! set_sw && fiasco_in && fiasco_in->swver[0] && strcmp(fiasco_in->swver, buf) != 0 ) {
|
content_ver[0] = 0;
|
||||||
set_sw = 1;
|
dev_get_content_ver(dev, content_ver, sizeof(content_ver));
|
||||||
set_sw_arg = fiasco_in->swver;
|
printf("Content eMMC version: %s\n", content_ver[0] ? content_ver : "(not detected)");
|
||||||
}
|
|
||||||
|
|
||||||
buf[0] = 0;
|
|
||||||
dev_get_content_ver(dev, buf, sizeof(buf));
|
|
||||||
printf("Content eMMC version: %s\n", buf[0] ? buf : "(not detected)");
|
|
||||||
|
|
||||||
ret = dev_get_root_device(dev);
|
ret = dev_get_root_device(dev);
|
||||||
printf("Root device: ");
|
printf("Root device: ");
|
||||||
@@ -1079,6 +1081,11 @@ int main(int argc, char **argv) {
|
|||||||
set_rd_arg = "1";
|
set_rd_arg = "1";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( sw_ver[0] && dev_flash && ! set_sw && fiasco_in && fiasco_in->swver[0] && strcmp(fiasco_in->swver, sw_ver) != 0 ) {
|
||||||
|
set_sw = 1;
|
||||||
|
set_sw_arg = fiasco_in->swver;
|
||||||
|
}
|
||||||
|
|
||||||
if ( set_root )
|
if ( set_root )
|
||||||
ret = dev_set_root_device(dev, atoi(set_root_arg));
|
ret = dev_set_root_device(dev, atoi(set_root_arg));
|
||||||
if ( ret == -EAGAIN )
|
if ( ret == -EAGAIN )
|
||||||
@@ -1174,26 +1181,62 @@ int main(int argc, char **argv) {
|
|||||||
if ( ! image_type_to_string(i) )
|
if ( ! image_type_to_string(i) )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
image_dump = image_alloc_from_file(image_type_to_string(i), image_type_to_string(i), NULL, NULL, NULL, NULL);
|
sprintf(buf, "%hd", dev->detected_hwrev);
|
||||||
if ( ! image_dump ) {
|
|
||||||
ERROR("Cannot load image file %s", image_type_to_string(i));
|
switch ( i ) {
|
||||||
continue;
|
case IMAGE_2ND:
|
||||||
|
case IMAGE_XLOADER:
|
||||||
|
case IMAGE_SECONDARY:
|
||||||
|
ptr = nolo_ver;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_KERNEL:
|
||||||
|
ptr = kernel_ver;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_INITFS:
|
||||||
|
ptr = initfs_ver;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_ROOTFS:
|
||||||
|
ptr = sw_ver;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IMAGE_MMC:
|
||||||
|
ptr = content_ver;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
ptr = NULL;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
image_dump = image_alloc_from_file(image_type_to_string(i), image_type_to_string(i), device_to_string(dev->detected_device), buf, ptr, NULL);
|
||||||
|
|
||||||
|
if ( ! image_dump )
|
||||||
|
continue;
|
||||||
|
|
||||||
image_list_add(&image_dump_first, image_dump);
|
image_list_add(&image_dump_first, image_dump);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
fiasco_out = fiasco_alloc_empty();
|
fiasco_out = fiasco_alloc_empty();
|
||||||
if ( ! fiasco_out ) {
|
if ( ! fiasco_out ) {
|
||||||
ERROR("Cannot write images to fiasco file %s", dev_dump_fiasco_arg);
|
ERROR("Cannot write images to fiasco file %s", dev_dump_fiasco_arg);
|
||||||
} else {
|
} else {
|
||||||
/* TODO: Add swver */
|
strncpy(fiasco_out->swver, sw_ver, sizeof(fiasco_out->swver));
|
||||||
fiasco_out->first = image_first;
|
fiasco_out->swver[sizeof(fiasco_out->swver)-1] = 0;
|
||||||
|
fiasco_out->first = image_dump_first;
|
||||||
fiasco_write_to_file(fiasco_out, dev_dump_fiasco_arg);
|
fiasco_write_to_file(fiasco_out, dev_dump_fiasco_arg);
|
||||||
fiasco_free(fiasco_out); /* this will also free list image_dump_first */
|
fiasco_free(fiasco_out); /* this will also free list image_dump_first */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for ( i = 0; i < IMAGE_COUNT; ++i )
|
||||||
|
if ( image_type_to_string(i) )
|
||||||
|
unlink(image_type_to_string(i));
|
||||||
|
|
||||||
free(tmp);
|
free(tmp);
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
dev_dump_arg = NULL;
|
dev_dump_arg = NULL;
|
||||||
|
|||||||
Reference in new issue
Block a user