/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int check_android_misc(void)
{
	int   mode;
	u32   misc_offset = 0;
	char  misc_args[2048];
	char  misc_fill[2048];
	char  boot_commond[128];
	static struct bootloader_message *misc_message;

	if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT)
	{
		return 0;
	}
	if(gd->force_shell)
	{
		char delaytime[8];

		sprintf(delaytime, "%d", 3);
		setenv("bootdelay", delaytime);
	}

    memset(boot_commond, 0x0, 128);
	set_boot_type_cmd(boot_commond);
	printf("base bootcmd=%s\n", boot_commond);
	//判断存储介质
	if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2))
	{
		sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc");
		printf("bootcmd set setargs_mmc\n");
	}
	else
	{
		printf("bootcmd set setargs_nand\n");
	}
	//判断是否存在按键进入其它模式
	memset(misc_args, 0x0, 2048);
	mode = detect_other_boot_mode();
	misc_message = (struct bootloader_message *)misc_args;
	if(mode == ANDROID_NULL_MODE)
	{
		misc_offset = sunxi_partition_get_offset_byname("misc");
		if(!misc_offset)
		{
			int pmu_value;

			puts("no misc partition is found\n");
			pmu_value = axp_probe_pre_sys_mode();
			if(pmu_value == PMU_PRE_FASTBOOT_MODE)
			{
				puts("ready to enter fastboot mode\n");
				setenv("bootcmd", "run boot_fastboot");

				return 0;
			}
			else
			{
				printf("to be run cmd=%s\n", boot_commond);
				setenv("bootcmd", boot_commond);

				return 0;
			}
		}
		memset(misc_fill, 0xff, 2048);
#ifdef DEBUG
		tick_printf("misc_offset  : %d\n", (int )misc_offset);
#endif
		sunxi_flash_read(misc_offset, 2048/512, misc_args);
	}
	else if(mode == ANDROID_RECOVERY_MODE)
	{
		strcpy(misc_message->command, "boot-recovery");
	}
	else if(mode == ANDROID_FASTBOOT_MODE)
	{
		strcpy(misc_message->command, "bootloader");
	}
#ifdef DEBUG
	{
		uint *dump_value;

		dump_value = *(uint *)misc_message->command;
		if(dump_value != 0xffffffff)
			printf("misc.command  : %s\n", misc_message->command);
		else
			printf("misc.command  : NULL\n");

		dump_value = *(uint *)misc_message->status;
		if(dump_value != 0xffffffff)
			printf("misc.status  : %s\n", misc_message->status);
		else
			printf("misc.status  : NULL\n");

		dump_value = *(uint *)misc_message->recovery;
		if(dump_value != 0xffffffff)
			printf("misc.recovery  : %s\n", misc_message->recovery);
		else
			printf("misc.recovery  : NULL\n");
	}
#endif
	//判断命令
	if(!strcmp(misc_message->command, "efex"))
	{
		/* there is a recovery command */
		puts("find efex cmd\n");
		sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		sunxi_board_run_fel();

		return 0;
	}

	if(!strcmp(misc_message->command, "boot-resignature"))
	{
		puts("find boot-resignature cmd\n");
		sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1);
	}
	else if(!strcmp(misc_message->command, "boot-recovery"))
	{
		puts("Recovery detected, will boot recovery\n");
		sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
		/* android recovery will clean the misc */
	}
	else if(!strcmp(misc_message->command, "bootloader"))
	{
		puts("Fastboot detected, will boot fastboot\n");
		sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot");
		if(misc_offset)
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
	}

	setenv("bootcmd", boot_commond);

	printf("to be run cmd=%s\n", boot_commond);

	return 0;
}
Пример #2
0
/*
************************************************************************************************************
*
*                                             function
*
*    name          :
*
*    parmeters     :
*
*    return        :
*
*    note          :
*
*
************************************************************************************************************
*/
int check_android_misc(void)
{
	int   mode;
	int	  pmu_value;
	u32   misc_offset = 0;
	char  misc_args[2048];
	char  misc_fill[2048];
	char  boot_commond[128];
	static struct bootloader_message *misc_message;

	if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT)
	{
		return 0;
	}
	if(gd->force_shell)
	{
		char delaytime[8];

		sprintf(delaytime, "%d", 3);
		setenv("bootdelay", delaytime);
	}
    //if enter debug mode,set loglevel = 8
    check_debug_mode();

   memset(boot_commond, 0x0, 128);
	strcpy(boot_commond, getenv("bootcmd"));
	printf("base bootcmd=%s\n", boot_commond);
	//判断存储介质
	if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2))
	{
		sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc");
		printf("bootcmd set setargs_mmc\n");
	}
	else
	{
		printf("bootcmd set setargs_nand\n");
	}
	misc_message = (struct bootloader_message *)misc_args;
	memset(misc_args, 0x0, 2048);
	memset(misc_fill, 0xff, 2048);
	mode = detect_other_boot_mode();
	if(mode == ANDROID_NULL_MODE)
	{
		pmu_value = axp_probe_pre_sys_mode();
		if(pmu_value == PMU_PRE_FASTBOOT_MODE)
		{
			puts("PMU : ready to enter fastboot mode\n");
			strcpy(misc_message->command, "bootloader");
		}
		else if(pmu_value == PMU_PRE_RECOVERY_MODE)
		{
			puts("PMU : ready to enter recovery mode\n");
			strcpy(misc_message->command, "boot-recovery");
		}
		else
		{
			misc_offset = sunxi_partition_get_offset_byname("misc");
			debug("misc_offset = %x\n",misc_offset);
			if(!misc_offset)
			{
				printf("no misc partition is found\n");
			}
			else
			{
				printf("misc partition found\n");
				sunxi_flash_read(misc_offset, 2048/512, misc_args); //read misc partition data
			}
		}
	}
	else if(mode == ANDROID_RECOVERY_MODE)
	{
		strcpy(misc_message->command, "boot-recovery");
	}
	else if( mode == ANDROID_FASTBOOT_MODE)
	{
		strcpy(misc_message->command, "bootloader");
	}
	//最终统一判断命令
	if(!loglel_change_flag)   //add by young,if you want to enter debug_mode ,so do enter boot_normal
	{
		if(!strcmp(misc_message->command, "efex"))
		{
			/* there is a recovery command */
			puts("find efex cmd\n");
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
			sunxi_board_run_fel();

			return 0;
		}

		if(!strcmp(misc_message->command, "boot-resignature"))
		{
			puts("find boot-resignature cmd\n");
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
			sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1);
		}
		else if(!strcmp(misc_message->command, "boot-recovery"))
		{
			if(!strcmp(misc_message->recovery, "sysrecovery"))
			{
				puts("recovery detected, will sprite recovery\n");
				strncpy(boot_commond, "sprite_recovery", sizeof("sprite_recovery"));
				sunxi_flash_write(misc_offset, 2048/512, misc_fill);
			}
			else
			{
				puts("Recovery detected, will boot recovery\n");
				sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
			}
			/* android recovery will clean the misc */
		}
		else if(!strcmp(misc_message->command, "bootloader"))
		{
			puts("Fastboot detected, will boot fastboot\n");
			sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot");
			if(misc_offset)
				sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		}
		else if(!strcmp(misc_message->command, "usb-recovery"))
		{
			puts("Recovery detected, will usb recovery\n");
			sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
		}
	}
	if(!strcmp(misc_message->command ,"debug_mode"))
	{
		puts("debug_mode detected ,will enter debug_mode");
		if(!change_to_debug_mode())
		{
			check_debug_mode();
		}
			sunxi_flash_write(misc_offset,2048/512,misc_fill);
	}
	setenv("bootcmd", boot_commond);

	printf("to be run cmd=%s\n", boot_commond);
	return 0;

}
Пример #3
0
int check_android_misc(void)
{
	int   mode;
	int	  pmu_value;
	u32   misc_offset = 0;
	char  misc_args[2048];
	char  misc_fill[2048];
	char  boot_commond[128];
	static struct bootloader_message *misc_message;

	if(uboot_spare_head.boot_data.work_mode != WORK_MODE_BOOT)
	{
		return 0;
	}
	if(gd->force_shell)
	{
		char delaytime[8];

		sprintf(delaytime, "%d", 3);
		setenv("bootdelay", delaytime);
	}
        //if enter debug mode,set loglevel = 8
        check_debug_mode();

        memset(boot_commond, 0x0, 128);
	strcpy(boot_commond, getenv("bootcmd"));
	printf("base bootcmd=%s\n", boot_commond);
	//判断存储介质
	if((uboot_spare_head.boot_data.storage_type == 1) || (uboot_spare_head.boot_data.storage_type == 2))
	{
		sunxi_str_replace(boot_commond, "setargs_nand", "setargs_mmc");
		printf("bootcmd set setargs_mmc\n");
	}
	else
	{
		printf("bootcmd set setargs_nand\n");
	}
	//判断是否存在按键进入其它模式
	misc_message = (struct bootloader_message *)misc_args;
	memset(misc_args, 0x0, 2048);
	memset(misc_fill, 0xff, 2048);
	mode = detect_other_boot_mode();

	misc_offset = sunxi_partition_get_offset_byname("misc");
	//先判断上一次系统是否有写入数据到pmu寄存器
	pmu_value = axp_probe_pre_sys_mode();
	if(pmu_value == PMU_PRE_FASTBOOT_MODE)
	{
		puts("PMU : ready to enter fastboot mode\n");
		strcpy(misc_message->command, "bootloader");
	}
	else if(pmu_value == PMU_PRE_RECOVERY_MODE)
	{
		puts("PMU : ready to enter recovery mode\n");
		strcpy(misc_message->command, "boot-recovery");
	}
//get the part --"misc"
	else
	{
		debug("misc_offset = %x\n",misc_offset);
		if(!misc_offset)
		{
			printf("no misc partition is found\n");
		}
		else
		{
			printf("misc partition found\n");
			sunxi_flash_read(misc_offset, 2048/512, misc_args); //read misc partition data
		}
	}
	if((misc_message->command[0] == 0x00) ||(misc_message->command[0] == 0xff))
	{
		printf("misc_message->command = %x \n",misc_message->command[0]);
		if(mode == USER_SELECT_MODE) //说明探测阶段有按键按下
		{
			printf("enter user_select_mode\n");
		#if 0
			//如果misc分区没有上次系统写入数据,并且检测到有按键按下,那么进入图片显示菜单
			user_select_current_status = FASTBOOT_MODE;
			show_user_select_menu_ui(); //显示当前模式的ui
			while(status != POWERON_KEY_PRESSED)//图片显示菜单
			{
				status = sunxi_probe_key_pressed();
				if(( status == KEY_PRESSED))
				{
					debug("key_ststus = 0x%x\n ",status);
					user_mode_status_update(status);     	//更新菜单的选项
					show_user_select_menu_ui(); 				//显示当前模式的ui
				}
			}
			if(user_select_current_status == RECOVERY_MODE )
			{
				printf("misc_message->command = boot-recovery\n");
				strcpy(misc_message->command, "boot-recovery");
			}
			else if(user_select_current_status == FASTBOOT_MODE)
			{
				printf("misc_message->command = bootloader\n");
				strcpy(misc_message->command, "bootloader");
			}
		#endif
		}
		else if(mode == ANDROID_RECOVERY_MODE)
		{
			strcpy(misc_message->command, "boot-recovery");
		}
		else if( mode == ANDROID_FASTBOOT_MODE)
		{
			strcpy(misc_message->command, "bootloader");
		}
	}

	//最终统一判断命令
	if(!loglel_change_flag)   //add by young,if you want to enter debug_mode ,so do enter boot_normal
	{
		if(!strcmp(misc_message->command, "efex"))
		{
			/* there is a recovery command */
			puts("find efex cmd\n");
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
			sunxi_board_run_fel();

			return 0;
		}

		if(!strcmp(misc_message->command, "boot-resignature"))
		{
			puts("find boot-resignature cmd\n");
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
			sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1);
		}
		else if(!strcmp(misc_message->command, "boot-recovery"))
		{
			puts("Recovery detected, will boot recovery\n");
			sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
			/* android recovery will clean the misc */
		}
		else if(!strcmp(misc_message->command, "bootloader"))
		{
			puts("Fastboot detected, will boot fastboot\n");
			sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot");
			if(misc_offset)
				sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		}
		else if(!strcmp(misc_message->command, "usb-recovery"))
		{
			puts("Recovery detected, will usb recovery\n");
			sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
		}
	}
	if(!strcmp(misc_message->command ,"debug_mode"))
	{
		puts("debug_mode detected ,will enter debug_mode");
		if(!change_to_debug_mode())
		{
			check_debug_mode();
		}
			sunxi_flash_write(misc_offset,2048/512,misc_fill);
	}
	setenv("bootcmd", boot_commond);

	printf("to be run cmd=%s\n", boot_commond);
#if 0
	misc_message = (struct bootloader_message *)misc_args;
	if(mode == ANDROID_NULL_MODE)
	{
		misc_offset = sunxi_partition_get_offset_byname("misc");
		if(!misc_offset)
		{
			int pmu_value;

			puts("no misc partition is found\n");
			pmu_value = axp_probe_pre_sys_mode();
			if(pmu_value == PMU_PRE_FASTBOOT_MODE)
			{
				puts("ready to enter fastboot mode\n");
				setenv("bootcmd", "run boot_fastboot");

				return 0;
			}
			else
			{
				printf("to be run cmd=%s\n", boot_commond);
				setenv("bootcmd", boot_commond);

				return 0;
			}
		}
		memset(misc_fill, 0xff, 2048);
#ifdef DEBUG
		tick_printf("misc_offset  : %d\n", (int )misc_offset);
#endif
		sunxi_flash_read(misc_offset, 2048/512, misc_args);
	}
	else if(mode == ANDROID_RECOVERY_MODE)
	{
		strcpy(misc_message->command, "boot-recovery");
	}
	else if(mode == ANDROID_FASTBOOT_MODE)
	{
		strcpy(misc_message->command, "bootloader");
	}
#ifdef DEBUG
	{
		uint *dump_value;

		dump_value = *(uint *)misc_message->command;
		if(dump_value != 0xffffffff)
			printf("misc.command  : %s\n", misc_message->command);
		else
			printf("misc.command  : NULL\n");

		dump_value = *(uint *)misc_message->status;
		if(dump_value != 0xffffffff)
			printf("misc.status  : %s\n", misc_message->status);
		else
			printf("misc.status  : NULL\n");

		dump_value = *(uint *)misc_message->recovery;
		if(dump_value != 0xffffffff)
			printf("misc.recovery  : %s\n", misc_message->recovery);
		else
			printf("misc.recovery  : NULL\n");
	}
#endif
	//判断命令
	if(!strcmp(misc_message->command, "efex"))
	{
		/* there is a recovery command */
		puts("find efex cmd\n");
		sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		sunxi_board_run_fel();

		return 0;
	}

	if(!strcmp(misc_message->command, "boot-resignature"))
	{
		puts("find boot-resignature cmd\n");
		sunxi_flash_write(misc_offset, 2048/512, misc_fill);
		sunxi_oem_op_lock(SUNXI_LOCKING, NULL, 1);
	}
	else if(!strcmp(misc_message->command, "boot-recovery"))
	{
		puts("Recovery detected, will boot recovery\n");
		sunxi_str_replace(boot_commond, "boot_normal", "boot_recovery");
		/* android recovery will clean the misc */
	}
	else if(!strcmp(misc_message->command, "bootloader"))
	{
		puts("Fastboot detected, will boot fastboot\n");
		sunxi_str_replace(boot_commond, "boot_normal", "boot_fastboot");
		if(misc_offset)
			sunxi_flash_write(misc_offset, 2048/512, misc_fill);
	}
	
	setenv("bootcmd", boot_commond);

	printf("to be run cmd=%s\n", boot_commond);
#endif
	return 0;
}