Пример #1
0
int keypress_to_upgrade()
{
	int ret=0;

	ret = isVolRKeyPress();
	if(ret !=1)
	{
		printf("Normal Start...\n");
		return	1;
	}
	else
	{
		display_messge("upgrading... please wait");
		if(upgrade_bootloader())
		{
			run_command ("set upgrade_step 1", 0);
			run_command ("save", 0);
			run_command ("reset", 0);
			hang();
		}
		run_command ("set upgrade_step 2", 0);
		run_command ("save", 0);
		into_recovery();
	}
	return 0;
	
}
Пример #2
0
int switch_boot_mode(void)
{
	unsigned long hold_time = 5000000, polling_time = 10000, tmp;
	//unsigned long upgrade_step;
	unsigned int key_flag=0;

	while(hold_time > 0)
	{
		udelay(polling_time);
		tmp = get_key();
		if(tmp && (key_flag<10)) {  
		    printf("get_key(): %d\n", tmp);
                    key_flag++;
                }
                else if(!tmp && (key_flag>=10) && (key_flag<20)) {
		    printf("get_key(): %d\n", tmp);
                    key_flag++;
                }
                else if(key_flag>=20)
                    break;
        
		hold_time -= polling_time;
        if((key_flag==0) && (hold_time<4950000))
            break;
	}
        printf("key_flag=%d\n", key_flag);
	if(key_flag >= 15)
	{
                printf("nand key burning.... please wait\n");
                run_command ("tiny_usbtool 20000", 0);
                return 1;
	}
	else if(key_flag == 10)
	{
		printf("upgrading... please wait\n");
		into_recovery();
	} else {
		printf("Normal Start...\n");
		return	1;
        }

}
int switch_boot_mode(void)
{
    unsigned long hold_time = 50000, polling_time = 10000, tmp;

    printf("ENTER U-BOOT SWITCH MODE !!!!\n");

    saradc_enable();

    //added by pengtj for added fool idle
    get_key();
    get_key();
    #ifdef ADD_FOR_MBX_C03
    set_power_pin();
    #endif

    while(hold_time > 0)
    {
        udelay(polling_time);
        tmp = get_key();
        printf("get_key(): %d\n", tmp);
        if(!tmp)  break;
        hold_time -= polling_time;
    }

	logo_display();
    if (reboot_mode == AMLOGIC_FACTORY_RESET_REBOOT )
    {
    	  printf("Recovery Start from upgrade apk...\n");
	#ifdef CONFIG_UPGRADE
		into_recovery();
	#else
        run_command ("run recoveryboot", 0);
	#endif
        hang();

    }
    else if(hold_time > 0)
    {
        printf("Normal Start...\n");
#ifdef POWER_KEY_LEAD_START_UP
       int temp=0;
	int bootdelay=0;
	printf("Please input power key ! \n ");
	gpio_direction_input(INPUT_KEY_VALUE);
	printf("\b\b\b\0");
	while(1)
	{
	       temp=gpio_get_value(INPUT_KEY_VALUE);
		if(temp<1)
			break;
	       udelay(10000);
	};
    #endif
        return  1;
    }
    else
    {
       	printf("Recovery Start...\n");
       	//aml_autoscript();
	#ifdef CONFIG_UPGRADE
		into_recovery();
	#else
        run_command ("run recoveryboot", 0);
	#endif
        hang();
    }
}
Пример #4
0
int switch_boot_mode(void)
{
 //   unsigned long hold_time = 50000, polling_time = 10000, tmp;
    unsigned long upgrade_step;
	int ret=0;
	act8942_init(&act8942_pdata);
	//act8942_dump();
	
	upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16);
	printf("upgrade_step = %d\n", upgrade_step);
	
	saradc_enable();
	
#ifdef ENABLE_FONT_RESOURCE
	RegisterFont(DEFAULT_FONT);
#endif
	ret=isVolAKeyPress();
	if(ret==1)
		aml_autoscript();
	
	powerkey_hold(0);
#ifdef CONFIG_AML_TINY_USBTOOL
	usb_boot(1);
#endif
	
	if(upgrade_step == 2)
	{
		switch(reboot_mode)
		{
			case AMLOGIC_NORMAL_BOOT:
			{
				ret=keypress_to_upgrade();
				if(ret==0)
					return 0;
				printf("AMLOGIC_NORMAL_BOOT...\n");
				power_up();
				logo_display();
				return	1;
			}
			case AMLOGIC_FACTORY_RESET_REBOOT:
			{
				printf("AMLOGIC_FACTORY_RESET_REBOOT...\n");
				power_up();
				logo_display();
				run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0);
				run_command ("bootm", 0);
				break;
			}
			case AMLOGIC_UPDATE_REBOOT:
			{
				printf("AMLOGIC_UPDATE_REBOOT...\n");
				power_up();
				logo_display();
				run_command ("set upgrade_step 0", 0);
				run_command ("save", 0);
				upgrade_step = 0;
				break;
			}
			default:
			{
				printf("AMLOGIC_CHARGING_REBOOT...\n");
				if(is_ac_connected)
				{
					power_up();
#ifdef CONFIG_BATTERY_CHARGING
					//battery_charging();
#endif
					logo_display();
				}
				else
				{
					powerkey_hold(0);
#ifdef CONFIG_BATTERY_CHARGING
					if(get_powerkey_hold_count())
					{
						  logo_display();
						if(get_battery_percentage() < 10)
						{
							power_low_display();
							sdelay(2);
							power_down();
							printf("Low Power!!!\nPower Down!\n");
							hang();
						}
#else
					if(powerkey_hold(1000))
					{
#endif
						logo_display();
						power_up();
						printf("Power Up!\n");
					}
					else
					{
						power_down();
						printf("Power Down!\n");
						hang();
					}
				}
				break;
			}
		}
	}
	else
	{
		power_up();
		printf("Upgrade step %d...\n", upgrade_step);
	}

	if(upgrade_step == 0)
	{
#ifdef CONFIG_AML_TINY_USBTOOL
		usb_boot(1);
#endif

		display_messge("upgrade step 1! Don't Power Off!");
		if(upgrade_bootloader())
		{
			run_command ("set upgrade_step 1", 0);
			run_command ("save", 0);
			run_command ("reset", 0);
			hang();
		}
		else
		{
			printf("### ERROR:	u-boot write failed!!!\n");
			return	-1;
		}
	}
	else if(upgrade_step == 1)
	{
		display_messge("upgrade step 2! Don't Power Off!");
		run_command ("defenv", 0);
		run_command ("set upgrade_step 2", 0);
		run_command ("save", 0);
		
		into_recovery();
	}


	//added by Elvis for added fool idle
	/*get_key();
	get_key();
	
	while(hold_time > 0)
	{
		udelay(polling_time);
		tmp = get_key();
		printf("get_key(): %d\n", tmp);
		if(!tmp)  break;
		hold_time -= polling_time;
	}

	if(hold_time > 0)
	{
		printf("Normal Start...\n");
		return	1;
	}
	else
	{
		display_messge("upgrading... please wait");
		if(upgrade_bootloader())
		{
			run_command ("set upgrade_step 1", 0);
			run_command ("save", 0);
			run_command ("reset", 0);
			hang();
		}
		run_command ("set upgrade_step 2", 0);
		run_command ("save", 0);
		into_recovery();
	}

*/
		ret=keypress_to_upgrade();
		return ret;

//return	0;
}
Пример #5
0
int switch_boot_mode(void)
{
    unsigned long hold_time = 50000, polling_time = 10000, tmp;
    unsigned long upgrade_step;

    upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16);
    printf("upgrade_step = %d    !!!!!!!!!!!!!!!!!!\n", upgrade_step);

    saradc_enable();

#ifdef	CONFIG_UBI_SUPPORT
    powerkey_hold(0);
    run_command ("ubi part system", 0);
    powerkey_hold(0);
    run_command ("ubifsmount system", 0);
    //run_command ("ubifsls", 0);
#endif

    if(upgrade_step == 3)
    {
        switch(reboot_mode)
        {
            case AMLOGIC_NORMAL_BOOT:
            {
                printf("AMLOGIC_NORMAL_BOOT...\n");
                power_hold();
		//green led on red led off
		green_powerkey_led_on();
		red_powerkey_led_off();
		SET_MPEG_REG_MASK(VPP_MISC, VPP_POST_FG_OSD2 | VPP_PRE_FG_OSD2);
                logo_display();
                return  1;
            }
            case AMLOGIC_FACTORY_RESET_REBOOT:
            {
                printf("AMLOGIC_FACTORY_RESET_REBOOT...\n");
                power_hold();
		//green led on red led off
		green_powerkey_led_on();
		red_powerkey_led_off();
		SET_MPEG_REG_MASK(VPP_MISC, VPP_POST_FG_OSD2 | VPP_PRE_FG_OSD2);
                logo_display();
                run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0);
				run_command ("bootm", 0);
                break;
            }
            case AMLOGIC_UPDATE_REBOOT:
            {
                printf("AMLOGIC_UPDATE_REBOOT...\n");
                power_hold();
		//green led on red led off
		green_powerkey_led_on();
		red_powerkey_led_off();
		SET_MPEG_REG_MASK(VPP_MISC, VPP_POST_FG_OSD2 | VPP_PRE_FG_OSD2);
                logo_display();
                run_command ("set upgrade_step 0", 0);
                run_command ("save", 0);
                upgrade_step = 0;
                break;
            }
	    case AMLOGIC_CHARGING_REBOOT:
	    {
                printf("AMLOGIC_POWERDOWN... \n");
                if(is_ac_connected)
                { 
                    power_unhold();
		    hang();
                }
	    	}
            default:
            {
                printf("Default.... \n");
                if(is_ac_connected)
                { 
                    power_hold();
#ifdef CONFIG_BATTERY_CHARGING
			battery_charging();
#endif
                }
                else
                {
                    powerkey_hold(0);
                    if(get_powerkey_hold_count())
                    {
#ifdef CONFIG_BATTERY_CHARGING
                        if(get_battery_percentage() < 10)
                        {
                            power_low_display();
                            sdelay(2);
                            power_unhold();
                            printf("Low Power!!!\nPower Down!\n");
                            hang();
                        }
#endif
                        power_hold();
                        printf("Power Up!\n");
                    }
                    else
                    {
                        power_unhold();
                        printf("Power Down!\n");
                        hang();
                    }
                }
		//green led on red led off
		green_powerkey_led_on();
		red_powerkey_led_off();
		SET_MPEG_REG_MASK(VPP_MISC, VPP_POST_FG_OSD2 | VPP_PRE_FG_OSD2);


                logo_display();
                break;
            }
        }
    }
    else
    {
        power_hold();
        printf("Upgrade step %d...\n", upgrade_step);

	green_powerkey_led_on();
	red_powerkey_led_off();
	SET_MPEG_REG_MASK(VPP_MISC, VPP_POST_FG_OSD2 | VPP_PRE_FG_OSD2);
        logo_display();
    }

    if(upgrade_step == 0)
    {
        if(upgrade_bootloader())
        {
            run_command ("set upgrade_step 1", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        else
        {
            printf("### ERROR:  u-boot write failed!!!\n");
            return  -1;
        }
    }
    else if((upgrade_step >0) && (upgrade_step < 3))
    {
        if(upgrade_step == 1)
        {
            if(upgrade_env())
            {
                run_command ("set upgrade_step 2", 0);
                run_command ("save", 0);
                run_command ("reset", 0);
                hang();
            }
            else
            {
                run_command ("defenv", 0);
                run_command ("save", 0);
            }
        }
        run_command ("set upgrade_step 3", 0);
        run_command ("save", 0);
        //upgrade_partition();
        into_recovery();
    }

    //added by Elvis for added fool idle
    get_key();
    get_key();
    
    while(hold_time > 0)
    {
        udelay(polling_time);
        tmp = get_key();
        printf("get_key(): %d\n", tmp);
        if(!tmp)  break;
        hold_time -= polling_time;
    }

    if(hold_time > 0)
    {
        aml_autoscript();
        printf("Normal Start...\n");
        return  1;
    }
    else
    {
        if(upgrade_bootloader())
        {
            run_command ("set upgrade_step 1", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        if(upgrade_env())
        {
            run_command ("set upgrade_step 2", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        run_command ("set upgrade_step 3", 0);
        run_command ("save", 0);
#ifndef	CONFIG_UBI_SUPPORT
        //upgrade_partition();
#endif
        into_recovery();
    }
}
Пример #6
0
int switch_boot_mode(void)
{
    unsigned long hold_time = 3000, polling_time = 10000, tmp;
    unsigned long upgrade_step;

    upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16);
    printf("upgrade_step = %d    !!!!!!!!!!!!!!!!!!\n", upgrade_step);

#ifdef CONFIG_SARADC
    saradc_enable();
#endif

#ifdef ENABLE_FONT_RESOURCE
		RegisterFont(DEFAULT_FONT);
#endif
		//aml_autoscript();
		//logo_display();
		//return 1;

    if(upgrade_step == 3)
    {
		switch(reboot_mode)
        {
            case AMLOGIC_NORMAL_BOOT:
            {
                printf("AMLOGIC_NORMAL_BOOT...\n");
                printf("reboot_mode is %d...\n", reboot_mode);
                power_hold();
                logo_display();
                return  1;
            }
            case AMLOGIC_FACTORY_RESET_REBOOT:
            {
                printf("AMLOGIC_FACTORY_RESET_REBOOT...\n");
                power_hold();
                logo_display();
                run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0);
				run_command ("bootm", 0);;
                break;
            }
            case AMLOGIC_UPDATE_REBOOT:
            {
                printf("AMLOGIC_UPDATE_REBOOT...\n");
                power_hold();
                logo_display();
                run_command ("set upgrade_step 0", 0);
                run_command ("save", 0);
                upgrade_step = 0;
                break;
            }
            default:
            {
                printf("Default.... \n");
                power_hold();
                logo_display();
            	break;
            }
        }
    }
    else
    {
        power_hold();
        printf("Upgrade step %d...\n", upgrade_step);
    }

    if(upgrade_step == 0)
    {
        display_messge("upgrade step 1! Don't Power Off!");
		if(upgrade_bootloader())
        {
            run_command ("set upgrade_step 1", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        else
        {
            printf("### ERROR:  u-boot write failed!!!\n");
            //return  -1;
        }
    }
    else if((upgrade_step >0) && (upgrade_step < 3))
    {
        if(upgrade_step == 1)
        {
            display_messge("upgrade step 2! Don't Power Off!");
            if(upgrade_env())
            {
                run_command ("set upgrade_step 2", 0);
                run_command ("save", 0);
                run_command ("reset", 0);
                hang();
            }
            else
            {
                run_command ("defenv", 0);
                run_command ("save", 0);
            }
        }
		display_messge("upgrade step 3! Don't Power Off!");
        run_command ("set upgrade_step 3", 0);
        run_command ("save", 0);
        //upgrade_partition();
        into_recovery();
    }

	powerkey_hold(0);
    if(!powerkey_hold(hold_time))
    {
    	//aml_autoscript();
    	if(upgrade_step == 0)
    	{
        	logo_display();
	        run_command ("set upgrade_step 3", 0);
	        run_command ("save", 0);
    	}
    	printf("Normal Start...\n");	
    	return 1;
    }
    else
    {
		display_messge("upgrading... please wait");
		if(upgrade_bootloader())
        {
            run_command ("set upgrade_step 1", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        if(upgrade_env())
        {
            run_command ("set upgrade_step 2", 0);
            run_command ("save", 0);
            run_command ("reset", 0);
            hang();
        }
        run_command ("set upgrade_step 3", 0);
        run_command ("save", 0);
#ifndef	CONFIG_UBI_SUPPORT
        //upgrade_partition();
#endif
        into_recovery();
    }
}
Пример #7
0
int switch_boot_mode(void)
{
    unsigned long hold_time = 50000, polling_time = 10000, tmp;
    unsigned long upgrade_step;
    
    clrbits_le32(P_PREG_PAD_GPIO2_EN_N, (1<<25));     // VCC5V_EN GPIOD_9
    setbits_le32(P_PREG_PAD_GPIO2_O, (1<<25));

	get_osd_size();
	
#ifdef CONFIG_PMU_ACT8942
	act8942_init(&act8942_pdata);
	//act8942_dump();
#endif

	upgrade_step = simple_strtoul (getenv ("upgrade_step"), NULL, 16);
	printf("upgrade_step = %d\n", upgrade_step);
	
	saradc_enable();
	
#ifdef ENABLE_FONT_RESOURCE
	RegisterFont(DEFAULT_FONT);
#endif
	aml_autoscript();
	powerkey_hold(0);
	u32 reboot_mode_current = reboot_mode;//cvt
    reboot_mode_clear();//cvt
#ifdef	CONFIG_AML_TINY_USBTOOL		//cvt
extern int usb_boot(int clk_cfg, int time_out);
	if((reboot_mode_current == MESON_USB_BURNER_REBOOT) || get_burner_key())
	{
		usb_boot(1, 200000);
	}
#endif

	if(upgrade_step == 2)
	{
		switch(reboot_mode_current)
		{
			case AMLOGIC_NORMAL_BOOT:
			{
				printf("AMLOGIC_NORMAL_BOOT...\n");
				power_up();
				logo_display();
				return	1;
			}
			case AMLOGIC_FACTORY_RESET_REBOOT:
			{
				printf("AMLOGIC_FACTORY_RESET_REBOOT...\n");
				power_up();
				logo_display();
				run_command ("nand read ${recovery_name} ${loadaddr} 0 ${recovery_size}", 0);
				run_command ("bootm", 0);
				break;
			}
			case AMLOGIC_UPDATE_REBOOT:
			{
				printf("AMLOGIC_UPDATE_REBOOT...\n");
				power_up();
				logo_display();
				run_command ("set upgrade_step 0", 0);
				run_command ("save", 0);
				upgrade_step = 0;
				break;
			}
			default:
			{
				printf("AMLOGIC_CHARGING_REBOOT...\n");
				if(is_ac_connected)
				{
					power_up();
#ifdef CONFIG_BATTERY_CHARGING
					battery_charging();
#endif
					logo_display();
				}
				else
				{
					powerkey_hold(0);
#ifdef CONFIG_BATTERY_CHARGING
					if(get_powerkey_hold_count())
					{
						  logo_display();
						if(get_battery_percentage() < 10)
						{
							power_low_display();
							sdelay(2);
							power_down();
							printf("Low Power!!!\nPower Down!\n");
							hang();
						}
						logo_display();
						power_up();
						printf("Power Up!\n");
					}
#else
					if(powerkey_hold(1000))
					{
						logo_display();
						power_up();
						printf("Power Up!\n");
					}
#endif
					else
					{
						power_down();
						printf("Power Down!\n");
						hang();
					}
				}
				break;
			}
		}
	}
	else
	{
		power_up();
		printf("Upgrade step %d...\n", upgrade_step);
	}

	if(upgrade_step == 0)
	{
		display_messge("upgrade step 1! Don't Power Off!");
		if(upgrade_bootloader())
		{
			run_command ("set upgrade_step 1", 0);
			run_command ("save", 0);
			run_command ("reset", 0);
			hang();
		}
		else
		{
			printf("### ERROR:	u-boot write failed!!!\n");
			return	-1;
		}
	}
	else if(upgrade_step == 1)
	{
		display_messge("upgrade step 2! Don't Power Off!");
		run_command ("set upgrade_step 2", 0);
		run_command ("save", 0);
		into_recovery();
	}


	//added by Elvis for added fool idle
	get_key();
	get_key();
	
	while(hold_time > 0)
	{
		udelay(polling_time);
		tmp = get_key();
		printf("get_key(): %d\n", tmp);
		if(!tmp)  break;
		hold_time -= polling_time;
	}

	if(hold_time > 0)
	{
		printf("Normal Start...\n");
		
		char *recovery_command;
		recovery_command = getenv("recovery_command");
		if (strcmp(recovery_command, "--usb_burning") == 0){
				run_command ("set recovery_command", 0);
		}	
		
		run_command ("save", 0);
		return	1;
	}
	else
	{
		display_messge("upgrading... please wait");
		if(upgrade_bootloader())
		{
			run_command ("set upgrade_step 1", 0);
			run_command ("save", 0);
			run_command ("reset", 0);
			hang();
		}
		run_command ("set upgrade_step 2", 0);
		run_command ("save", 0);
		into_recovery();
	}


return	0;
}