Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // nkk71: check for kexec support, otherwise use workaround
- if (!multirom_has_kexec())
- {
- //==========================================================================================================================
- // nkk71: workaround for lack of kexec-hb support:
- // flash correct kernel to primary slot,
- // initiate a reboot, and autoboot the ROM
- if (s.is_second_boot == 0)
- {
- char path_bootimg[500];
- char path_boot_mmcblk[500];
- // find kernel mmcblk
- sprintf(path_boot_mmcblk, "/dev/block/platform/msm_sdcc.1/by-name/boot");
- ERROR("nkk71: boot mmcblk=%s\n",path_boot_mmcblk);
- // primary boot.img
- sprintf(path_bootimg, "%s/primary_boot.img", s.roms[0]->base_path);
- ERROR("nkk71: primary_boot.img=%s\n",path_bootimg);
- if (to_boot->type != ROM_DEFAULT)
- {
- FILE *fp1, *fp2;
- // check if primary rom boot.img is backed up
- if (fp1 = fopen(path_bootimg, "r"))
- {
- // it's there, compare them maybe it's a new primary boot.img
- int ch1, ch2;
- fp2 = fopen(path_boot_mmcblk, "r");
- ch1 = getc(fp1);
- ch2 = getc(fp2);
- while ((ch1 != EOF) && (ch2 != EOF) && (ch1 == ch2))
- {
- ch1 = getc(fp1);
- ch2 = getc(fp2);
- }
- fclose(fp1);
- fclose(fp2);
- if (ch1 != ch2)
- {
- // looks like a new primary boot.img, so back it up (replacing the old one)
- ERROR("nkk71: backing up NEW primary boot.img; res=%d\n", copy_file(path_boot_mmcblk, path_bootimg));
- }
- }
- else
- {
- // it's not there, so backup primary boot.img
- ERROR("nkk71: backing up primary boot.img; res=%d\n", copy_file(path_boot_mmcblk, path_bootimg));
- }
- // now flash the secondary boot.img to primary slot
- sprintf(path_bootimg, "%s/boot.img", to_boot->base_path);
- ERROR("nkk71: copy boot.img to primary slot; res=%d\n", copy_file(path_bootimg, path_boot_mmcblk));
- }
- else
- {
- // restore primay boot.img
- ERROR("nkk71: restore primary boot.img; res=%d\n", copy_file(path_bootimg, path_boot_mmcblk));
- }
- }
- // nkk71: end of workaround (boot.img flashing), later below, we'll set second_boot true, and ask for a full reboot
- //==========================================================================================================================
- }
- exit = multirom_prepare_for_boot(&s, to_boot);
- // Something went wrong, exit/reboot
- if(exit == -1)
- {
- if(rom_to_boot == NULL)
- {
- multirom_emergency_reboot();
- exit = EXIT_REBOOT;
- }
- else
- exit = EXIT_UMOUNT;
- goto finish;
- }
- s.current_rom = to_boot;
- free(s.curr_rom_part);
- s.curr_rom_part = NULL;
- if(to_boot->partition)
- s.curr_rom_part = strdup(to_boot->partition->uuid);
- if(s.is_second_boot == 0 && (M(to_boot->type) & MASK_ANDROID) && (exit & EXIT_KEXEC))
- {
- s.is_second_boot = 1;
- // mrom_kexecd=1 param might be lost if kernel does not have kexec patches
- ERROR(SECOND_BOOT_KMESG);
- }
- else
- // nkk71: check for kexec support, otherwise use workaround
- if (!multirom_has_kexec())
- {
- if (s.is_second_boot == 0 && ((M(to_boot->type) & MASK_ANDROID) || (to_boot->type == ROM_DEFAULT)))
- {
- // nkk71: force a full reboot (due to kernel flashing from above), then autoboot the ROM
- s.is_second_boot = 1;
- exit = (EXIT_REBOOT | EXIT_UMOUNT);
- ERROR("nkk71: go for reboot second_boot!\n");
- ERROR(SECOND_BOOT_KMESG); // go for second_boot = 1
- }
- }
- else
- s.is_second_boot = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment