示例#1
0
void highlight_boot_line(int cursor, enum highlight_type highl) {
	switch (highl) {
	case HIGHLIGHT_GRAY:
		lcd_console_setcolor(CONSOLE_COLOR_GRAY, CONSOLE_COLOR_BLACK);
		break;
	case HIGHLIGHT_GREEN:
		lcd_console_setcolor(CONSOLE_COLOR_BLACK, CONSOLE_COLOR_GREEN);
		break;
	case HIGHLIGHT_CYAN:
		lcd_console_setcolor(CONSOLE_COLOR_BLACK, CONSOLE_COLOR_CYAN);
		break;
	case HIGHLIGHT_NONE:
	default:
		lcd_console_setcolor(CONSOLE_COLOR_CYAN, CONSOLE_COLOR_BLACK);
		break;
	}
	lcd_console_setpos(MENUTOP + cursor, INDENT);
	lcd_puts(opt_list[cursor]);
	if (cursor == CHANGE_BOOT_DEV) {
		print_u_boot_dev();
	}
	if (cursor == CHANGE_BOOT_IMG) {
		print_u_boot_img();
	}
}
示例#2
0
static void display_feedback(enum boot_action image)
{
//	uint16_t *image_start;
//	uint16_t *image_end;

	lcd_bl_set_brightness(150);
 	lcd_console_setpos(53, 25);
	lcd_console_setcolor(CONSOLE_COLOR_CYAN, CONSOLE_COLOR_BLACK);

	switch(image) {

	case BOOT_EMMC_NORMAL:
		lcd_puts(" (INT) LOADING BOOT ...     ");
		break;

	case BOOT_EMMC_RECOVERY:
		lcd_puts(" (INT) LOADING RECOVERY ... ");
		break;

	case BOOT_EMMC_ALTBOOT:
		lcd_puts(" (INT) LOADING ALTBOOT ...  ");
		break;

	case BOOT_SD_RECOVERY:
		lcd_puts(" (SDC) LOADING RECOVERY ...  ");
		break;

	case BOOT_SD_CM7:
		lcd_puts(" (SDC) LOADING CM7 ...       ");
		break;

	case BOOT_SD_CM9:
		lcd_puts(" (SDC) LOADING CM9 ...       ");
		break;

	case BOOT_SD_ALTBOOT1:
		lcd_puts(" (SDC) LOADING ALTBOOT1 ...  ");
		break;

	case BOOT_SD_ALTBOOT2:
		lcd_puts(" (SDC) LOADING ALTBOOT2 ...  ");
		break;

	case BOOT_SD_ALTBOOT3:
		lcd_puts(" (SDC) LOADING ALTBOOT3 ...  ");
		break;

	case BOOT_FASTBOOT:
		lcd_puts(" FASTBOOT HAS STARTED, PRESS POWER TO CANCEL ");
		break;
	default:
		lcd_puts(" LOADING ... ");
		break;
	}

	//lcd_display_image(image_start, image_end);
}
示例#3
0
static void display_feedback(enum boot_action image)
{
//	uint16_t *image_start;
//	uint16_t *image_end;

	lcd_bl_set_brightness(140);
 	lcd_console_setpos(54, 25);
	lcd_console_setcolor(CONSOLE_COLOR_CYAN, CONSOLE_COLOR_BLACK);

	switch(image) {

	case BOOT_EMMC_NORMAL:
		lcd_puts("    Loading (EMMC)...");
		break;
	case BOOT_SD_RECOVERY:
		lcd_puts("Loading Recovery from SD...");
		break;
	case BOOT_SD_ALTBOOT:
		lcd_puts(" Loading AltBoot from SD...");
		break;
	case BOOT_SD_NORMAL:
		lcd_puts("     Loading (SD)...");
		break;
	case BOOT_EMMC_RECOVERY:
		lcd_puts("Loading Recovery from EMMC...");
		break;
	case BOOT_EMMC_ALTBOOT:
		lcd_puts(" Loading AltBoot from EMMC...");
		break;
	case BOOT_FASTBOOT:
	 	lcd_console_setpos(54, 13);
		lcd_puts(" - fastboot has started, press POWER to cancel -");
		break;
	default:
		lcd_puts("        Loading...");
		break;
	}

	//lcd_display_image(image_start, image_end);
}
示例#4
0
int do_menu() {
	unsigned char key = 0;

	int valid_opt[NUM_OPTS] = { 0 };
	int x;
	int cursor = 0;
	u8 pwron = 0;

	lcd_console_setcolor(CONSOLE_COLOR_CYAN, CONSOLE_COLOR_BLACK);
	// lcd_clear (NULL, 1, 1, NULL);
	lcd_console_setpos(MENUTOP-5, INDENT);
	lcd_puts("_____________________________");
	lcd_console_setpos(MENUTOP-3, INDENT);
	lcd_puts("          BOOT MENU          ");
	lcd_console_setpos(MENUTOP-2, INDENT);
	lcd_puts("_____________________________");

	gpio_write(COL0, 0);//drive COL0 LOW

	if (twl6030_hw_status(&pwron)) {
		lcd_console_setpos(MENUTOP, 2);
		lcd_puts("Error: Failed to read twl6030 hw_status\n");
	}
	valid_opt[BOOT_FASTBOOT] = 1;

	valid_opt[BOOT_EMMC_NORMAL] = 1;
	valid_opt[BOOT_EMMC_RECOVERY] = 1;

	if (check_device_image(DEV_EMMC, "altboot.img"))
		valid_opt[BOOT_EMMC_ALTBOOT] = 1;

	if (check_device_image(DEV_SD, "recovery.img"))
		valid_opt[BOOT_SD_RECOVERY] = 1;
	if (check_device_image(DEV_SD, "cm7.img"))
		valid_opt[BOOT_SD_CM7] = 1;
	if (check_device_image(DEV_SD, "cm9.img"))
		valid_opt[BOOT_SD_CM9] = 1;
	if (check_device_image(DEV_SD, "altboot1.img"))
		valid_opt[BOOT_SD_ALTBOOT1] = 1;
	if (check_device_image(DEV_SD, "altboot2.img"))
		valid_opt[BOOT_SD_ALTBOOT2] = 1;
	if (check_device_image(DEV_SD, "altboot3.img"))
		valid_opt[BOOT_SD_ALTBOOT3] = 1;

	if (read_u_boot_file("u-boot.device") != 'X') // if that file is there
		valid_opt[CHANGE_BOOT_DEV] = 1;
	if (read_u_boot_file("u-boot.altboot") != 'X') // if that file is there
		valid_opt[CHANGE_BOOT_IMG] = 1;

	for (x = 0; x < NUM_OPTS; x++) {
		lcd_console_setpos(MENUTOP + x, INDENT);
		if ((!valid_opt[CHANGE_BOOT_DEV] && !valid_opt[CHANGE_BOOT_IMG]) && 
			(x== DEFAULT_BOOT_STR || x == CHANGE_BOOT_DEV || x== CHANGE_BOOT_IMG))
			continue;
		if (valid_opt[x])
			highlight_boot_line(x, HIGHLIGHT_NONE);
		else
			highlight_boot_line(x, HIGHLIGHT_GRAY);
	}

	lcd_console_setpos(MENUTOP + NUM_OPTS + 4, INDENT - 7);
	lcd_puts(" PRESS VOL-UP/DN TO MOVE AND \"n\" TO SELECT");
	lcd_console_setpos(59, 0);
	lcd_puts(" \n \n Menu by j4mm3r, HD.\n Credits: bauwks, fattire, mik_os, Rebellos, Denx, Ogilvy \n Cyanoboot for Nook Tablet (" __TIMESTAMP__ ") - ** NOT FOR SALE **");

	cursor = 0;

	// highlight first option
	highlight_boot_line(cursor, HIGHLIGHT_CYAN);

	do {
		udelay(RESET_TICK);
	} while (get_keys_pressed(&key)); // wait for release

	do {
		get_keys_pressed(&key);

		lcd_console_setpos(5, 0);
#if 0 //debugging purpose
		lcd_printf(" keycode: 0x%X, 0x%X, 0x%X, 0x%X", key, readl(CM_L4PER_GPIO6_CLKCTRL),
				readl(CM_L4PER_GPIO2_CLKCTRL), readl(CM_L4PER_CLKSTCTRL));

#endif
		if (key & VOLDOWN_KEY) // button is pressed
		{
			// unhighlight current option
			highlight_boot_line(cursor, HIGHLIGHT_NONE);
			while (!valid_opt[++cursor] || cursor >= NUM_OPTS) {
				if (cursor >= NUM_OPTS)
					cursor = -1;

			}
			// highlight new option
			highlight_boot_line(cursor, HIGHLIGHT_CYAN);
			do {
				udelay(RESET_TICK);
			} while (get_keys_pressed(&key)); //wait for release

		}

		if (key & VOLUP_KEY) // button is pressed
		{
			// unhighlight current option
			highlight_boot_line(cursor, HIGHLIGHT_NONE);
			while (!valid_opt[--cursor] || cursor < 0) {
				if (cursor < 0)
					cursor = NUM_OPTS;

			}
			// highlight new option
			highlight_boot_line(cursor, HIGHLIGHT_CYAN);
			do {
				udelay(RESET_TICK);
			} while (get_keys_pressed(&key)); //wait for release

		}

		if ((key & N_KEY) && (cursor == CHANGE_BOOT_DEV)) { //selected modify device
			const char* file = "u-boot.device";
			if (read_u_boot_file(file) == '1') {
				write_u_boot_file(file, '0');
			} else {
				write_u_boot_file(file, '1');
			}
			udelay(RESET_TICK);
			highlight_boot_line(cursor, HIGHLIGHT_GREEN);
			do {
				udelay(RESET_TICK);
			} while (get_keys_pressed(&key)); //wait for release
		}

		if ((key & N_KEY) && (cursor == CHANGE_BOOT_IMG)) { //selected modify image
			const char* file = "u-boot.altboot";
			if (read_u_boot_file(file) == '1') {
				write_u_boot_file(file, '0');
			} else {
				write_u_boot_file(file, '1');
			}
			udelay(RESET_TICK);
			highlight_boot_line(cursor, HIGHLIGHT_GREEN);
			do {
				udelay(RESET_TICK);
			} while (get_keys_pressed(&key)); //wait for release
		}
		udelay(RESET_TICK);

	} while (!(key & N_KEY) || (cursor == CHANGE_BOOT_DEV) || (cursor
			== CHANGE_BOOT_IMG));

	highlight_boot_line(cursor, HIGHLIGHT_GREEN);

	lcd_console_setpos(MENUTOP + NUM_OPTS + 2, 25);
	lcd_console_setcolor(CONSOLE_COLOR_CYAN, CONSOLE_COLOR_BLACK);

	return cursor;
}
示例#5
0
int determine_boot_type(void)
{
	DECLARE_GLOBAL_DATA_PTR;
	uint8_t charging;
	uint16_t batt_lvl;
	extern uint16_t check_charging(uint8_t* enabling);
	unsigned long bootcount = bootcount_load();
	char s [5];

	setenv("bootlimit", stringify(ACCLAIM_BOOTLIMIT));
	setenv("altbootcmd", "mmcinit 1; booti mmc1 recovery");
	batt_lvl = check_charging(&charging);
	lcd_console_init();
	// give subtle indicator if uboot is booting from emmc or sd

	if(charging)
		lcd_bl_set_brightness(35); //batt very low, let it charge
	lcd_console_setpos(0, 1); //indent slightly
	lcd_console_setcolor(CONSOLE_COLOR_GRAY, CONSOLE_COLOR_BLACK);
	if (running_from_sd()) {
		lcd_puts("SD");
		} else {
		lcd_puts("EMMC"); }
	sprintf(s, " %u", bootcount);
	lcd_puts(s);
	extern const char* board_rev_string(unsigned long btype);
	lcd_console_setpos(1, 1);
	lcd_printf("board rev: %s | %s", board_rev_string(gd->bd->bi_board_revision), (get_sdram_size() == SZ_512M?"512MB/8GB":"1GB/16GB"));
	lcd_console_setpos(2, 1);
	lcd_console_setcolor((batt_lvl < 30?(batt_lvl <= 10?CONSOLE_COLOR_RED:CONSOLE_COLOR_ORANGE):CONSOLE_COLOR_GREEN), CONSOLE_COLOR_BLACK);
	lcd_printf("batt level: %d\n charging %s", batt_lvl, (charging?"ENABLED":"DISABLED"));


	int action = get_boot_action();

	while(1){
		if(charging)
			lcd_bl_set_brightness(35); //batt very low, let it charge
		else
			lcd_bl_set_brightness(100); //batt very low, let it charge
		switch(action) {
		case BOOT_SD_NORMAL:
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 boot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_NORMAL);
			return 0;

        case BOOT_SD_RECOVERY:
            setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 recovery.img; booti 0x81000000");
            setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_RECOVERY);
            return 0;

		case BOOT_SD_ALTBOOT:
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${sdbootargs}; run setbootargs; mmcinit 0; fatload mmc 0:1 0x81000000 altboot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for sd boot altbootcmd is the same as bootcmd
			display_feedback(BOOT_SD_ALTBOOT);
			return 0;

	        //actually, boot from boot+512K -- thanks bauwks!
		case BOOT_EMMC_NORMAL:
			setenv("bootcmd", "mmcinit 1; booti mmc1 boot 0x80000");
			display_feedback(BOOT_EMMC_NORMAL);
			return 0;

		//actually, boot from recovery+512K -- thanks bauwks!
		case BOOT_EMMC_RECOVERY:
			setenv("bootcmd", "mmcinit 1; booti mmc1 recovery 0x80000");
			display_feedback(BOOT_EMMC_RECOVERY);
			return 0;

		case BOOT_EMMC_ALTBOOT:  // no 512K offset, this is just a file.
			setenv ("bootcmd", "setenv setbootargs setenv bootargs ${emmcbootargs}; run setbootargs; mmcinit 1; fatload mmc 1:5 0x81000000 altboot.img; booti 0x81000000");
			setenv ("altbootcmd", "run bootcmd"); // for emmc altboot altbootcmd is the same as bootcmd
			display_feedback(BOOT_EMMC_ALTBOOT);
			return 0;

		case BOOT_FASTBOOT:
			display_feedback(BOOT_FASTBOOT);
            run_command("fastboot", 0);
			break;
		case INVALID:
		default:
			printf("Aborting boot!\n");
			return 1;
		}
		action = do_menu();
	}
}
示例#6
0
static inline enum boot_action get_boot_action(void) 
{
	u8 pwron = 0;
        volatile struct bootloader_message *bcb = (struct bootloader_message *) 0x81000000;
	volatile unsigned int *reset_reason = (unsigned int *) 0x4A307B04;

	if (mmc_init(1)) {
		printf("mmc_init failed!\n");
		return INVALID;
	}

	// clear bootcount if requested
	if (read_u_boot_clearbc()=='1') {
		bootcount_store((unsigned long)0);
	}

        // Then check if there's a BCB file

        if (!read_bcb()) {
                printf("BCB found, checking...\n");

                if (bcb->command[0] != 0 &&
                        bcb->command[0] != 255) {
                      	  if (running_from_sd()) {
				return BOOT_SD_RECOVERY;
				}
				return BOOT_EMMC_RECOVERY;
			  }
                } else {
		lcd_console_setpos(53, 15);
		lcd_console_setcolor(CONSOLE_COLOR_ORANGE, CONSOLE_COLOR_BLACK);
		lcd_puts("/bootdata/BCB missing.  Running recovery.");
		if (running_from_sd()) {
			return BOOT_SD_RECOVERY;
			}
			return BOOT_EMMC_RECOVERY;
                }

	// give them time to press the button(s)
	udelay(2000*1000);

	if ((gpio_read(HOME_BUTTON) == 0) &&
		(gpio_read(POWER_BUTTON) == 1)) {  // BOTH KEYS STILL HELD FROM UB1
		if (running_from_sd()) {
			return BOOT_SD_RECOVERY;
			}
			return BOOT_EMMC_RECOVERY;
		}

		if ((gpio_read(HOME_BUTTON) == 0) &&
               		 (gpio_read(POWER_BUTTON) == 0))    // just HOME button is pressed
		{ return do_menu();
		}
	else	// default boot
		{

		char device_flag, altboot_flag;
		if ((running_from_sd()) && (!((device_flag = read_u_boot_device()) == '1'))) {
			if (altboot_flag = read_u_boot_altboot() == '1') {
				lcd_console_setpos(53, 15);
				lcd_console_setcolor(CONSOLE_COLOR_ORANGE, CONSOLE_COLOR_BLACK);
				lcd_puts("Normal SD boot overridden.  Alt boot from SD...");
				return BOOT_SD_ALTBOOT;
			} else {
				return BOOT_SD_NORMAL;
			}
		} else { 	// running from emmc or overridden
				if (altboot_flag = read_u_boot_altboot() == '1') {
					lcd_console_setpos(53, 11);
					lcd_console_setcolor(CONSOLE_COLOR_ORANGE, CONSOLE_COLOR_BLACK);
					lcd_puts("Normal SD boot overridden.  Alt boot from EMMC...");
					return BOOT_EMMC_ALTBOOT; }
				else {
					if ((device_flag == '1') && (running_from_sd())) {
					lcd_console_setpos(53, 15);
					lcd_console_setcolor(CONSOLE_COLOR_ORANGE, CONSOLE_COLOR_BLACK);
					lcd_puts("SD boot overridden.  Normal boot from EMMC..."); }
					return BOOT_EMMC_NORMAL;
				}
		}
	}
}