Esempio n. 1
0
int menu_show(int bootdelay)
{
	int ret;

	run_command2("run saveparms", 0);
	ret = ait_menu_show(&ait_main, bootdelay);
	run_command2("run restoreparms", 0);

	if (ret == MENU_EXIT_BOOTCMD)
		return 0;

	return MENU_EXIT;
}
Esempio n. 2
0
static int ait_menu_evaluate_update(char *choice)
{
	int ret;

	if (!choice)
		return MENU_MAIN;

	switch (choice[1]) {
	case '1':
		return ait_menu_show(&ait_network, 0);
		break;
	case '2':
		/* load image */
		ret = run_command2("run load_img", 0);
		printf("ret: %d\n", ret);
		if (ret)
			return MENU_UPDATE;

		ret = ait_menu_check_image();
		if (ret)
			return MENU_UPDATE;

		return ait_menu_show(&ait_load, 0);
		break;
	case '3':
		return MENU_MAIN;
		break;

	}

	return MENU_MAIN;
}
Esempio n. 3
0
int run_command(const std::vector<std::string> &argv)
{
    if (argv.empty()) {
        errno = EINVAL;
        return -1;
    }

    return run_command2(argv[0], argv, std::string(), nullptr, nullptr);
}
Esempio n. 4
0
int run_command_cb(const std::vector<std::string> &argv,
                   OutputCb cb, void *data)
{
    if (argv.empty()) {
        errno = EINVAL;
        return -1;
    }

    return run_command2(argv[0], argv, std::string(), cb, data);
}
Esempio n. 5
0
static int ait_writeublheader(void)
{
	char s[20];
	unsigned long i;
	int ret;

	for (i = CONFIG_SYS_NAND_BLOCK_SIZE;
		i < CONFIG_SYS_NAND_U_BOOT_OFFS;
		i += CONFIG_SYS_NAND_BLOCK_SIZE) {
		sprintf(s, "%lx", i);
		ret = setenv("header_addr", s);
		if (ret == 0)
			ret = run_command2("run img_writeheader", 0);
		if (ret != 0)
			break;
	}
	return ret;
}
Esempio n. 6
0
static int ait_menu_install_images(void)
{
	int ret = 0;
	int count = 0;
	char s[100];
	char *t;

	/*
	 * possible image types:
	 * FIT_SUBTYPE_UNKNOWN
	 * FIT_SUBTYPE_UBL_HEADER
	 * FIT_SUBTYPE_SPL_IMAGE
	 * FIT_SUBTYPE_UBOOT_IMAGE
	 * FIT_SUBTYPE_DF_ENV_IMAGE
	 * FIT_SUBTYPE_RAMDISK_IMAGE
	 *
	 * use Envvariables:
	 * img_addr_r: image start addr
	 * header_addr: addr where to write to UBL header
	 * img_writeheader: write ubl header to nand
	 * img_writespl: write spl to nand
	 * img_writeuboot: write uboot to nand
	 * img_writedfenv: write default environment to ubi volume
	 * img_volume: which ubi volume should be updated with img_writeramdisk
	 * filesize: size of data for updating ubi volume
	 * img_writeramdisk: write ramdisk to ubi volume
	 */

	while (images[count].type != IH_TYPE_INVALID) {
		printf("Installing %s\n",
			genimg_get_type_name(images[count].type));
		sprintf(s, "%p", images[count].data);
		setenv("img_addr_r", s);
		sprintf(s, "%lx", (unsigned long)images[count].size);
		setenv("filesize", s);
		switch (images[count].subtype) {
		case FIT_SUBTYPE_DF_ENV_IMAGE:
			ret = run_command2("run img_writedfenv", 0);
			break;
		case FIT_SUBTYPE_RAMDISK_IMAGE:
			t = getenv("img_volume");
			if (!t) {
				ret = setenv("img_volume", "rootfs1");
			} else {
				/* switch to other volume */
				if (strncmp(t, "rootfs1", 7) == 0)
					ret = setenv("img_volume", "rootfs2");
				else
					ret = setenv("img_volume", "rootfs1");
			}
			if (ret != 0)
				break;

			ret = run_command2("run img_writeramdisk", 0);
			break;
		case FIT_SUBTYPE_SPL_IMAGE:
			ret = run_command2("run img_writespl", 0);
			break;
		case FIT_SUBTYPE_UBL_HEADER:
			ret = ait_writeublheader();
			break;
		case FIT_SUBTYPE_UBOOT_IMAGE:
			ret = run_command2("run img_writeuboot", 0);
			break;
		default:
			/* not supported type */
			break;
		}
		count++;
	}
	/* now save dvn_* and img_volume env vars to new values */
	if (ret == 0)
		ret = run_command2("run savenewvers", 0);

	return ret;
}