Example #1
0
int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret = 1;
	unsigned long val;
	/* Initialize the board specific support */
	if (0 == fastboot_init(&interface))
	{
		printf ("Fastboot entered...\n");
		run_command("setgreenled 50", 0);
		fastboot_countdown = CFG_FASTBOOT_COUNTDOWN;
		/* If we got this far, we are a success */
		ret = 0;
		val = getbootmode();
		/* On disconnect or error, polling returns non zero */
		/* Always delay for fastboot unless we're in bootmode 4002 
		 * or using the "factory" cable */
		if((0x4002 != val) && !(__raw_readl(0x48055138) & 0x00100000)){
			while (fastboot_countdown)
			{
	            if (!fastboot_confirmed) {
                   fastboot_countdown--;
                }
				if (fastboot_poll())
					break;
				/* if we're holding down the button to get into
				 * recovery, don't wait for the fastboot timeout so we don't
				 * accidentally power off.  short circuit 49999/50000 times
				 * through to keep from overwhelming the twl6030 */

				if (!(fastboot_countdown % 50000) &&
						(0 == twl6030_get_power_button_status())) {
					fastboot_wait_power_button_abort = 1;
					break;
				}
			}
		}else{
			while (1)
			{
				if (fastboot_poll())
					break;
			}
		}
	}

	/* Reset the board specific support */
	fastboot_shutdown();
	/* If we're in 4003, go on to OMAP boot over USB */
	if(0x4003 == val){
        printf ("setting boot sequence first to USB.\nreboot...\n");
        set_SWBootingCfg();		
	}
	return ret;
}
Example #2
0
static int do_fastboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
	uintptr_t buf_addr = (uintptr_t)NULL;
	size_t buf_size = 0;

	if (argc < 2)
		return CMD_RET_USAGE;

	while (argc > 1 && **(argv + 1) == '-') {
		char *arg = *++argv;

		--argc;
		while (*++arg) {
			switch (*arg) {
			case 'l':
				if (--argc <= 0)
					return CMD_RET_USAGE;
				buf_addr = simple_strtoul(*++argv, NULL, 16);
				goto NXTARG;

			case 's':
				if (--argc <= 0)
					return CMD_RET_USAGE;
				buf_size = simple_strtoul(*++argv, NULL, 16);
				goto NXTARG;

			default:
				return CMD_RET_USAGE;
			}
		}
NXTARG:
		;
	}

	/* Handle case when USB controller param is just '-' */
	if (argc == 1) {
		pr_err("Error: Incorrect USB controller index\n");
		return CMD_RET_USAGE;
	}

	fastboot_init((void *)buf_addr, buf_size);

	if (!strcmp(argv[1], "udp"))
		return do_fastboot_udp(argc, argv, buf_addr, buf_size);

	if (!strcmp(argv[1], "usb")) {
		argv++;
		argc--;
	}

	return do_fastboot_usb(argc, argv, buf_addr, buf_size);
}
Example #3
0
int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret = 1;
	unsigned long val;
	/* Initialize the board specific support */
	if (0 == fastboot_init(&interface))
	{
		showimage(FASTBOOT);
		printf ("Fastboot entered...\n");
		fastboot_countdown = CFG_FASTBOOT_COUNTDOWN;
		/* If we got this far, we are a success */
		ret = 0;
		val = idme_get_bootmode();
		/* On disconnect or error, polling returns non zero */
		if((5 == val) && !(__raw_readl(0x48055138) & 0x00100000)){
			while (fastboot_countdown)
			{
				if (!fastboot_confirmed) {
					fastboot_countdown--;
				}
				if (fastboot_poll())
					break;
			}
		}else{
			while (1)
			{
				if (fastboot_poll())
					break;
			}
		}
	}

	/* Reset the board specific support */
	fastboot_shutdown();
	if(5 == val){
        printf ("setting boot sequence first to USB.\nreboot...\n");
        set_SWBootingCfg();		
	}
	printf ("Fastboot exited...\n");
	return ret;
}
int main(int argc, char **argv)
{
	struct statfs buf;
	int ret = 0;
	/* Files written only read/writable by root */
	umask(S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);

	/* initialize libmicroui */
#ifdef USE_GUI
	mui_init();
#endif

	pr_info(" -- UserFastBoot %s for %s --\n", USERFASTBOOT_VERSION, DEVICE_NAME);

	mui_set_background(BACKGROUND_ICON_INSTALLING);

	struct selinux_opt seopts[] = {
		{ SELABEL_OPT_PATH, "/file_contexts" }
	};

	sehandle = selabel_open(SELABEL_CTX_FILE, seopts, 1);

	if (!sehandle) {
		pr_error("Warning: No file_contexts\n");
	}

	load_volume_table();
	aboot_register_commands();
	register_userfastboot_plugins();
	ret = statfs("/tmp", &buf);
	if (!ret){
		unsigned long size = buf.f_bsize * buf.f_bfree;
		fastboot_init(size);
	}
	else
		pr_error("Error when acuiring tmpfs size:-%d\n", errno);


	/* Shouldn't get here */
	exit(1);
}
Example #5
0
int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret = 1;
	char fbparts[4096], *env;
	int check_timeout = 0;
	uint64_t timeout_endtime = 0;
	uint64_t timeout_ticks = 0;
	long timeout_seconds = -1;
	int continue_from_disconnect = 0;

	/*
	 * Place the runtime partitions at the end of the
	 * static paritions.  First save the start off so
	 * it can be saved from run to run.
	 */
	if (static_pcount >= 0) {
		/* Reset */
		pcount = static_pcount;
	} else {
		/* Save */
		static_pcount = pcount;
	}
	env = getenv("fbparts");
	if (env) {
		unsigned int len;
		len = strlen(env);
		if (len && len < 4096) {
			char *s, *e;

			memcpy(&fbparts[0], env, len + 1);
			printf("Fastboot: Adding partitions from environment\n");
			s = &fbparts[0];
			e = s + len;
			while (s < e) {
				if (add_partition_from_environment(s, &s)) {
					printf("Error:Fastboot: Abort adding partitions\n");
					/* reset back to static */
					pcount = static_pcount;
					break;
				}
				/* Skip a bunch of delimiters */
				while (s < e) {
					if ((' ' == *s) ||
					    ('\t' == *s) ||
					    ('\n' == *s) ||
					    ('\r' == *s) ||
					    (',' == *s)) {
						s++;
					} else {
						break;
					}
				}
			}
		}
	}

	/* Time out */
	if (2 == argc) {
		long try_seconds;
		char *try_seconds_end;
		/* Check for timeout */
		try_seconds = simple_strtol(argv[1],
					    &try_seconds_end, 10);
		if ((try_seconds_end != argv[1]) &&
		    (try_seconds >= 0)) {
			check_timeout = 1;
			timeout_seconds = try_seconds;
			printf("Fastboot inactivity timeout %ld seconds\n", timeout_seconds);
		}
	}

	if (1 == check_timeout) {
		timeout_ticks = (uint64_t)
			(timeout_seconds * get_tbclk());
	}


	do {
		continue_from_disconnect = 0;

		/* Initialize the board specific support */
		if (0 == fastboot_init(&interface)) {

			int poll_status;

			/* If we got this far, we are a success */
			ret = 0;
			printf("fastboot initialized\n");

			timeout_endtime = get_ticks();
			timeout_endtime += timeout_ticks;

			while (1) {
				uint64_t current_time = 0;
				poll_status = fastboot_poll();

				if (1 == check_timeout)
					current_time = get_ticks();

				if (FASTBOOT_ERROR == poll_status) {
					/* Error */
					break;
				} else if (FASTBOOT_DISCONNECT == poll_status) {
					/* beak, cleanup and re-init */
					printf("Fastboot disconnect detected\n");
					continue_from_disconnect = 1;
					break;
				} else if ((1 == check_timeout) &&
					   (FASTBOOT_INACTIVE == poll_status)) {

					/* No activity */
					if (current_time >= timeout_endtime) {
						printf("Fastboot inactivity detected\n");
						break;
					}
				} else {
					/* Something happened */
					if (1 == check_timeout) {
						/* Update the timeout endtime */
						timeout_endtime = current_time;
						timeout_endtime += timeout_ticks;
					}
				}

				/* Check if the user wanted to terminate with ^C */
				if ((FASTBOOT_INACTIVE == poll_status) &&
				    (ctrlc())) {
					printf("Fastboot ended by user\n");
					break;
				}

				/*
				 * Check if the fastboot client wanted to
				 * continue booting
				 */
				if (continue_booting) {
					printf("Fastboot ended by client\n");
					break;
				}

				/* Check if there is something to upload */
				tx_handler();
			}
		}

		/* Reset the board specific support */
		fastboot_shutdown();

		/* restart the loop if a disconnect was detected */
	} while (continue_from_disconnect);

	return ret;
}
int do_fastboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
	int ret = 1;
#if defined(CONFIG_MACH_BOWSER_SUBTYPE_TATE)
	unsigned long val;
#endif
	/* Initialize the board specific support */
	if (0 == fastboot_init(&interface))
	{
		printf ("Fastboot entered...\n");

#if defined(CONFIG_FASTBOOT_COUNTDOWN)
		fastboot_countdown = CFG_FASTBOOT_COUNTDOWN;
#endif
		/* If we got this far, we are a success */
		ret = 0;
#if defined(CONFIG_MACH_BOWSER_SUBTYPE_TATE)
		val = getbootmode();
#endif
		/* On disconnect or error, polling returns non zero */
#if defined(CONFIG_FASTBOOT_COUNTDOWN)
		if((3 == flag) ){
			while (fastboot_countdown--)
			{
				if (fastboot_poll()) break;
				if (fastboot_confirmed == 1) {
                    show_fastboot();
                    while (1) {
                        if (fastboot_poll())
                                break;
                    }
                } else {
				  if (fastboot_poll()) break;
				}
			}

		}else{
			show_fastboot();
			while (1)
			{
				if (fastboot_poll())
					break;
			}
		}
#else
		show_fastboot();
		while (1)
		{
			if (fastboot_poll())
				break;
		}
#endif
	}

	/* Reset the board specific support */
	fastboot_shutdown();
#if defined(CONFIG_MACH_BOWSER_SUBTYPE_TATE)
	if(0x5 == val) {
		printf ("setting boot sequence first to USB.\nreboot...\n");
		set_SWBootingCfg();
	}
#endif
	return ret;
}
Example #7
0
int main(int argc, char **argv)
{
	pthread_t t_auto, t_input, t_uevent, t_sighandler;
	//Volume *vol;
	int ret;
	char *disk_conf;
	void (*ui_update)(void *) = NULL;
	sigset_t set;

	/* block signals for all theads */
	sigemptyset(&set);
	sigaddset(&set, SIGPIPE);
	sigaddset(&set, SIGALRM);
	if (pthread_sigmask(SIG_BLOCK, &set, NULL))
		pr_critial("block signal failed.\n");

	/* create a dedicate thread to handle signals */
	if (pthread_create(&t_sighandler, NULL, sig_handler, &set))
		pr_critial("create signal handler thread failed.\n");

	if (argc > 1)
		ret = load_config(argv[1]);
	else
		ret = load_config(NULL);
	/* currently, missing config file is not critical */
	if (ret)
		pr_warning("can't load tboot configuration.\n");

	if (ret = tboot_ui_init(tboot_config_get(UI_CONF_KEY)))
		pr_error("UI crashed!\n");

	tboot_config_set(UI_CONF_KEY, tboot_ui_getconfpath());

	ev_init(input_callback, NULL);

	display_sysinfo(ret);

	if (!ret) {
		ui_update = ui_callback;
	}

	pr_info(" -- preos v%s for %s --\n", preos_version, DEVICE_NAME);
	import_kernel_cmdline(parse_cmdline_option);

	disk_conf = tboot_config_get(DISK_CONFIG_KEY);
	if (!disk_conf) {
		pr_error("Invalid tboot config disk_conf.\n");
		die();
	}

	setup_disk_information(disk_conf);

	aboot_register_commands();

	register_tboot_plugins();

	if (pthread_create(&t_input, NULL, input_listener_thread,
					NULL)) {
		pr_perror("pthread_create");
		die();
	}

	lcd_state_init();

	if (pthread_create(&t_uevent, NULL, uevent_thread, ui_update)) {
		pr_perror("pthread_create t_uevent");
		die();
	}

	/*
	vol = volume_for_path(SDCARD_VOLUME);
	if (vol)
		try_update_sw(vol, 1);
	*/

	if (g_use_autoboot && !g_update_location) {
		/*
		 * Create menu items for debug boot, this is a feature for developers
		 * only.
		 *
		 * Developers (kernel developers) put kernel, cmdline,
		 * rmadisk.img(optional) to platform boot directory  in kexec enabled
		 * preos.
		 *
		 * Generally, there are two ways to do that.
		 *
		 * 1. you can put these files into /boot after the system boot
		 * into rootfs.
		 * 2. you can put these files into platform.img.gz and create a new
		 * platform.img.gz and then flash it to target device.
		 *
		 * Previous, if the system can't boot into rootfs, the only way left
		 * is flash a new platform image. Apparently, it's a huge effort.
		 *
		 * To make more choice, two kernels are supported now, so make sure
		 * there is a works kernel in /boot , you can always boot into
		 * normal system and put a new kernel by any other way, such as scp,
		 * ftp and etc.
		 */

		/*
		 * make our menu acts more like grub which more users familiar with.
		 */
		tboot_ui_menu_item("Boot: kernel", start_default_kernel);
		tboot_ui_menu_item("Boot: kernel.bak", start_backup_kernel);
		tboot_ui_menu_item("Boot: kernel/rootfs on TF/micro-SD card",
				start_mmc_kernel);
		/*
		 * boot from NFS is quite useless now because the usb network bandwidth
		 * is too narrow to satisfy the boot up sequence. It may (80%) hang at
		 * system boot up, especially at X server start up
		 *
		 * So, by default, disable it.
		 */
		if (strcasecmp(tboot_config_get(ENABLE_NFS_KEY), "yes") == 0)
			tboot_ui_menu_item("Boot: kernel/rootfs on NFS",
					start_nfs_kernel);

		tboot_ui_menu_selected(3);      // set debug boot: kernel selected

		if (pthread_create(&t_auto, NULL, autoboot_thread, NULL)) {
			pr_perror("pthread_create");
			die();
		}
	}

	/*
	 * dealy to start tboot server
	 */
	do {
		sleep(1);
	} while (autoboot_enabled || power_pressed);

	pr_info("Listening for the fastboot protocol over USB.\n");
	fastboot_init(g_scratch_size * MEGABYTE);

	/* Shouldn't get here */
	tboot_ui_exit();

	if (tboot_config)
		hashmapFree(tboot_config);
//	tboot_cmds_free();

	exit(1);
}