Пример #1
0
void OdroidFlashManager::writeBootFromFile(QString boot_ini_path, QString drive_path) // TODO: defer to diskimager
{
   // load boot_file
   QFile  boot_ini(boot_ini_path);
   boot_ini.open(QIODevice::ReadOnly);
   QByteArray   boot_settings(boot_ini.readAll());
   mDiskManager->overwriteBootFile(boot_settings,drive_path);
}
Пример #2
0
int do_booti(struct bootloader_ops *boot_ops, char *info, void *download_addr)
{
	boot_img_hdr *hdr;
	u32 addr;
	u64 sector1, sector2;
	char *ptn = "boot";
	int boot_from_mmc = 0;
	u64 num_sectors = 0;
	int sector_sz = 0;
	int ret = 0;
	unsigned dbt_addr = CONFIG_ADDR_ATAGS;
	unsigned cfg_machine_type = CONFIG_BOARD_MACH_TYPE;
	void (*theKernel)(int zero, int arch, void *);

	if (!(strcmp(info, "storage")))
		boot_from_mmc = 1;

	if (download_addr != NULL)
		addr = (u32) download_addr;
	else
		addr = CONFIG_ADDR_DOWNLOAD;

	hdr = (boot_img_hdr *) addr;

	if (boot_from_mmc) {

		struct fastboot_ptentry *pte;

		ret = load_ptbl(boot_ops->storage_ops, 0);
		if (ret != 0)
			goto fail;

		dbt_addr = load_dev_tree(boot_ops, dbt_addr);
		if (dbt_addr < 0)
			goto fail;

		pte = fastboot_flash_find_ptn(ptn);
		if (!pte) {
			printf("booti: cannot find '%s' partition\n", ptn);
			goto fail;
		}

		sector_sz = boot_ops->storage_ops->get_sector_size();
		num_sectors =  sizeof(boot_img_hdr) / sector_sz;
		ret = boot_ops->storage_ops->read(pte->start, num_sectors,
							(void *) hdr);
		if (ret != 0) {
			printf("booti: failed to read bootimg header\n");
			goto fail;
		} else
			bootimg_print_image_hdr(hdr);

		ret = memcmp(hdr->magic, BOOT_MAGIC, 8);
		if (ret != 0) {
			printf("booti: bad boot image magic\n");
			goto fail;
		}

		sector1 = pte->start + (hdr->page_size / sector_sz);

		sector2 = sector1 +
			ALIGN(hdr->kernel_size, hdr->page_size) / sector_sz;

		num_sectors = CEIL(hdr->kernel_size, sector_sz);
		if (num_sectors <= (hdr->kernel_size / sector_sz))
			num_sectors = (hdr->kernel_size / sector_sz);

		DBG("Reading kernel from start sector %d and reading %d "
			"number of sectors\n", (int)sector1, (int)num_sectors);

		ret = boot_ops->storage_ops->read(sector1, num_sectors,
					(void *) hdr->kernel_addr);
		if (ret != 0) {
			printf("mmc read failed\n");
			goto fail;
		}

		DBG("Done reading kernel from mmc\n");

		num_sectors = CEIL(hdr->ramdisk_size, sector_sz);
		if (num_sectors <= (hdr->ramdisk_size / sector_sz))
			num_sectors = (hdr->ramdisk_size / sector_sz);

		DBG("Reading ramdisk from start sector %d and reading %d "
			"number of sectors\n", (int)sector2, (int)num_sectors);

		ret = boot_ops->storage_ops->read(sector2, num_sectors,
					(void *) hdr->ramdisk_addr);
		if (ret != 0) {
			printf("mmc read failed\n");
			goto fail;
		}

		DBG("Done reading ramdisk from mmc\n");

	} else {
		u32 kaddr, raddr;

		DBG("user wants to boot an image downloaded using "
							"fastboot\n");

		ret = memcmp(hdr->magic, BOOT_MAGIC, 8);
		if (ret != 0) {
			printf("booti: bad boot image magic\n");
			goto fail;
		}

		bootimg_print_image_hdr(hdr);

		kaddr = addr + hdr->page_size;

		raddr = kaddr + ALIGN(hdr->kernel_size, hdr->page_size);

		memmove((void *) hdr->kernel_addr, (void *)kaddr,
							hdr->kernel_size);
		memmove((void *) hdr->ramdisk_addr, (void *)raddr,
							hdr->ramdisk_size);
	}

	printf("kernel   @ %08x (%d)\n", hdr->kernel_addr, hdr->kernel_size);
	printf("ramdisk  @ %08x (%d)\n", hdr->ramdisk_addr, hdr->ramdisk_size);

#if defined CONFIG_OMAP4_ANDROID_CMD_LINE || \
	defined CONFIG_OMAP5_ANDROID_CMD_LINE
	boot_settings(boot_ops, &hdr[0], CONFIG_ADDR_ATAGS);
#endif

#if defined START_HYPERVISOR_MODE && defined CONFIG_IS_OMAP5
	if (!(strcmp(boot_ops->proc_ops->proc_get_type(), "GP"))) {
		printf("Starting ARM Hyp mode\n");
		start_hyp_mode(MONITOR_API_START_HYPERVISOR);
	}
#endif

	theKernel = (void (*)(int, int, void *))(hdr->kernel_addr);

	printf("booting kernel...\n");
	theKernel(0, cfg_machine_type, (void *)dbt_addr);

fail:
	ret = boot_ops->usb_ops->usb_open(boot_ops->usb_ops->usb, INIT_USB,
							boot_ops->proc_ops);
	if (ret != 0) {
		printf("\nusb_open failed\n");
		return ret;
	}
	do_fastboot(boot_ops);
	return 0;
}